ci: add more golang strictness checks
Adin Schmahmann committed
May 3, 2022 at 11:56 UTC
6f4fc1ae8e51db08bbad61c6c3bb217479db0643
1 file changed
+37
.github/workflows/golang-analysis.yml
new
+37
@@ -0,0 +1,37 @@
1
+on: [push, pull_request]
2
+name: Go Checks
3
+
4
+jobs:
5
+ unit:
6
+ runs-on: ubuntu-latest
7
+ name: All
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ with:
11
+ submodules: recursive
12
+ - uses: actions/setup-go@v2
13
+ with:
14
+ go-version: "1.17.x"
15
+ - name: Check that go.mod is tidy
16
+ uses: protocol/multiple-go-modules@v1.2
17
+ with:
18
+ run: |
19
+ go mod tidy
20
+ if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
21
+ echo "go.sum was added by go mod tidy"
22
+ exit 1
23
+ fi
24
+ git diff --exit-code -- go.sum go.mod
25
+ - name: gofmt
26
+ if: always() # run this step even if the previous one failed
27
+ run: |
28
+ out=$(gofmt -s -l .)
29
+ if [[ -n "$out" ]]; then
30
+ echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
31
+ exit 1
32
+ fi
33
+ - name: go vet
34
+ if: always() # run this step even if the previous one failed
35
+ uses: protocol/multiple-go-modules@v1.2
36
+ with:
37
+ run: go vet ./...