-
Notifications
You must be signed in to change notification settings - Fork 15
341 lines (284 loc) · 9.95 KB
/
ci.yml
File metadata and controls
341 lines (284 loc) · 9.95 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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
name: CI
on:
push:
branches: [ main, master ]
pull_request:
branches: [ "**" ]
permissions:
contents: write
jobs:
go:
name: Go ${{ matrix.task }}
runs-on: ubuntu-latest
strategy:
matrix:
task: [test, lint, build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
# Test task
- name: Setup Python for tests
if: matrix.task == 'test'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Python worker package
if: matrix.task == 'test'
run: |
cd worker/python
pip install -e .
cd ../..
- name: Test with coverage
if: matrix.task == 'test'
shell: bash
run: |
set -euo pipefail
pkgs=$(go list ./... | grep -v '/bench')
if [ -n "$pkgs" ]; then
go test -timeout 5m -v -race -coverprofile=coverage.out -covermode=atomic $pkgs
fi
- name: Check Go coverage is 100%
if: matrix.task == 'test'
continue-on-error: true
shell: bash
run: |
set -euo pipefail
if [ -f coverage.out ]; then
coverage=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
echo "Total coverage: ${coverage}%"
if (( $(echo "$coverage < 100" | bc -l) )); then
echo "⚠️ Coverage ${coverage}% is below 100% (currently non-blocking)"
echo "Goal: Achieve 100% coverage before re-enabling strict enforcement"
else
echo "✅ Coverage is 100%"
fi
fi
- name: Upload coverage to Codecov
if: matrix.task == 'test' && github.event_name == 'push'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
fail_ci_if_error: false
- name: Update coverage report
if: matrix.task == 'test' && github.event_name == 'push'
uses: ncruces/go-coverage-report@v0
with:
report: true
chart: true
amend: true
continue-on-error: true
# Lint task
- name: Go fmt check
if: matrix.task == 'lint'
run: |
fmt_out=$(gofmt -l . || true)
if [ -n "$fmt_out" ]; then
echo "Run 'go fmt' on the following files:" >&2
echo "$fmt_out" >&2
exit 1
fi
- name: golangci-lint
if: matrix.task == 'lint'
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout=5m
# Build task
- name: Go vet
if: matrix.task == 'build'
shell: bash
run: |
set -euo pipefail
pkgs=$(go list ./... | grep -v '/bench')
if [ -n "$pkgs" ]; then
echo "$pkgs" | xargs -r -n1 go vet
fi
- name: Build all packages
if: matrix.task == 'build'
shell: bash
run: |
set -euo pipefail
pkgs=$(go list ./... | grep -v '/bench')
if [ -n "$pkgs" ]; then
echo "$pkgs" | xargs -r -n1 go build
fi
- name: Build examples
if: matrix.task == 'build'
run: go build ./examples/basic
python:
name: Python lint and tests (uv)
runs-on: ubuntu-latest
defaults:
run:
working-directory: worker/python
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup uv and Python
uses: astral-sh/setup-uv@v4
- name: Sync dependencies
run: uv sync --all-extras --dev
- name: Ruff check
run: uv run ruff check .
- name: Ruff format check
run: uv run ruff format --check .
- name: ty check
run: uv run ty check .
- name: Pytest with coverage
run: uv run pytest -q --cov=pyproc_worker --cov-report=term-missing --cov-report=xml
- name: Check Python coverage is 100%
continue-on-error: true
run: |
coverage=$(uv run coverage report --precision=2 | grep TOTAL | awk '{print $4}' | sed 's/%//')
echo "Total coverage: ${coverage}%"
if (( $(echo "$coverage < 100" | bc -l) )); then
echo "⚠️ Coverage ${coverage}% is below 100% (currently non-blocking)"
echo "Goal: Achieve 100% coverage before re-enabling strict enforcement"
else
echo "✅ Coverage is 100%"
fi
benchmark:
name: Performance benchmarks and gates
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Setup Python with uv
uses: astral-sh/setup-uv@v4
- name: Install Python dependencies
run: |
cd worker/python
uv sync --all-extras
- name: Run benchmarks
run: |
cd bench
go test -bench=BenchmarkLatencyPercentiles -benchmem -benchtime=10s -timeout=5m | tee benchmark_results.txt || true
# Extract and check performance metrics
if grep -q "p50:" benchmark_results.txt; then
echo "=== Performance Results ==="
grep -E "p50:|p95:|p99:" benchmark_results.txt
# Extract p50 value (in microseconds)
p50=$(grep "p50:" benchmark_results.txt | sed -E 's/.*p50: ([0-9.]+).*/\1/')
p99=$(grep "p99:" benchmark_results.txt | sed -E 's/.*p99: ([0-9.]+).*/\1/')
echo ""
echo "Checking performance gates..."
# Check p50 < 100µs
if [ ! -z "$p50" ]; then
if (( $(echo "$p50 > 100" | bc -l) )); then
echo "⚠️ p50 latency ${p50}µs exceeds target of 100µs (non-blocking)"
else
echo "✅ p50 latency ${p50}µs meets target (<100µs)"
fi
fi
# Check p99 < 500µs
if [ ! -z "$p99" ]; then
if (( $(echo "$p99 > 500" | bc -l) )); then
echo "⚠️ p99 latency ${p99}µs exceeds target of 500µs (non-blocking)"
else
echo "✅ p99 latency ${p99}µs meets target (<500µs)"
fi
fi
else
echo "No latency metrics found in benchmark results"
fi
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: bench/benchmark_results.txt
pr-language:
name: PR language check (English)
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Check PR title and body are in English
uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title;
const body = context.payload.pull_request.body || '';
// Detect non-ASCII heavy content (CJK, Cyrillic, etc.)
const nonAsciiRatio = (str) => {
if (!str || str.length === 0) return 0;
const nonAscii = str.match(/[^\x00-\x7F]/g) || [];
return nonAscii.length / str.length;
};
const titleRatio = nonAsciiRatio(title);
const bodyRatio = nonAsciiRatio(body);
console.log(`Title non-ASCII ratio: ${(titleRatio * 100).toFixed(1)}%`);
console.log(`Body non-ASCII ratio: ${(bodyRatio * 100).toFixed(1)}%`);
const threshold = 0.3;
const issues = [];
if (titleRatio > threshold) {
issues.push(`PR title contains ${(titleRatio * 100).toFixed(0)}% non-ASCII characters. Please use English.`);
}
if (body.length > 0 && bodyRatio > threshold) {
issues.push(`PR body contains ${(bodyRatio * 100).toFixed(0)}% non-ASCII characters. Please use English.`);
}
if (issues.length > 0) {
core.setFailed(issues.join('\n'));
} else {
console.log('PR title and body are in English.');
}
links:
name: README and docs link check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Link Checker
uses: lycheeverse/lychee-action@v2
with:
args: --config .lychee.toml README.md "docs/**/*.md"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
sbom:
name: SBOM generation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install syft
uses: anchore/sbom-action/download-syft@v0
- name: Generate Go SBOM
run: syft dir:. --exclude ./worker/python -o cyclonedx-json=sbom-go.cdx.json
- name: Generate Python SBOM
run: syft dir:worker/python -o cyclonedx-json=sbom-python.cdx.json
- name: Upload SBOMs
uses: actions/upload-artifact@v4
with:
name: sbom
path: |
sbom-go.cdx.json
sbom-python.cdx.json
k8s-manifests:
name: K8s manifest validation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Helm
uses: azure/setup-helm@v4
- name: Install kustomize
uses: imranismail/setup-kustomize@v2
- name: Helm lint
run: helm lint charts/pyproc/
- name: Helm template
run: helm template test charts/pyproc/
- name: Kustomize build - dev
run: kustomize build deploy/kustomize/overlays/dev
- name: Kustomize build - staging
run: kustomize build deploy/kustomize/overlays/staging
- name: Kustomize build - production
run: kustomize build deploy/kustomize/overlays/production