-
Notifications
You must be signed in to change notification settings - Fork 0
349 lines (296 loc) · 11.7 KB
/
Copy pathci.yml
File metadata and controls
349 lines (296 loc) · 11.7 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
name: CI
on:
push:
pull_request:
jobs:
migrations:
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: rag_assistant
POSTGRES_USER: rag
POSTGRES_PASSWORD: rag_dev_password
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U rag -d rag_assistant"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: postgresql://rag:rag_dev_password@localhost:5432/rag_assistant
DB_ENCRYPTION_KEY: ci-test-key-32-characters-long-xyz
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: "pip"
cache-dependency-path: requirements.lock
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --require-hashes -r requirements.lock
- name: Run migration round-trip audit
run: python scripts/migration_round_trip.py
helm:
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: azure/setup-helm@v4
- name: Helm lint
run: helm lint deploy/helm/ --strict
- name: Render chart
run: |
helm template deploy/helm/ --values deploy/helm/values.yaml \
--set secrets.existingSecret=ci-placeholder \
--set env.CORS_ORIGINS=https://support.example.com \
--set postgresql.auth.password=ci-placeholder \
> /tmp/rendered.yaml
- uses: helm/kind-action@v1
- name: Client dry-run
run: kubectl apply --dry-run=client -f /tmp/rendered.yaml
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: "pip"
cache-dependency-path: |
requirements-dev.lock
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --require-hashes -r requirements-dev.lock
- name: Lint
run: ruff check .
type-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: "pip"
cache-dependency-path: |
requirements-dev.lock
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --require-hashes -r requirements-dev.lock
- name: Run mypy on strict scope
# Strict modules (auth, db.*, llm.providers, config/settings.py,
# agent/state.py, agent/prompts.py, agent/prompt_registry.py,
# agent/tools.py, agent/graph.py, tasks.*, utils.*, monitoring.*,
# channels.*, tracing.*, ingestion.*, evaluation.*, api/app.py +
# api/_shared.py, api/correlation.py, api/rate_limit.py, api/routers/*,
# vectordb.*) must remain green. Codex audit 2026-04-27 H3 + next-steps
# Steps 6, 9 + api.app strict promotion 2026-04-28 + db/tasks/utils
# 2026-06-13 + monitoring/channels 2026-06-13 + tracing/ingestion
# 2026-06-13 + evaluation 2026-06-13 + api routers/helpers 2026-06-14 +
# vectordb 2026-06-14.
# The first (main) path list is kept in sync across this job,
# scripts/local-gate.ps1, and scripts/autopilot.ps1 by
# test_mypy_strict_scope_is_synced_across_gates. The second command keeps
# --follow-imports=skip for its heavy-graph modules: api/_shared.py
# transitively imports api.app, whose full FastAPI graph times out under
# mypy, and vectordb pulls langchain/sentence-transformers, whose type
# graph spikes memory. It is intentionally outside the sync guard.
run: |
python -m mypy auth db llm/providers/ config/settings.py agent/state.py agent/prompts.py agent/prompt_registry.py agent/tools.py agent/graph.py tasks utils monitoring channels tracing ingestion evaluation --no-incremental --show-error-codes
python -m mypy api/app.py api/_shared.py api/correlation.py api/rate_limit.py api/routers vectordb --no-incremental --follow-imports=skip --show-error-codes
test-unit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.13"]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
requirements-dev.lock
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --require-hashes -r requirements-dev.lock
- name: Run unit tests
run: pytest tests/ -q --ignore=tests/integration -p no:cacheprovider
test-integration:
# Codex audit 2026-04-27 H4: integration job must block PRs.
# If a Postgres/Redis-backed test fails, the PR should turn red.
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.13"]
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: rag_test
POSTGRES_USER: rag
POSTGRES_PASSWORD: rag_test_password
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U rag -d rag_test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: postgresql+asyncpg://rag:rag_test_password@127.0.0.1:5432/rag_test
REDIS_URL: redis://127.0.0.1:6379/0
OLLAMA_BASE_URL: http://127.0.0.1:65535
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
requirements-dev.lock
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --require-hashes -r requirements-dev.lock
- name: Run integration tests
run: pytest tests/integration -q --timeout=120 --timeout-method=thread
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: "pip"
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit==4.5.1
- name: Run pre-commit
run: pre-commit run --all-files
security:
# Codex audit 2026-04-27 next-steps Step 7: bandit + pip-audit run as
# blocking PR gates (also live in pre-commit, but a dedicated job
# surfaces them clearly in GitHub Checks and audits the locked deps,
# not the loose constraint file).
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: "pip"
- name: Install audit tooling
run: |
python -m pip install --upgrade pip
pip install bandit[toml]==1.9.4 pip-audit==2.10.0
- name: Bandit static analysis
# -ll: Medium+ severity blocks. Low findings are advisory only.
run: bandit -r . -ll -c pyproject.toml -x ./tests,./.venv,./reports,./data,./archive-legacy,./.tmp
- name: pip-audit (locked dependencies)
# --disable-pip: skip pip resolution; the lock is already complete.
# --require-hashes: enforce that every line carries a sha256.
# CVE-2026-45829/GHSA-f4j7-r4q5-qw2c is an unfixed ChromaDB server
# advisory (PyPI fixed_in is empty). This app uses embedded
# PersistentClient, not an exposed Chroma server; keep Chroma latest and
# retain a narrow ignore until upstream publishes a fixed release.
# CVE-2025-3000 is an unfixed torch advisory (local memory corruption in
# torch.jit.script, PyPI fixed_in empty). torch is used only for local
# sentence-transformers inference and torch.jit.script never receives
# untrusted input; drop the ignore once an upstream fix ships. Keep this
# list in sync with the pip-audit hook in .pre-commit-config.yaml.
run: >
pip-audit --strict --disable-pip --require-hashes
--timeout 15
--progress-spinner off
--cache-dir .tmp/pip-audit-cache
--ignore-vuln CVE-2026-45829
--ignore-vuln GHSA-f4j7-r4q5-qw2c
--ignore-vuln CVE-2025-3000
-r requirements.lock
regression-eval:
# Deterministic PR gate: experiment targets use mock runtime and report-only
# mode, so this does not require Ollama, vector-store setup, or database
# persistence. When regression inputs and the curated dataset are present,
# the script exit code enforces the regression gate.
if: github.event_name == 'pull_request'
name: regression-eval
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dorny/paths-filter@v4
id: regression_changes
with:
list-files: shell
filters: |
regression:
- 'agent/prompts.py'
- 'config/settings.py'
- 'evaluation/curated_cases.jsonl'
- 'evaluation/experiments/*.yaml'
- name: Skip when regression inputs did not change
if: steps.regression_changes.outputs.regression != 'true'
run: echo "No prompt/settings/experiment changes detected."
- uses: actions/setup-python@v6
if: steps.regression_changes.outputs.regression == 'true'
with:
python-version: "3.13"
cache: "pip"
cache-dependency-path: |
requirements-dev.lock
- name: Install dependencies
if: steps.regression_changes.outputs.regression == 'true'
run: |
python -m pip install --upgrade pip
pip install --require-hashes -r requirements-dev.lock
- name: Resolve regression candidate
if: steps.regression_changes.outputs.regression == 'true'
id: regression_target
shell: bash
run: |
candidate="current"
for file in ${{ steps.regression_changes.outputs.regression_files }}; do
if [[ "$file" == evaluation/experiments/*.yaml ]]; then
candidate="$(basename "$file" .yaml)"
break
fi
done
echo "candidate=$candidate" >> "$GITHUB_OUTPUT"
- name: Skip when curated dataset is unavailable
if: steps.regression_changes.outputs.regression == 'true' && !hashFiles('evaluation/curated_cases.jsonl')
run: echo "evaluation/curated_cases.jsonl is missing; skipping informational regression run."
- name: Run regression eval
if: steps.regression_changes.outputs.regression == 'true' && hashFiles('evaluation/curated_cases.jsonl')
run: >
python scripts/regression_eval.py
--baseline current
--candidate ${{ steps.regression_target.outputs.candidate }}
--dataset evaluation/curated_cases.jsonl
--tenant all
--max-cases 100
--seed 42
--mock-experiment-runtime
--no-persist