From 69742799330d3cab35c66a892dbcee67b8ae1389 Mon Sep 17 00:00:00 2001 From: Fatih Arslan Date: Thu, 13 May 2021 22:55:39 +0300 Subject: [PATCH] Improve CI * Don't run the CI twice in pull requests * Add check for `go.mod` consistency * Upgrade Go version to `1.16.x` * Ugrade the Go `actions/setup-go` actions library to `v2` --- .github/workflows/go.yml | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 043028d..7ed538b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,24 +1,40 @@ name: build -on: [push, pull_request] -jobs: +on: + push: + branches: + - master + - main + pull_request: - test-build: +jobs: + test: name: Test & Build runs-on: ubuntu-latest steps: - - name: Set up Go 1.15 - uses: actions/setup-go@v1 + - name: Set up Go 1.16 + uses: actions/setup-go@v2 with: - go-version: 1.15.3 - id: go + go-version: ^1.16 - name: Check out code into the Go module directory uses: actions/checkout@v2 + + - name: Run go mod tidy + run: | + set -e + go mod tidy + output=$(git status -s) + if [ -z "${output}" ]; then + exit 0 + fi + echo 'We wish to maintain a tidy state for go mod. Please run `go mod tidy` on your branch, commit and push again.' + echo 'Running `go mod tidy` on this CI test yields with the following changes:' + echo "$output" + exit 1 - name: Test - run: | - go test -race ./... + run: go test -race ./... - name: Build run: go build ./...