Skip to content

Commit

Permalink
ci: migrate to Github Actions, close oauth2-proxy#546 (oauth2-proxy#750)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
shinebayar-g and JoelSpeed authored Oct 5, 2020
1 parent 8be97f2 commit dc7dbc5
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 27 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dc7dbc5

Please sign in to comment.