Repository navigation
198 lines (165 loc) · 5.91 KB
/
Copy pathtest.yml
File metadata and controls
198 lines (165 loc) · 5.91 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions: {}
jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- name: Check formatting
run: test -z "$(gofmt -l .)" || (echo "Run 'gofmt -w .' to fix formatting" && gofmt -l . && exit 1)
- name: Vet
run: go vet ./...
- name: Check go.mod tidiness
run: |
go mod tidy
git diff --exit-code go.mod go.sum
- name: Test
run: go test -v ./...
- name: Test the skills sync
run: seed/scripts/test-sync-skills.sh
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.9.0
lint-actions:
name: GitHub Actions audit
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Run actionlint
uses: rhysd/actionlint@914e7df21a07ef503a81201c76d2b11c789d3fca # v1.7.12
- name: Run zizmor
uses: zizmorcore/zizmor-action@3dc1ecc9bcb9e94e9b2c709687979e1298497054 # v0.6.2
with:
advanced-security: false
security:
name: Govulncheck
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Run govulncheck
run: govulncheck ./...
test-race:
name: Test (race detector)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- name: Test with race detector
run: go test -race -v ./...
benchmarks:
name: Benchmarks
runs-on: ubuntu-latest
permissions:
contents: read
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 2
persist-credentials: false
- name: Check for benchmark-relevant changes
id: filter
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
filters: |
bench:
- '**/*.go'
- 'go.mod'
- 'go.sum'
- name: Set up Go
if: steps.filter.outputs.bench == 'true'
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- name: Run benchmarks
if: steps.filter.outputs.bench == 'true'
run: |
set -o pipefail
go test -bench=. -benchmem -count=3 ./... | tee benchmarks.txt
- name: Download previous benchmark baseline
if: steps.filter.outputs.bench == 'true'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: benchmarks-baseline.txt
key: benchmarks-baseline-${{ github.sha }}
restore-keys: |
benchmarks-baseline-
- name: Install benchstat
if: steps.filter.outputs.bench == 'true'
run: go install golang.org/x/perf/cmd/benchstat@latest
- name: Compare benchmarks
if: steps.filter.outputs.bench == 'true' && hashFiles('benchmarks-baseline.txt') != ''
run: |
echo "## Benchmark Comparison" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
benchstat benchmarks-baseline.txt benchmarks.txt >> "$GITHUB_STEP_SUMMARY" 2>&1 || true
echo '```' >> "$GITHUB_STEP_SUMMARY"
- name: Check for significant regression
if: steps.filter.outputs.bench == 'true' && hashFiles('benchmarks-baseline.txt') != ''
run: |
benchstat benchmarks-baseline.txt benchmarks.txt > comparison.txt 2>&1 || true
if grep -E '\+[2-9][0-9]\.[0-9]+%|\+[1-9][0-9][0-9]+' comparison.txt; then
echo "::error::Performance regression detected (≥20% slower). See benchmark comparison in step summary."
exit 1
fi
- name: Save benchmark baseline
if: steps.filter.outputs.bench == 'true'
run: cp benchmarks.txt benchmarks-baseline.txt
- name: Cache benchmark baseline
if: steps.filter.outputs.bench == 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: benchmarks-baseline.txt
key: benchmarks-baseline-${{ github.sha }}
- name: Upload benchmark results
if: steps.filter.outputs.bench == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmarks
path: benchmarks.txt
retention-days: 30