-
Notifications
You must be signed in to change notification settings - Fork 0
433 lines (400 loc) · 15.2 KB
/
Copy pathci.yml
File metadata and controls
433 lines (400 loc) · 15.2 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ---------------------------------------------------------------------------
# Detect which paths changed so downstream jobs can be skipped when
# irrelevant files are touched. Always runs — no path filter here.
# ---------------------------------------------------------------------------
changes:
name: Detect changed paths
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: read
outputs:
python: ${{ steps.filter.outputs.python }}
infra: ${{ steps.filter.outputs.infra }}
proto: ${{ steps.filter.outputs.proto }}
ts_sdk: ${{ steps.filter.outputs.ts_sdk }}
admin_ui: ${{ steps.filter.outputs.admin_ui }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
python:
- 'packages/**'
- 'apps/gateway/**'
- 'tests/**'
- 'scripts/**'
- 'sdks/python/**'
- 'pyproject.toml'
- 'uv.lock'
- 'proto/**'
- 'buf.yaml'
- 'buf.gen.yaml'
infra:
- 'infra/terraform/**'
- 'infra/helm/**'
proto:
- 'proto/**'
- 'buf.yaml'
- 'buf.gen.yaml'
ts_sdk:
- 'sdks/typescript/**'
admin_ui:
- 'apps/admin-ui/**'
# ---------------------------------------------------------------------------
# Lint + type-check + unit tests (Ubuntu + macOS + Windows)
# Cross-platform requirement: every step must pass on all three OSes.
# ---------------------------------------------------------------------------
lint-test:
name: Lint & Test (${{ matrix.os }})
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-14, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python 3.12
run: uv python install 3.12
- name: Install Python dependencies
run: uv sync --all-packages
- name: Ruff lint
run: uv run ruff check .
- name: Ruff format check
run: uv run ruff format --check .
- name: RAG001 — logging policy check
run: uv run python scripts/check_logging.py
- name: Mypy (strict)
run: uv run mypy packages/ apps/gateway/
- name: Pytest
# The perf gate is excluded here — it runs as its own single-runner job
# (perf-gate) where timing is stable; noisier macOS / Windows runners
# would make a latency budget flaky. The red-team gate is likewise its
# own job (redteam-gate) so the security suite is a named exit gate.
run: uv run pytest tests/ packages/ sdks/python/tests -x -q --tb=short -m "not perf and not redteam"
# ---------------------------------------------------------------------------
# Secrets scan — blocks if a real credential is planted in a PR.
# Intentionally has no path filter: always run on every push/PR.
# ---------------------------------------------------------------------------
secrets-scan:
name: Secrets scan (gitleaks)
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install gitleaks
run: |
curl -sSfL \
https://github.com/gitleaks/gitleaks/releases/download/v8.21.2/gitleaks_8.21.2_linux_x64.tar.gz \
| tar -xz gitleaks
sudo mv gitleaks /usr/local/bin/gitleaks
- name: Run gitleaks
run: gitleaks detect --source . --redact --exit-code 1
# ---------------------------------------------------------------------------
# Schema-drift gate — regenerates dist/schemas/ and fails if anything in the
# tracked schema artifacts is modified, staged, or untracked. Catches both
# "forgot to regenerate" and "forgot to git add" mistakes.
# ---------------------------------------------------------------------------
schema-drift:
name: Schema drift (dist/schemas/)
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --all-packages
- name: Regenerate JSON schemas
env:
PYTHONPATH: packages/core/src
run: uv run python -m rag_core.gen_schemas dist/schemas/
- name: Verify no drift
run: uv run python scripts/check_schema_drift.py
# ---------------------------------------------------------------------------
# OpenAPI-drift gate (Step 3.7) — re-export dist/openapi.{json,yaml} from the
# live gateway routes and fail if the committed spec is stale. The spec is
# the source of truth for the REST-side SDKs, so it must never lag the app.
# ---------------------------------------------------------------------------
openapi-drift:
name: OpenAPI drift (dist/openapi.*)
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --all-packages
- name: Re-export OpenAPI spec
run: uv run python scripts/export_openapi.py
- name: Verify no drift
run: uv run python scripts/check_openapi_drift.py
# ---------------------------------------------------------------------------
# TypeScript SDK (Step 3.7) — typecheck + unit tests for the hand-written
# @agentcontextos/sdk client. Runs only when sdks/typescript changes.
# ---------------------------------------------------------------------------
ts-sdk:
name: TypeScript SDK (typecheck + test)
needs: changes
if: needs.changes.outputs.ts_sdk == 'true'
runs-on: ubuntu-22.04
defaults:
run:
working-directory: sdks/typescript
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
- name: Typecheck
run: pnpm run typecheck
- name: Test
run: pnpm test
- name: Build
run: pnpm run build
# ---------------------------------------------------------------------------
# Admin UI (Step 3.10) — typecheck + lint + unit tests + production build for
# the Next.js operator console. Runs only when apps/admin-ui changes.
# ---------------------------------------------------------------------------
admin-ui:
name: Admin UI (typecheck + test + build)
needs: changes
if: needs.changes.outputs.admin_ui == 'true'
runs-on: ubuntu-22.04
defaults:
run:
working-directory: apps/admin-ui
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
- name: Typecheck
run: pnpm run typecheck
- name: Lint
run: pnpm run lint
- name: Test
run: pnpm test
- name: Build
run: pnpm run build
# ---------------------------------------------------------------------------
# Framework adapters (Step 3.8) — install the lighter framework extras and
# run the agentcontextos.integrations adapter tests so the mapping logic is
# exercised against the real framework base classes (not just skipped). The
# heavier extras (crewai, semantic-kernel) stay skip-if-absent here.
# ---------------------------------------------------------------------------
integrations:
name: Framework adapters
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --all-packages
- name: Install framework extras
run: uv pip install langchain-core llama-index-core haystack-ai dspy langgraph autogen-core
- name: Run adapter tests
run: uv run pytest sdks/python/tests/test_integrations.py -q
# ---------------------------------------------------------------------------
# Proto lint + drift gate (Step 3.2) — buf lint over proto/, then
# regenerate Python stubs and fail if anything in apps/gateway/.../_grpc_gen/
# differs from a fresh codegen run. Drift gate runs on all three OSes to
# catch grpcio-tools / mypy-protobuf platform-specific output differences
# before they hit a developer.
# ---------------------------------------------------------------------------
proto-lint:
name: Proto lint (buf)
needs: changes
if: needs.changes.outputs.proto == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: buf lint
proto-drift:
name: Proto stub drift (${{ matrix.os }})
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-14, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --all-packages
- name: Regenerate gRPC stubs
run: uv run python scripts/gen_proto_py.py
- name: Verify no drift
run: uv run python scripts/check_proto_drift.py
# ---------------------------------------------------------------------------
# Logging gates — schema + PII + event-registry (activated in Step 0.7b)
# ---------------------------------------------------------------------------
log-gates:
name: Log schema + PII gates
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --all-packages
- run: uv run pytest tests/logs/ -v
# ---------------------------------------------------------------------------
# Gateway latency gate (Step 4.6) — the p99 ≤ 30 ms overhead budget.
# Single runner (ubuntu) on purpose: a latency budget needs stable timing, so
# it is excluded from the noisier cross-OS unit sweep and enforced here.
# ---------------------------------------------------------------------------
perf-gate:
name: Gateway latency gate
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --all-packages
- name: Gateway p99 overhead gate
run: uv run pytest tests/perf/ -v -m perf
# ---------------------------------------------------------------------------
# Red-team — adversarial security probe suites (Step 7.3). Deterministic +
# in-process, so a single runner; named separately so the security gate is a
# first-class CI exit gate (prompt injection ≥95% block + no untrusted chunk
# in a system-trust position; ACL bypass; PII egress; tenant escape).
# ---------------------------------------------------------------------------
redteam-gate:
name: Red-team security gate
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --all-packages
- name: Adversarial probe suites
run: uv run pytest tests/redteam/ -v -m redteam
# ---------------------------------------------------------------------------
# IaC validation — terraform validate + helm lint (no live cluster needed)
# ---------------------------------------------------------------------------
iac:
name: IaC validate (terraform + helm)
needs: changes
if: needs.changes.outputs.infra == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "~1.9"
- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: "latest"
- name: Terraform validate — dev
working-directory: infra/terraform/environments/dev
run: |
terraform init -backend=false
terraform validate
- name: Terraform validate — prod
working-directory: infra/terraform/environments/prod
run: |
terraform init -backend=false
terraform validate
- name: Helm lint — rag-platform
run: helm lint infra/helm/rag-platform/
- name: Helm template — dry run
run: helm template rag-platform infra/helm/rag-platform/ > /dev/null
# ---------------------------------------------------------------------------
# Dependency CVE audit
# ---------------------------------------------------------------------------
audit:
name: pip-audit
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --all-packages
- run: uv run pip-audit
# ---------------------------------------------------------------------------
# Required status-check gate.
# Always runs; fails only if a real job failed (skipped jobs are OK).
# Configure "CI passed" as the required branch-protection check in GitHub.
# ---------------------------------------------------------------------------
ci-pass:
name: CI passed
needs: [lint-test, secrets-scan, schema-drift, log-gates, audit, iac, proto-lint, proto-drift, perf-gate, redteam-gate]
if: always()
runs-on: ubuntu-22.04
steps:
- name: Check job results
run: |
results='${{ toJSON(needs.*.result) }}'
echo "Job results: $results"
if echo "$results" | grep -q '"failure"'; then
echo "One or more jobs failed."
exit 1
fi
echo "All jobs passed or were skipped."