From 26c983c3a25cfb449e0e55d73871605c4d5667fa Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Thu, 15 Aug 2019 09:38:02 +0200 Subject: Setup CI via Actions --- .github/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/ci.yml (limited to '.github') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..34eed3b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: git2go CI +on: + pull_request: + push: + branches: + - master + - v* + +jobs: + + build: + strategy: + fail-fast: false + matrix: + go: [ '1.9', '1.10', '1.11', '1.12' ] + 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 Go module directory + uses: actions/checkout@v1 + - name: Build + run: make test-static -- cgit v1.2.3 From a5b3de11aec347d2431372afffd7bacb224d8ca3 Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Thu, 15 Aug 2019 09:42:58 +0200 Subject: submodule --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to '.github') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34eed3b..ab7a9da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,4 +26,6 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v1 - name: Build - run: make test-static + run: | + git submodule update --init + make test-static -- cgit v1.2.3 From b201c503ab5788b2ce5511fa75792127e27e254c Mon Sep 17 00:00:00 2001 From: lhchavez Date: Wed, 12 Feb 2020 17:07:17 -0800 Subject: Update .github/workflows/ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab7a9da..d058ec6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - go: [ '1.9', '1.10', '1.11', '1.12' ] + go: [ '1.9', '1.10', '1.11', '1.12' , '1.13'] name: Go ${{ matrix.go }} runs-on: ubuntu-18.04 -- cgit v1.2.3 From 26edffd5f57618d2927926fde4c4ac1fcba5d84a Mon Sep 17 00:00:00 2001 From: lhchavez Date: Sat, 22 Feb 2020 23:07:08 +0000 Subject: 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. --- .github/workflows/ci.yml | 64 +++++++++++++++++++++++++++++++++++++++-- .gitignore | 1 + .travis.yml | 16 +++++++---- Makefile | 47 ++++++++++++++++++++++++++---- script/build-libgit2-dynamic.sh | 5 ++++ script/build-libgit2-static.sh | 20 ++----------- script/build-libgit2.sh | 46 +++++++++++++++++++++++++++++ 7 files changed, 166 insertions(+), 33 deletions(-) create mode 100755 script/build-libgit2-dynamic.sh create mode 100755 script/build-libgit2.sh (limited to '.github') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d058ec6..931cc09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,15 +4,16 @@ on: push: branches: - master + - release-* - v* jobs: - build: + build-legacy: strategy: fail-fast: false 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 @@ -23,9 +24,66 @@ jobs: 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 }} + + 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 Go module directory + uses: actions/checkout@v1 + - name: Build + run: | + git submodule update --init + 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 test-static + make build-libgit2-dynamic + - name: Test + run: make test-dynamic diff --git a/.gitignore b/.gitignore index edc18d5..713781b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /static-build/ +/dynamic-build/ diff --git a/.travis.yml b/.travis.yml index 7d53122..b25a052 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,29 @@ language: go go: + - "1.9" + - "1.10" - "1.11" - "1.12" - "1.13" - tip -script: make test-static +install: + - make build-libgit2-static + - go get --tags "static" ./... + +script: + - make test-static matrix: allow_failures: - go: tip git: - submodules: false - -before_install: - - git submodule update --init + submodules: true branches: only: - master - /v\d+/ - - next + - /release-.*/ diff --git a/Makefile b/Makefile index 4dffce0..182c53e 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,53 @@ 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 test --count=1 ./... -install: build-libgit2 +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 -install-static: build-libgit2 - go install --tags "static" ./... +static-build/install/lib/libgit2.a: + ./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 test --count=1 --tags "static" ./... + +install-static: static-build/install/lib/libgit2.a + go install --tags "static" ./... diff --git a/script/build-libgit2-dynamic.sh b/script/build-libgit2-dynamic.sh new file mode 100755 index 0000000..af037f3 --- /dev/null +++ b/script/build-libgit2-dynamic.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -e + +exec "$(dirname "$0")/build-libgit2.sh" --dynamic diff --git a/script/build-libgit2-static.sh b/script/build-libgit2-static.sh index 26efc8e..1d28898 100755 --- a/script/build-libgit2-static.sh +++ b/script/build-libgit2-static.sh @@ -1,21 +1,5 @@ #!/bin/sh -set -ex +set -e -ROOT="$(cd "$(dirname "$0")/.." && echo "${PWD}")" -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 +exec "$(dirname "$0")/build-libgit2.sh" --static diff --git a/script/build-libgit2.sh b/script/build-libgit2.sh new file mode 100755 index 0000000..acbc84a --- /dev/null +++ b/script/build-libgit2.sh @@ -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 -- cgit v1.2.3