-
Notifications
You must be signed in to change notification settings - Fork 63
87 lines (78 loc) · 2.56 KB
/
check-static.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: check/static
on:
push:
branches: [stable]
pull_request:
types: [opened, synchronize, reopened]
branches: [staging]
paths:
- '**'
- '!.github/**'
- '.github/workflows/gochecks.yaml'
jobs:
go:
runs-on: ubuntu-latest
env:
RUNGOGENERATE: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
go-version: 1.22.0
cache: false
- name: Set Go variables
id: goenv
run: |
{
echo "cache=$(go env GOCACHE)"
echo "modcache=$(go env GOMODCACHE)"
echo "mod=$(go env GOMOD)"
} >>"$GITHUB_OUTPUT"
- name: Go caches
uses: actions/cache@v4
with:
path: |
${{ steps.goenv.outputs.cache }}
${{ steps.goenv.outputs.modcache }}
key: ${{ github.job }}-${{ runner.os }}-go-${{ hashFiles(steps.goenv.outputs.mod) }}
restore-keys: |
${{ github.job }}-${{ runner.os }}-go-
- name: Check that go.mod is tidy
uses: protocol/[email protected]
with:
run: |
git config --global --add safe.directory '*'
go mod tidy
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
echo "go.sum was added by go mod tidy"
exit 1
fi
git diff --exit-code -- go.sum go.mod
- name: gofumpt
if: success() || failure() # run this step even if the previous one failed
uses: golangci/golangci-lint-action@v5
with:
version: v1.56.2
args: --timeout=30m --no-config --disable-all --enable=gofumpt --out-format=colored-line-number
skip-cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v5
with:
version: v1.56.2
args: --timeout=30m --out-format=colored-line-number
skip-cache: true
- name: go generate
uses: protocol/[email protected]
if: (success() || failure()) && env.RUNGOGENERATE == 'true'
with:
run: |
git clean -fd # make sure there aren't untracked files / directories
go generate ./...
# check if go generate modified or added any files
if ! $(git add . && git diff-index HEAD --exit-code --quiet); then
echo "go generate caused changes to the repository:"
git status --short
exit 1
fi