fix(ci): stop Postgres state-bleed across CI runs (#277) #299
No reviewers
Labels
No labels
area:auth
area:ci
area:db
area:infra
area:native
area:pwa
area:service
epic
feature
foundation
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
james/carol!299
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "277-postgres-ci-state-bleed"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #277.
Problem
The self-hosted Forgejo
act_runnerreuses the Postgres service container'sdata volume across CI runs, so a table created by one PR's run (e.g. #269's
organization_key_people) is still physically present at the start of thenext run. When a PR is stale across a table-adding migration, the test
teardown's hardcoded
KYSELY_TABLESdrop list doesn't know about the orphantable, its FK blocks the
peopledrop, and all 15 Postgres suites fail atapps/api/tests/db/_engines.ts. This is the #259-family failure that bit PR#270.
Both fixes from the ticket are applied (defense-in-depth):
Fix 1 — tmpfs the Postgres data dir (CI)
.forgejo/workflows/pr.yml: thetestjob'spostgresservice now mounts--tmpfs /var/lib/postgresql/data, so the data dir lives in RAM and is freshon every container start.
initdbre-runs clean each time, making therunner's volume reuse harmless. Fixes the visible symptom.
Fix 2 — derive the teardown drop-list at runtime (test infra)
apps/api/tests/db/_engines.ts: the hardcodedKYSELY_TABLESarray is gone.The Postgres engine setup now queries
information_schema.tables(publicschema, base tables) and drops each with
CASCADE. FK ordering no longermatters, and no
KYSELY_TABLESedit is ever needed when a migration adds atable (#259). A database left orphaned by a previous run still tears down
cleanly even if the infra side regresses. Also drops the stale
KYSELY_TABLESreference in018_people.ts's down-migration comment.This directly satisfies acceptance criterion 2, so the alternative CI
drift-assertion is not needed.
Verification (local, Docker Postgres)
people+ a dependent FK table) into theDB, re-ran: 953 passed — teardown handles the orphan (pre-fix this
failed at the
peopledrop).TEST_POSTGRES_URL): 786 passed / 167 skipped,unchanged.
tsc --noEmitandactionlintclean.End-to-end acceptance (CI-only): a PR branched off a stale base across a
table-adding migration should now go green without a rebase.
🤖 Generated with Claude Code
📊 Test coverage
Patch coverage: no testable lines changed.
Overall (
app/,lib/,db/, excluding UI per ADR-0019):Soft thresholds per ADR-0019. Coverage is informational and does not block merge.