-
Notifications
You must be signed in to change notification settings - Fork 0
250 lines (233 loc) · 6.93 KB
/
Copy pathci.yml
File metadata and controls
250 lines (233 loc) · 6.93 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: CI
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
name: Cross-platform test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# The coverage job runs the complete suite on Linux.
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- run: go test -short -p=8 -parallel=8 ./...
validate-agents-md:
name: Validate AGENTS.md
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- run: make docs-check
formatting:
name: Go formatting
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Check formatting
run: make fmt-check
golangci-lint:
name: Go linters
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- uses: golangci/golangci-lint-action@v7
with:
version: v2.12.2
args: --timeout=5m
check-large-files:
name: Check file sizes
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Prevent growth of oversized Go files
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
PUSH_BEFORE: ${{ github.event.before }}
run: |
base=$PUSH_BEFORE
if [[ $EVENT_NAME == pull_request ]]; then
base=$PR_BASE
fi
if [[ -z $base || $base =~ ^0+$ ]] || ! git cat-file -e "$base^{commit}"; then
base=$(git rev-list --max-parents=0 HEAD)
fi
errors=0
while IFS= read -r file; do
[[ -z $file || ! -f $file ]] && continue
current_lines=$(wc -l < "$file")
base_lines=0
if git cat-file -e "$base:$file" 2>/dev/null; then
base_lines=$(git show "$base:$file" | wc -l)
fi
if (( current_lines > 800 && current_lines > base_lines )); then
echo "::error file=$file::$file grew from $base_lines to $current_lines lines; oversized Go files may not grow"
errors=$((errors + 1))
elif (( current_lines > 800 )); then
echo "::warning file=$file::$file remains oversized at $current_lines lines (baseline: $base_lines)"
fi
done < <(git diff --name-only --diff-filter=ACMR "$base"...HEAD -- '*.go')
if (( errors > 0 )); then
exit 1
fi
echo "No changed oversized Go file grew"
coverage:
name: Test coverage
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Run tests with timing and flaky detection
run: |
gotestsum --junitfile test-results.xml --rerun-fails=2 --rerun-fails-max-failures=5 --packages="./..." -- \
-short -p=8 -parallel=8 \
-coverprofile=coverage.out \
-covermode=set \
-coverpkg=./internal/... \
-timeout 180s
- name: Check coverage threshold
run: |
coverage=$(go tool cover -func=coverage.out | tail -n1 | awk '{print $NF}' | tr -d '%')
awk -v coverage="$coverage" 'BEGIN { if (coverage < 70) exit 1 }' || { \
echo "Coverage $coverage% is below 70% threshold"; \
exit 1; \
}
echo "Coverage: $coverage% (passes 70% threshold)"
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results
path: test-results.xml
- name: Upload coverage artifact
if: always()
uses: actions/upload-artifact@v7
with:
name: coverage
path: coverage.out
race:
name: Focused race tests
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- run: make test-race
integration:
name: Integration tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- run: make test-integration
tidy:
name: Module tidy check
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Check go.mod is tidy
run: make tidy-check
generated:
name: Generated outputs
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- run: make generate-check
security:
name: Security scan
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: go
- name: Build
run: go build ./...
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v3
npm:
name: npm launcher and package metadata
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v7
with:
node-version: 22
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- run: npm run test:npm
- run: npm run test:e2e
- run: npm pack --dry-run