Skip to content

Commit b6aa161

Browse files
committed
Update CI configuration
This change: * Updates the GitHub actions so that they run different commands for the dynamic and static flavors of libgit2. * Updates the .travis.yml file so that it does roughly the same as the GitHub actions. * Adds the release-* branches to the CI configurations. (cherry picked from commit 26edffd)
1 parent 1564166 commit b6aa161

File tree

7 files changed

+171
-37
lines changed

7 files changed

+171
-37
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ on:
44
push:
55
branches:
66
- master
7+
- release-*
78
- v*
89

910
jobs:
1011

11-
build:
12+
build-legacy:
1213
strategy:
1314
fail-fast: false
1415
matrix:
15-
go: [ '1.9', '1.10', '1.11', '1.12' , '1.13']
16+
go: [ '1.9', '1.10' ]
1617
name: Go ${{ matrix.go }}
1718

1819
runs-on: ubuntu-18.04
@@ -23,9 +24,66 @@ jobs:
2324
with:
2425
go-version: ${{ matrix.go }}
2526
id: go
27+
- name: Check out code into the GOPATH
28+
uses: actions/checkout@v1
29+
with:
30+
fetch-depth: 1
31+
path: src/github.com/${{ github.repository }}
32+
- name: Build
33+
env:
34+
GOPATH: /home/runner/work/git2go
35+
run: |
36+
git submodule update --init
37+
make build-libgit2-static
38+
go get --tags "static" github.com/${{ github.repository }}/...
39+
go build --tags "static" github.com/${{ github.repository }}/...
40+
- name: Test
41+
env:
42+
GOPATH: /home/runner/work/git2go
43+
run: make test-static
44+
45+
build-static:
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
go: [ '1.11', '1.12', '1.13' ]
50+
name: Go ${{ matrix.go }}
51+
52+
runs-on: ubuntu-18.04
53+
54+
steps:
55+
- name: Set up Go
56+
uses: actions/setup-go@v1
57+
with:
58+
go-version: ${{ matrix.go }}
59+
id: go
60+
- name: Check out code into the Go module directory
61+
uses: actions/checkout@v1
62+
- name: Build
63+
run: |
64+
git submodule update --init
65+
make build-libgit2-static
66+
- name: Test
67+
run: make test-static
68+
69+
build-dynamic:
70+
strategy:
71+
fail-fast: false
72+
name: Go (dynamic)
73+
74+
runs-on: ubuntu-18.04
75+
76+
steps:
77+
- name: Set up Go
78+
uses: actions/setup-go@v1
79+
with:
80+
go-version: '1.13'
81+
id: go
2682
- name: Check out code into the Go module directory
2783
uses: actions/checkout@v1
2884
- name: Build
2985
run: |
3086
git submodule update --init
31-
make test-static
87+
make build-libgit2-dynamic
88+
- name: Test
89+
run: make test-dynamic

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/static-build/
2+
/dynamic-build/

.travis.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
language: go
22

33
go:
4-
- 1.7
5-
- 1.8
6-
- 1.9
4+
- "1.7"
5+
- "1.8"
6+
- "1.9"
77
- "1.10"
8+
- "1.11"
9+
- "1.12"
10+
- "1.13"
811
- tip
912

10-
script: make test-static
13+
install:
14+
- make build-libgit2-static
15+
- go get --tags "static" ./...
16+
17+
script:
18+
- make test-static
1119

1220
matrix:
1321
allow_failures:
1422
- go: tip
1523

1624
git:
17-
submodules: false
18-
19-
before_install:
20-
- git submodule update --init
25+
submodules: true
2126

2227
branches:
2328
only:
2429
- master
2530
- /v\d+/
26-
- next
31+
- /release-.*/

Makefile

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,53 @@
11
default: test
22

3-
test: build-libgit2
3+
# System library
4+
# ==============
5+
# This uses whatever version of libgit2 can be found in the system.
6+
test:
47
go run script/check-MakeGitError-thread-lock.go
5-
go test ./...
8+
go test --count=1 ./...
69

7-
install: build-libgit2
10+
install:
811
go install ./...
912

