...
1name: build
2on:
3 push:
4 branches:
5 - master
6 - main
7 pull_request:
8
9jobs:
10 test:
11 name: Test & Build
12 runs-on: ubuntu-latest
13 steps:
14
15 - name: Set up Go
16 uses: actions/setup-go@v4
17 with:
18 go-version: '>=1.20.0'
19
20 - name: Check out code into the Go module directory
21 uses: actions/checkout@v4
22
23 - name: Run go mod tidy
24 run: |
25 set -e
26 go mod tidy
27 output=$(git status -s)
28 if [ -z "${output}" ]; then
29 exit 0
30 fi
31 echo 'We wish to maintain a tidy state for go mod. Please run `go mod tidy` on your branch, commit and push again.'
32 echo 'Running `go mod tidy` on this CI test yields with the following changes:'
33 echo "$output"
34 exit 1
35
36 - name: Test
37 run: go test -race ./...
38
39 - name: Lint
40 run: "go vet ./..."
41
42 - name: Staticcheck
43 uses: dominikh/staticcheck-action@v1.3.0
44 with:
45 version: "2023.1.2"
46 install-go: false
47
48 - name: Build
49 run: go build ./...
View as plain text