8
8
unit :
9
9
runs-on : ubuntu-latest
10
10
name : All
11
+ env :
12
+ RUNGOGENERATE : false
11
13
steps :
12
14
- uses : actions/checkout@v2
13
15
with :
14
16
submodules : recursive
15
17
- uses : actions/setup-go@v2
16
18
with :
17
- go-version : " 1.16.x"
19
+ go-version : " 1.17.x"
20
+ - name : Run repo-specific setup
21
+ uses : ./.github/actions/go-check-setup
22
+ if : hashFiles('./.github/actions/go-check-setup') != ''
23
+ - name : Read config
24
+ if : hashFiles('./.github/workflows/go-check-config.json') != ''
25
+ run : |
26
+ if jq -re .gogenerate ./.github/workflows/go-check-config.json; then
27
+ echo "RUNGOGENERATE=true" >> $GITHUB_ENV
28
+ fi
18
29
- name : Install staticcheck
19
- run : go install honnef.co/go/tools/cmd/staticcheck@434f5f3816b358fe468fa83dcba62d794e7fe04b # 2021.1 (v0.2.0 )
30
+ run : go install honnef.co/go/tools/cmd/staticcheck@df71e5d0e0ed317ebf43e6e59cf919430fa4b8f2 # 2021.1.1 (v0.2.1 )
20
31
- name : Check that go.mod is tidy
21
- uses : protocol/multiple-go-modules@v1.0
32
+ uses : protocol/multiple-go-modules@v1.2
22
33
with :
23
34
run : |
24
35
go mod tidy
@@ -37,14 +48,27 @@ jobs:
37
48
fi
38
49
- name : go vet
39
50
if : ${{ success() || failure() }} # run this step even if the previous one failed
40
- uses : protocol/multiple-go-modules@v1.0
51
+ uses : protocol/multiple-go-modules@v1.2
41
52
with :
42
53
run : go vet ./...
43
54
- name : staticcheck
44
55
if : ${{ success() || failure() }} # run this step even if the previous one failed
45
- uses : protocol/multiple-go-modules@v1.0
56
+ uses : protocol/multiple-go-modules@v1.2
46
57
with :
47
58
run : |
48
59
set -o pipefail
49
60
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
61
+ - name : go generate
62
+
63
+ if : (success() || failure()) && env.RUNGOGENERATE == 'true'
64
+ with :
65
+ run : |
66
+ git clean -fd # make sure there aren't untracked files / directories
67
+ go generate ./...
68
+ # check if go generate modified or added any files
69
+ if ! $(git add . && git diff-index HEAD --exit-code --quiet); then
70
+ echo "go generated caused changes to the repository:"
71
+ git status --short
72
+ exit 1
73
+ fi
50
74
0 commit comments