From dc7dbc5d286be384cca118fe7c686c54f1759515 Mon Sep 17 00:00:00 2001 From: Shinebayar G <3091558+shinebayar-g@users.noreply.github.com> Date: Mon, 5 Oct 2020 04:29:47 -0500 Subject: [PATCH] ci: migrate to Github Actions, close #546 (#750) * ci: migrate to Github Actions * ci: optimize on feedback * ci: run gocov in correct dir * ci: running after-build script always * ci: giving test script execute permission * ci: correct error handling on test script * ci: more verbose test script * ci: configure CC_TEST_REPORTER_ID env * ci: check existence of CC_TEST_REPORT_ID variable, skip if unset * ci: check existence of CC_TEST_REPORT_ID variable, skip if unset * update changelog * Update CHANGELOG.md Co-authored-by: Joel Speed --- .github/workflows/ci.yaml | 55 +++++++++++++++++++++++++++++++++++++++ CHANGELOG.md | 1 + test.sh | 27 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 .github/workflows/ci.yaml create mode 100755 test.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000000..c5e6340309 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,55 @@ +name: Continuous Integration + +on: + push: + branches: + - '**' + # - $default-branch + pull_request: + branches: + - '**' + # - $default-branch + +jobs: + build: + env: + COVER: true + GOPATH: ${{ github.workspace }} + runs-on: ubuntu-18.04 + steps: + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + with: + path: ./src/github.com/${{ github.repository }} + + - name: Set up Go 1.14 + uses: actions/setup-go@v2 + with: + go-version: ^1.14 + id: go + + - name: Get dependencies + run: | + cd src/github.com/${{ github.repository }} + curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin v1.24.0 + GO111MODULE=on go mod download + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + + - name: Lint + run: | + cd src/github.com/${{ github.repository }} + make lint + + - name: Build + run: | + cd src/github.com/${{ github.repository }} + make build + + - name: Test + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + run: | + cd src/github.com/${{ github.repository }} + ./test.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e7824f0a8..41dabfa9a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ - [#800](https://github.com/oauth2-proxy/oauth2-proxy/pull/800) Fix import path for v7 (@johejo) - [#783](https://github.com/oauth2-proxy/oauth2-proxy/pull/783) Update Go to 1.15 (@johejo) - [#813](https://github.com/oauth2-proxy/oauth2-proxy/pull/813) Fix build (@thiagocaiubi) +- [#750](https://github.com/oauth2-proxy/oauth2-proxy/pull/750) ci: Migrate to Github Actions (@shinebayar-g) # v6.1.1 diff --git a/test.sh b/test.sh new file mode 100755 index 0000000000..c4f6ef8533 --- /dev/null +++ b/test.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# manually exiting from script, because after-build needs to run always +set +e + +if [ -z $CC_TEST_REPORT_ID ]; then + echo "1. CC_TEST_REPORT_ID is unset, skipping" +else + echo "1. Running before-build" + ./cc-test-reporter before-build +fi + +echo "2. Running test" +make test +TEST_STATUS=$? +echo "TEST_STATUS: ${TEST_STATUS}" + +if [ -z $CC_TEST_REPORT_ID ]; then + echo "3. CC_TEST_REPORT_ID is unset, skipping" +else + echo "3. Running after-build" + ./cc-test-reporter after-build --exit-code $TEST_STATUS -t gocov +fi + +if [ "$TEST_STATUS" -ne 0 ]; then + echo "Test failed, status code: $TEST_STATUS" + exit $TEST_STATUS +fi