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.
This commit is contained in:
lhchavez 2020-02-22 23:07:08 +00:00
parent 419bac9075
commit 26edffd5f5
7 changed files with 166 additions and 33 deletions

View File

@ -4,15 +4,49 @@ on:
push: push:
branches: branches:
- master - master
- release-*
- v* - v*
jobs: jobs:
build: build-legacy:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
go: [ '1.9', '1.10', '1.11', '1.12' , '1.13'] go: [ '1.9', '1.10' ]
name: Go ${{ matrix.go }}
runs-on: ubuntu-18.04
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go }}
id: go
- name: Check out code into the GOPATH
uses: actions/checkout@v1
with:
fetch-depth: 1
path: src/github.com/${{ github.repository }}
- name: Build
env:
GOPATH: /home/runner/work/git2go
run: |
git submodule update --init
make build-libgit2-static
go get --tags "static" github.com/${{ github.repository }}/...
go build --tags "static" github.com/${{ github.repository }}/...
- name: Test
env:
GOPATH: /home/runner/work/git2go
run: make test-static
build-static:
strategy:
fail-fast: false
matrix:
go: [ '1.11', '1.12', '1.13' ]
name: Go ${{ matrix.go }} name: Go ${{ matrix.go }}
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
@ -28,4 +62,28 @@ jobs:
- name: Build - name: Build
run: | run: |
git submodule update --init git submodule update --init
make test-static make build-libgit2-static
- name: Test
run: make test-static
build-dynamic:
strategy:
fail-fast: false
name: Go (dynamic)
runs-on: ubuntu-18.04
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: '1.13'
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Build
run: |
git submodule update --init
make build-libgit2-dynamic
- name: Test
run: make test-dynamic

1
.gitignore vendored
View File

@ -1 +1,2 @@
/static-build/ /static-build/
/dynamic-build/

View File

@ -1,25 +1,29 @@
language: go language: go
go: go:
- "1.9"
- "1.10"
- "1.11" - "1.11"
- "1.12" - "1.12"
- "1.13" - "1.13"
- tip - tip
script: make test-static install:
- make build-libgit2-static
- go get --tags "static" ./...
script:
- make test-static
matrix: matrix:
allow_failures: allow_failures:
- go: tip - go: tip
git: git:
submodules: false submodules: true
before_install:
- git submodule update --init
branches: branches:
only: only:
- master - master
- /v\d+/ - /v\d+/
- next - /release-.*/

View File

@ -1,18 +1,53 @@
default: test default: test
test: build-libgit2 # System library
# ==============
# This uses whatever version of libgit2 can be found in the system.
test:
go run script/check-MakeGitError-thread-lock.go go run script/check-MakeGitError-thread-lock.go
go test --count=1 ./... go test --count=1 ./...
install: build-libgit2 install:
go install ./... go install ./...
build-libgit2: # Bundled dynamic library
# =======================
# In order to avoid having to manipulate `git_dynamic.go`, which would prevent
# the system-wide libgit2.so from being used in a sort of ergonomic way, this
# instead moves the complexity of overriding the paths so that the built
# libraries can be found by the build and tests.
.PHONY: build-libgit2-dynamic
build-libgit2-dynamic:
./script/build-libgit2-dynamic.sh
dynamic-build/install/lib/libgit2.so:
./script/build-libgit2-dynamic.sh
test-dynamic: dynamic-build/install/lib/libgit2.so
PKG_CONFIG_PATH=dynamic-build/install/lib/pkgconfig \
go run script/check-MakeGitError-thread-lock.go
PKG_CONFIG_PATH=dynamic-build/install/lib/pkgconfig \
LD_LIBRARY_PATH=dynamic-build/install/lib \
go test --count=1 ./...
install-dynamic: dynamic-build/install/lib/libgit2.so
PKG_CONFIG_PATH=dynamic-build/install/lib/pkgconfig \
go install ./...
# Bundled static library
# ======================
# This is mostly used in tests, but can also be used to provide a
# statically-linked library with the bundled version of libgit2.
.PHONY: build-libgit2-static
build-libgit2-static:
./script/build-libgit2-static.sh ./script/build-libgit2-static.sh
install-static: build-libgit2 static-build/install/lib/libgit2.a:
go install --tags "static" ./... ./script/build-libgit2-static.sh
test-static: build-libgit2 test-static: static-build/install/lib/libgit2.a
go run script/check-MakeGitError-thread-lock.go go run script/check-MakeGitError-thread-lock.go
go test --count=1 --tags "static" ./... go test --count=1 --tags "static" ./...
install-static: static-build/install/lib/libgit2.a
go install --tags "static" ./...

View File

@ -0,0 +1,5 @@
#!/bin/sh
set -e
exec "$(dirname "$0")/build-libgit2.sh" --dynamic

View File

@ -1,21 +1,5 @@
#!/bin/sh #!/bin/sh
set -ex set -e
ROOT="$(cd "$(dirname "$0")/.." && echo "${PWD}")" exec "$(dirname "$0")/build-libgit2.sh" --static
BUILD_PATH="${ROOT}/static-build"
VENDORED_PATH="${ROOT}/vendor/libgit2"
mkdir -p "${BUILD_PATH}/build" "${BUILD_PATH}/install/lib"
cd "${BUILD_PATH}/build" &&
cmake -DTHREADSAFE=ON \
-DBUILD_CLAR=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DREGEX_BACKEND=builtin \
-DCMAKE_C_FLAGS=-fPIC \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_INSTALL_PREFIX="${BUILD_PATH}/install" \
"${VENDORED_PATH}" &&
cmake --build . --target install

46
script/build-libgit2.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
# Since CMake cannot build the static and dynamic libraries in the same
# directory, this script helps build both static and dynamic versions of it and
# have the common flags in one place instead of split between two places.
set -e
if [ "$#" -eq "0" ]; then
echo "Usage: $0 <--dynamic|--static>">&2
exit 1
fi
ROOT="$(cd "$(dirname "$0")/.." && echo "${PWD}")"
VENDORED_PATH="${ROOT}/vendor/libgit2"
case "$1" in
--static)
BUILD_PATH="${ROOT}/static-build"
BUILD_SHARED_LIBS=OFF
;;
--dynamic)
BUILD_PATH="${ROOT}/dynamic-build"
BUILD_SHARED_LIBS=ON
;;
*)
echo "Usage: $0 <--dynamic|--static>">&2
exit 1
;;
esac
mkdir -p "${BUILD_PATH}/build" "${BUILD_PATH}/install/lib"
cd "${BUILD_PATH}/build" &&
cmake -DTHREADSAFE=ON \
-DBUILD_CLAR=OFF \
-DBUILD_SHARED_LIBS"=${BUILD_SHARED_LIBS}" \
-DREGEX_BACKEND=builtin \
-DCMAKE_C_FLAGS=-fPIC \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_INSTALL_PREFIX="${BUILD_PATH}/install" \
"${VENDORED_PATH}" &&
exec cmake --build . --target install