-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (150 loc) · 5.31 KB
/
Copy pathgo-race.yml
File metadata and controls
176 lines (150 loc) · 5.31 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: go-race
on:
push:
branches:
- "**"
pull_request:
permissions:
contents: read
jobs:
check:
name: fmt-and-test-go${{ matrix.go-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version:
- "1.24.x"
- "1.26.x"
include:
- go-version: "1.24.x"
run_extended: false
- go-version: "1.26.x"
run_extended: true
permissions:
contents: read
env:
GOTOOLCHAIN: local
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- name: Enforce root source whitelist
run: |
set -euo pipefail
expected="$(printf '%s\n' builder.go config.go context.go doc.go engine.go error_mapping.go errors.go goAuth.go types.go | sort)"
actual="$(ls -1 *.go | grep -v '_test.go$' | sort)"
if [ "$actual" != "$expected" ]; then
echo "Root source file whitelist mismatch"
echo "Expected:"
echo "$expected"
echo "Actual:"
echo "$actual"
exit 1
fi
disallowed="$(ls -1 *.go | grep -v '_test.go$' | grep -E '(limiter|store|audit|metrics|engine_)' || true)"
if [ -n "$disallowed" ]; then
echo "Disallowed root source file names detected:"
echo "$disallowed"
exit 1
fi
- name: Require changelog entry for API/config changes
if: github.event_name == 'pull_request'
run: |
set -euo pipefail
# Files that require a CHANGELOG.md entry when modified
API_PATTERNS="^(builder|config|context|engine|errors|goAuth|types)\.go$|^docs/api-reference\.md$|^docs/config\.md$"
CHANGED=$(git diff --name-only "${{ github.event.pull_request.base.sha }}" HEAD || true)
NEEDS_CL=false
for f in $CHANGED; do
if echo "$f" | grep -qE "$API_PATTERNS"; then
NEEDS_CL=true
break
fi
done
if [ "$NEEDS_CL" = "true" ]; then
if ! echo "$CHANGED" | grep -q "^CHANGELOG.md$"; then
echo "::error::Public API or config docs changed but CHANGELOG.md was not updated."
echo "Add an entry under [Unreleased] in CHANGELOG.md."
exit 1
fi
fi
- name: Go environment summary
run: |
echo "=== Go version ==="
go version
echo "=== Go env (selected) ==="
go env GOVERSION GOTOOLCHAIN GOROOT GOPATH GOOS GOARCH CGO_ENABLED
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@v0.42.0
- name: Check gofmt
run: |
files=$(find . -name '*.go' -not -path './vendor/*')
test -z "$(gofmt -l $files)"
- name: Check goimports
run: |
files=$(find . -name '*.go' -not -path './vendor/*')
test -z "$($(go env GOPATH)/bin/goimports -l $files)"
- name: Run unit tests (includes vet)
run: go test ./...
- name: Build example app
run: go build ./examples/http-minimal/...
- name: Check engine.go delegate complexity
run: go test -run TestEngine_DelegateMethodComplexity -v .
- name: Run integration tests (miniredis)
run: go test -tags=integration ./test/...
- name: Run integration tests (real Redis)
if: matrix.run_extended
run: |
docker compose -f docker-compose.test.yml up -d --wait
REDIS_ADDR=127.0.0.1:6379 go test -tags=integration -v -run 'TestRedisCompat' ./test/...
docker compose -f docker-compose.test.yml down
- name: Run fuzz tests (short)
if: matrix.run_extended
run: |
go test -fuzz=FuzzSessionDecode -fuzztime=30s ./session/
go test -fuzz=FuzzMaskCodecRoundTrip -fuzztime=30s ./permission/
go test -fuzz=FuzzDecodeRefreshToken -fuzztime=30s ./internal/
go test -fuzz=FuzzJWTParseAccess -fuzztime=30s ./jwt/
- name: Run perf sanity
if: matrix.go-version == '1.24.x'
run: bash security/run_perf_sanity.sh
- name: Install static analysis tools
if: matrix.run_extended
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Run staticcheck
if: matrix.run_extended
run: $(go env GOPATH)/bin/staticcheck "-checks=all,-ST1000,-ST1003,-ST1005,-U1000" ./...
- name: Run security scanners with baseline
if: matrix.run_extended
run: bash security/run_scanners.sh
race:
name: race-${{ matrix.os }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
env:
GOTOOLCHAIN: local
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: "1.26.x"
check-latest: true
- name: Run race tests
run: go test -race ./...