-
Notifications
You must be signed in to change notification settings - Fork 0
414 lines (389 loc) · 16.1 KB
/
Copy pathci.yml
File metadata and controls
414 lines (389 loc) · 16.1 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
name: CI
# PR-oriented fast gate (target wall time under ~10 minutes). Full multi-Python
# coverage stays on the Nightly workflow. Design/rationale:
# design/operations/pr-ci-fast-gate.md
on:
push:
branches: ["main"]
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
UV_PYTHON: "3.13"
jobs:
changes:
name: Path filters
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
workers: ${{ steps.filter.outputs.workers }}
surfaces: ${{ steps.filter.outputs.surfaces }}
adapters: ${{ steps.filter.outputs.adapters }}
compose: ${{ steps.filter.outputs.compose }}
shared_core: ${{ steps.filter.outputs.shared_core }}
ci_control: ${{ steps.filter.outputs.ci_control }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: .github/ci/path-filters.yml
quality:
name: Quality
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
version: "0.12.6"
enable-cache: true
- name: Set up Python 3.13
run: uv python install 3.13
- name: Install dependencies (locked)
run: uv sync --locked --python 3.13
- name: Test inventory drift check
run: python3 .github/ci/check_test_inventory.py
- name: Architecture dependency check
run: uv run lint-imports
- name: Ruff lint
run: uv run ruff check src/ benchmarks/
- name: Ruff format check
run: uv run ruff format --check src/ benchmarks/
- name: Pyright type check
run: uv run pyright src/ benchmarks/ --pythonversion 3.13
unit:
name: Unit
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
version: "0.12.6"
enable-cache: true
- name: Set up Python 3.13
run: uv python install 3.13
- name: Install dependencies (locked)
run: uv sync --locked --python 3.13
- name: Unit pack (no Postgres service)
run: |
mapfile -t paths < .github/ci/unit-paths.txt
if [ "${#paths[@]}" -eq 0 ]; then
echo "unit-paths.txt is empty" >&2
exit 1
fi
uv run pytest "${paths[@]}" -q --tb=short
contract-smoke:
name: Contract smoke
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
env:
REMEMBERSTACK_DATABASE_URL: postgresql+psycopg://rememberstack:rememberstack_test@localhost:5432/rememberstack_test
steps:
- uses: actions/checkout@v4
- name: Start PostgreSQL 19 with required extensions
run: .github/ci/start-postgres.sh
- uses: astral-sh/setup-uv@v5
with:
version: "0.12.6"
enable-cache: true
- name: Set up Python 3.13
run: uv python install 3.13
- name: Install dependencies (locked)
run: uv sync --locked --python 3.13
- name: Contract smoke pack
run: |
mapfile -t paths < .github/ci/contract-smoke-paths.txt
uv run pytest "${paths[@]}" -v --tb=short
integration-workers:
name: Integration (workers)
needs: changes
if: >-
github.event_name == 'push'
|| needs.changes.outputs.workers == 'true'
|| needs.changes.outputs.shared_core == 'true'
|| needs.changes.outputs.ci_control == 'true'
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
env:
REMEMBERSTACK_DATABASE_URL: postgresql+psycopg://rememberstack:rememberstack_test@localhost:5432/rememberstack_test
steps:
- uses: actions/checkout@v4
- name: Start PostgreSQL 19 with required extensions
run: .github/ci/start-postgres.sh
- uses: astral-sh/setup-uv@v5
with:
version: "0.12.6"
enable-cache: true
- name: Set up Python 3.13
run: uv python install 3.13
- name: Install dependencies (locked)
run: uv sync --locked --python 3.13
- name: Workers + spine integration
run: uv run pytest src/tests/workers src/tests/spine -q --tb=short
integration-surfaces:
name: Integration (surfaces)
needs: changes
if: >-
github.event_name == 'push'
|| needs.changes.outputs.surfaces == 'true'
|| needs.changes.outputs.shared_core == 'true'
|| needs.changes.outputs.ci_control == 'true'
runs-on: ubuntu-latest
timeout-minutes: 50
permissions:
contents: read
env:
REMEMBERSTACK_DATABASE_URL: postgresql+psycopg://rememberstack:rememberstack_test@localhost:5432/rememberstack_test
steps:
- uses: actions/checkout@v4
- name: Start PostgreSQL 19 with required extensions
run: .github/ci/start-postgres.sh
- uses: astral-sh/setup-uv@v5
with:
version: "0.12.6"
enable-cache: true
- name: Set up Python 3.13
run: uv python install 3.13
- name: Install dependencies (locked)
run: uv sync --locked --python 3.13
- name: Surfaces + eval integration
run: uv run pytest src/tests/surfaces src/tests/eval -q --tb=short
integration-adapters:
name: Integration (adapters)
needs: changes
if: >-
github.event_name == 'push'
|| needs.changes.outputs.adapters == 'true'
|| needs.changes.outputs.shared_core == 'true'
|| needs.changes.outputs.ci_control == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
env:
REMEMBERSTACK_DATABASE_URL: postgresql+psycopg://rememberstack:rememberstack_test@localhost:5432/rememberstack_test
steps:
- uses: actions/checkout@v4
- name: Start PostgreSQL 19 with required extensions
run: .github/ci/start-postgres.sh
- uses: astral-sh/setup-uv@v5
with:
version: "0.12.6"
enable-cache: true
- name: Set up Python 3.13
run: uv python install 3.13
- name: Install dependencies (locked)
run: uv sync --locked --python 3.13
- name: Adapters + profiles + spikes integration
run: |
uv run pytest src/tests/adapters src/tests/profiles src/tests/spikes -q --tb=short
compose-quickstart:
name: Compose quickstart
needs: changes
if: >-
github.event_name == 'push'
|| needs.changes.outputs.compose == 'true'
|| needs.changes.outputs.ci_control == 'true'
runs-on: ubuntu-latest
timeout-minutes: 25
permissions:
contents: read
env:
QUICKSTART_TARGET_SECONDS: "600"
REMEMBERSTACK_BUILD_REVISION: ${{ github.sha }}
steps:
- uses: actions/checkout@v4
- name: Validate Compose model
run: docker compose --env-file .env.example config --quiet
- name: Start fresh self-host deployment
run: |
started_at="$(date +%s)"
docker compose --env-file .env.example up --build --detach --wait
curl --fail http://localhost:8000/operations
served_revision="$(curl --fail --silent http://localhost:8000/deployment \
| python3 -c 'import json,sys; print(json.load(sys.stdin)["build_revision"])')"
test "$served_revision" = "${REMEMBERSTACK_BUILD_REVISION}"
query_result="$(curl --fail --silent \
--header 'Content-Type: application/json' \
--data '{"sql":"SELECT count(*) AS document_count FROM documents_live","parameters":[],"max_rows":1}' \
http://localhost:8000/query/sql)"
printf '%s' "$query_result" | python3 -c \
'import json,sys; result=json.load(sys.stdin); assert result["termination_reason"] == "completed", result'
elapsed_seconds="$(($(date +%s) - started_at))"
echo "Quickstart cold start to first query: ${elapsed_seconds}s / ${QUICKSTART_TARGET_SECONDS}s target" \
| tee -a "$GITHUB_STEP_SUMMARY"
test "$elapsed_seconds" -le "$QUICKSTART_TARGET_SECONDS"
- name: Prove MinIO conditional create
run: |
docker compose --env-file .env.example exec -T api python - <<'PY'
from rememberstack.adapters.selfhost import MinIOObjectStore, MinIOSettings
from rememberstack.model import ObjectAlreadyExistsError, ObjectKey
store = MinIOObjectStore(
bucket="remember-raw", settings=MinIOSettings.model_validate({})
)
key = ObjectKey("ci/immutable-object")
store.write_bytes(key=key, content=b"first")
try:
store.write_bytes(key=key, content=b"replacement")
except ObjectAlreadyExistsError:
pass
else:
raise RuntimeError("MinIO replaced an immutable object key")
PY
- name: Prove the zero-cost full pipeline
run: |
running_services="$(
docker compose --env-file .env.example ps --status running --services
)"
for service in \
api worker-convert worker-structure worker-chunk worker-embed-chunk \
worker-extract-claims worker-normalize-relations \
worker-adjudicate-observations worker-adjudicate-supersession \
worker-embed-claim worker-reconcile worker-label-relation; do
printf '%s\n' "$running_services" | grep -qx "$service"
done
ingested="$(
curl --fail --header 'Content-Type: application/octet-stream' \
--data-binary ' ' \
'http://localhost:8000/ingest?filename=empty.md&mime=text%2Fmarkdown'
)"
version_id="$(
printf '%s' "$ingested" |
docker compose --env-file .env.example exec -T api \
python -c 'import json, sys; print(json.load(sys.stdin)["version_id"])'
)"
# D84/D88/D90: extract is chunk-scoped; empty input skips claim
# normalize and takes durable empty_complete (no document_version
# adjudicate_observations row at the entity-fanout generation).
# Version-level ledger stages:
# convert→structure→chunk→embed_chunk→adjudicate_supersession→
# embed_claim→label→reconcile (8).
observed=''
for attempt in {1..60}; do
observed="$(docker compose --env-file .env.example exec -T postgres \
psql -U rememberstack -d rememberstack -Atc \
"SELECT count(*), count(*) FILTER (WHERE status='succeeded'), count(DISTINCT stage) FROM processing_state WHERE target_id='$version_id'")"
if [ "$observed" = '8|8|8' ]; then
break
fi
sleep 1
done
test "$observed" = '8|8|8'
test "$(docker compose --env-file .env.example exec -T postgres \
psql -U rememberstack -d rememberstack -Atc \
'SELECT count(*) FROM cost_ledger')" = '0'
docker compose --env-file .env.example --profile operations \
run --rm projections
readiness="$(
curl --fail --header 'Content-Type: application/json' \
--data "{\"version_ids\":[\"$version_id\"],\"require\":{\"pipeline\":true,\"p1\":true,\"live_graph\":true,\"p3\":true}}" \
'http://localhost:8000/readiness'
)"
printf '%s' "$readiness" |
docker compose --env-file .env.example exec -T api python -c \
'import json, sys; report = json.load(sys.stdin); assert report["ready"]; assert all(item["ready"] for item in report["versions"]); assert all(item["ready"] for item in report["capabilities"].values())'
- name: Stage an upgrade from the prior schema
run: |
docker compose --env-file .env.example stop \
api worker-convert worker-structure worker-chunk worker-embed-chunk \
worker-extract-claims worker-normalize-relations \
worker-adjudicate-observations worker-adjudicate-supersession \
worker-embed-claim worker-reconcile worker-label-relation
docker compose --env-file .env.example run --rm --no-deps \
--entrypoint alembic setup downgrade p7_02_0016
test "$(docker compose --env-file .env.example exec -T postgres \
psql -U rememberstack -d rememberstack -Atc \
'SELECT version_num FROM alembic_version')" = 'p7_02_0016'
test "$(docker compose --env-file .env.example exec -T postgres \
psql -U rememberstack -d rememberstack -Atc \
'SELECT count(*) FROM deployments')" = '1'
docker compose --env-file .env.example rm --force setup
- name: Run migrations before application processes restart
run: |
compose_args=(
--env-file .env.example
--file compose.yaml
--file .github/compose/upgrade-gate.yaml
)
docker compose "${compose_args[@]}" up --detach --wait &
compose_pid="$!"
release_gate() {
docker compose "${compose_args[@]}" exec -T setup \
touch /tmp/rememberstack-upgrade-release
}
trap 'release_gate || true' EXIT
setup_running=''
for attempt in {1..30}; do
setup_running="$(
docker compose "${compose_args[@]}" ps --status running --services setup
)"
if [ "$setup_running" = 'setup' ]; then
break
fi
sleep 1
done
test "$setup_running" = 'setup'
running_services="$(
docker compose "${compose_args[@]}" ps --status running --services
)"
test -z "$(printf '%s\n' "$running_services" \
| grep -E '^(api|worker-(convert|structure|chunk|embed-chunk|extract-claims|normalize-relations|adjudicate-observations|adjudicate-supersession|embed-claim|reconcile|label-relation))$' || true)"
test "$(docker compose "${compose_args[@]}" exec -T postgres \
psql -U rememberstack -d rememberstack -Atc \
'SELECT version_num FROM alembic_version')" = 'p7_02_0016'
release_gate
wait "$compose_pid"
trap - EXIT
test "$(docker compose --env-file .env.example exec -T postgres \
psql -U rememberstack -d rememberstack -Atc \
'SELECT version_num FROM alembic_version')" = 'p9_26_0047'
test "$(docker compose --env-file .env.example exec -T postgres \
psql -U rememberstack -d rememberstack -Atc \
'SELECT count(*) FROM deployments')" = '1'
running_services="$(
docker compose "${compose_args[@]}" ps --status running --services
)"
for service in \
api worker-convert worker-structure worker-chunk worker-embed-chunk \
worker-extract-claims worker-normalize-relations \
worker-adjudicate-observations worker-adjudicate-supersession \
worker-embed-claim worker-reconcile worker-label-relation; do
printf '%s\n' "$running_services" | grep -qx "$service"
done
curl --fail http://localhost:8000/healthz
- name: Show service logs after failure
if: failure()
run: docker compose --env-file .env.example logs --no-color
- name: Remove quickstart deployment
if: always()
run: docker compose --env-file .env.example down --volumes
# Single always-present required check. Integration path jobs are soft.
pr-gate:
name: PR gate
runs-on: ubuntu-latest
needs: [changes, quality, unit, contract-smoke]
if: always()
steps:
- name: Require hard lanes (incl. path selector)
run: |
echo "changes=${{ needs.changes.result }}"
echo "quality=${{ needs.quality.result }}"
echo "unit=${{ needs.unit.result }}"
echo "contract-smoke=${{ needs.contract-smoke.result }}"
test "${{ needs.changes.result }}" = "success"
test "${{ needs.quality.result }}" = "success"
test "${{ needs.unit.result }}" = "success"
test "${{ needs.contract-smoke.result }}" = "success"