Skip to content

Commit d43da17

Browse files
committed
update .github/workflows/go-check.yml
1 parent af3ae0d commit d43da17

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

.github/workflows/go-check.yml

+29-5
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,28 @@ jobs:
88
unit:
99
runs-on: ubuntu-latest
1010
name: All
11+
env:
12+
RUNGOGENERATE: false
1113
steps:
1214
- uses: actions/checkout@v2
1315
with:
1416
submodules: recursive
1517
- uses: actions/setup-go@v2
1618
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
1829
- 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)
2031
- name: Check that go.mod is tidy
21-
uses: protocol/multiple-go-modules@v1.0
32+
uses: protocol/multiple-go-modules@v1.2
2233
with:
2334
run: |
2435
go mod tidy
@@ -37,14 +48,27 @@ jobs:
3748
fi
3849
- name: go vet
3950
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
4152
with:
4253
run: go vet ./...
4354
- name: staticcheck
4455
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
4657
with:
4758
run: |
4859
set -o pipefail
4960
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
61+
- name: go generate
62+
uses: protocol/[email protected]
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
5074

0 commit comments

Comments
 (0)