File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Lint
2+ on :
3+ push :
4+ paths :
5+ - " **.go"
6+ - go.mod
7+ - go.sum
8+ pull_request :
9+ paths :
10+ - " **.go"
11+ - go.mod
12+ - go.sum
13+
14+ jobs :
15+ lint :
16+ runs-on : ubuntu-latest
17+
18+ steps :
19+ - name : Set up Go
20+ uses : actions/setup-go@v2
21+ with :
22+ go-version : 1.17
23+
24+ - name : Check out code
25+ uses : actions/checkout@v2
26+
27+ - name : Verify dependencies
28+ run : |
29+ go mod verify
30+ go mod download
31+
32+ LINT_VERSION=1.43.0
33+ curl -fsSL https://github.com/golangci/golangci-lint/releases/download/v${LINT_VERSION}/golangci-lint-${LINT_VERSION}-linux-amd64.tar.gz | \
34+ tar xz --strip-components 1 --wildcards \*/golangci-lint
35+ mkdir -p bin && mv golangci-lint bin/
36+
37+ - name : Run checks
38+ run : |
39+ STATUS=0
40+ assert-nothing-changed() {
41+ local diff
42+ "$@" >/dev/null || return 1
43+ if ! diff="$(git diff -U1 --color --exit-code)"; then
44+ printf '\e[31mError: running `\e[1m%s\e[22m` results in modifications that you must check into version control:\e[0m\n%s\n\n' "$*" "$diff" >&2
45+ git checkout -- .
46+ STATUS=1
47+ fi
48+ }
49+
50+ assert-nothing-changed go fmt ./...
51+ assert-nothing-changed go mod tidy
52+
53+ bin/golangci-lint run --out-format=github-actions --timeout=3m || STATUS=$?
54+
55+ exit $STATUS
You can’t perform that action at this time.
0 commit comments