10-
build-libgit2:
13+
# Bundled dynamic library
14+
# =======================
15+
# In order to avoid having to manipulate `git_dynamic.go`, which would prevent
16+
# the system-wide libgit2.so from being used in a sort of ergonomic way, this
17+
# instead moves the complexity of overriding the paths so that the built
18+
# libraries can be found by the build and tests.
19+
.PHONY: build-libgit2-dynamic
20+
build-libgit2-dynamic:
21+
./script/build-libgit2-dynamic.sh
22+
23+
dynamic-build/install/lib/libgit2.so:
24+
./script/build-libgit2-dynamic.sh
25+
26+
test-dynamic: dynamic-build/install/lib/libgit2.so
27+
PKG_CONFIG_PATH=dynamic-build/install/lib/pkgconfig \
28+
go run script/check-MakeGitError-thread-lock.go
29+
PKG_CONFIG_PATH=dynamic-build/install/lib/pkgconfig \
30+
LD_LIBRARY_PATH=dynamic-build/install/lib \
31+
go test --count=1 ./...
32+
33+
install-dynamic: dynamic-build/install/lib/libgit2.so
34+
PKG_CONFIG_PATH=dynamic-build/install/lib/pkgconfig \
35+
go install ./...
36+
37+
# Bundled static library
38+
# ======================
39+
# This is mostly used in tests, but can also be used to provide a
40+
# statically-linked library with the bundled version of libgit2.
41+
.PHONY: build-libgit2-static
42+
build-libgit2-static:
1143
./script/build-libgit2-static.sh
1244

13-
install-static: build-libgit2
14-
go install --tags "static" ./...
45+
static-build/install/lib/libgit2.a:
46+
./script/build-libgit2-static.sh
1547

16-
test-static: build-libgit2
48+
test-static: static-build/install/lib/libgit2.a
1749
go run script/check-MakeGitError-thread-lock.go
18-
go test --tags "static" ./...
50+
go test --count=1 --tags "static" ./...
51+
52+
install-static: static-build/install/lib/libgit2.a
53+
go install --tags "static" ./...

script/build-libgit2-dynamic.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
exec "$(dirname "$0")/build-libgit2.sh" --dynamic

script/build-libgit2-static.sh

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
#!/bin/sh
22

3-
set -ex
3+
set -e
44

5-
ROOT="$(cd "$(dirname "$0")/.." && echo "${PWD}")"
6-
BUILD_PATH="${ROOT}/static-build"
7-
VENDORED_PATH="${ROOT}/vendor/libgit2"
8-
9-
mkdir -p "${BUILD_PATH}/build" "${BUILD_PATH}/install/lib"
10-
11-
cd "${BUILD_PATH}/build" &&
12-
cmake -DTHREADSAFE=ON \
13-
-DBUILD_CLAR=OFF \
14-
-DBUILD_SHARED_LIBS=OFF \
15-
-DCMAKE_C_FLAGS=-fPIC \
16-
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
17-
-DCMAKE_INSTALL_PREFIX="${BUILD_PATH}/install" \
18-
"${VENDORED_PATH}" &&
19-
20-
cmake --build . --target install
5+
exec "$(dirname "$0")/build-libgit2.sh" --static

script/build-libgit2.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
3+
# Since CMake cannot build the static and dynamic libraries in the same
4+
# directory, this script helps build both static and dynamic versions of it and
5+
# have the common flags in one place instead of split between two places.
6+
7+
set -e
8+
9+
if [ "$#" -eq "0" ]; then
10+
echo "Usage: $0 <--dynamic|--static>">&2
11+
exit 1
12+
fi
13+
14+
ROOT="$(cd "$(dirname "$0")/.." && echo "${PWD}")"
15+
VENDORED_PATH="${ROOT}/vendor/libgit2"
16+
17+
case "$1" in
18+
--static)
19+
BUILD_PATH="${ROOT}/static-build"
20+
BUILD_SHARED_LIBS=OFF
21+
;;
22+
23+
--dynamic)
24+
BUILD_PATH="${ROOT}/dynamic-build"
25+
BUILD_SHARED_LIBS=ON
26+
;;
27+
28+
*)
29+
echo "Usage: $0 <--dynamic|--static>">&2
30+
exit 1
31+
;;
32+
esac
33+
34+
mkdir -p "${BUILD_PATH}/build" "${BUILD_PATH}/install/lib"
35+
36+
cd "${BUILD_PATH}/build" &&
37+
cmake -DTHREADSAFE=ON \
38+
-DBUILD_CLAR=OFF \
39+
-DBUILD_SHARED_LIBS"=${BUILD_SHARED_LIBS}" \
40+
-DCMAKE_C_FLAGS=-fPIC \
41+
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
42+
-DCMAKE_INSTALL_PREFIX="${BUILD_PATH}/install" \
43+
"${VENDORED_PATH}" &&
44+
45+
exec cmake --build . --target install

0 commit comments

Comments
 (0)