go #111
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: go | |
on: | |
pull_request: | |
push: | |
jobs: | |
build-and-test: | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GO111MODULE: 'on' | |
CGO_ENABLED: '0' | |
strategy: | |
fail-fast: true | |
matrix: | |
go: ['1.14', '1.x'] | |
# Locked at https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | |
os: | |
- ubuntu-20.04 | |
- windows-2019 | |
- macos-10.15 | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash | |
name: ${{ matrix.go }} on ${{ matrix.os }} | |
steps: | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ matrix.go }} | |
- id: go-cache-paths | |
run: | | |
echo "::set-output name=go-build::$(go env GOCACHE)" | |
echo "::set-output name=go-mod::$(go env GOMODCACHE)" | |
- run: echo ${{ steps.go-cache-paths.outputs.go-build }} | |
- run: echo ${{ steps.go-cache-paths.outputs.go-mod }} | |
- name: Go Build Cache | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-build }} | |
key: ${{ runner.os }}-go-${{ matrix.go }}-build-${{ hashFiles('**/go.sum') }} | |
- name: Go Mod Cache (go>=1.15) | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-mod }} | |
key: ${{ runner.os }}-go-${{ matrix.go }}-mod-${{ hashFiles('**/go.sum') }} | |
if: matrix.go != '1.14' | |
- uses: actions/checkout@v2 | |
- run: go mod download && go mod tidy && go mod verify | |
- if: runner.os == 'Linux' | |
run: git --no-pager diff && [[ $(git --no-pager diff --name-only | wc -l) = 0 ]] | |
- run: go vet ./... | |
- if: runner.os == 'Linux' | |
run: git --no-pager diff && [[ $(git --no-pager diff --name-only | wc -l) = 0 ]] | |
- run: go fmt ./... | |
- if: runner.os == 'Linux' | |
run: git --no-pager diff && [[ $(git --no-pager diff --name-only | wc -l) = 0 ]] | |
- run: go test ./... | |
- run: go test -v -run TestRaceyPatternSchema -race ./... | |
env: | |
CGO_ENABLED: '1' | |
- if: runner.os == 'Linux' | |
run: git --no-pager diff && [[ $(git --no-pager diff --name-only | wc -l) = 0 ]] | |
- run: | | |
cp openapi3/testdata/load_with_go_embed_test.go openapi3/ | |
cat go.mod | sed 's%go 1.14%go 1.16%' >gomod && mv gomod go.mod | |
go test ./... | |
if: matrix.go != '1.14' | |
- if: runner.os == 'Linux' | |
name: Errors must not be capitalized https://github.com/golang/go/wiki/CodeReviewComments#error-strings | |
run: | | |
! git grep -E '(fmt|errors)[^(]+\(.[A-Z]' | |
- if: runner.os == 'Linux' | |
name: Did you mean %q | |
run: | | |
! git grep -E "'[%].'" |