Skip to content

Commit 03aace0

Browse files
committed
add .github/workflows/go-check.yml
1 parent 2214382 commit 03aace0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/go-check.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# File managed by web3-bot. DO NOT EDIT.
2+
# See https://github.com/protocol/.github/ for details.
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
unit:
8+
runs-on: ubuntu-latest
9+
name: Go checks
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-go@v2
13+
with:
14+
go-version: "1.16.x"
15+
- name: Install staticcheck
16+
run: go install honnef.co/go/tools/cmd/staticcheck@be534f007836a777104a15f2456cd1fffd3ddee8 # v2020.2.2
17+
- name: Check that go.mod is tidy
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: ${{ success() || failure() }} # 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: ${{ success() || failure() }} # run this step even if the previous one failed
35+
run: go vet ./...
36+
- name: staticcheck
37+
if: ${{ success() || failure() }} # run this step even if the previous one failed
38+
run: |
39+
set -o pipefail
40+
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
41+

0 commit comments

Comments
 (0)