CI: per-run Postgres container name and ephemeral port (#165) #166
No reviewers
Labels
No labels
area:ai
area:ci-cd
area:notifications
area:observability
area:public-pages
backlog
bug
duplicate
enhancement
help wanted
invalid
question
type:decision
type:feature
type:infra
type:maintenance
type:security
v1.0.1
v1.1.0
v1.2.0
v1.3.0
v2.0.0
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rbrooks/WeatherBot!166
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/ci-postgres-collision"
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 #165.
Problem
When two PRs' CI runs overlap on the shared runner host, both go red: every job starts with
docker rm -f ci-postgres, force-removing the concurrent run's live database mid-suite, and the fixed-p 5432:5432publish would collide anyway. This happened to #163/#164 tonight (runs 141/142, started two minutes apart, both failed; both branches passed the full suite + ruff on the dev server and went green on solo reruns).Change
ci-postgres-${GITHUB_RUN_ID}; the pre-cleanrm -fand thealways()teardown are scoped to that name, so a job can only ever remove its own (possibly stale-from-a-crashed-rerun) container.-p 5432→ random free host port). The wait-and-detect step discovers the mapped port viadocker portand exportsPG_PORTalongsidePG_HOST; the migration and postgres-tier steps use both. Container-side candidates (container name, network IPs) still connect to 5432 directly, so both the containerized-job and host-job paths keep working.Verification
YAML parses; the detection script's candidate order is unchanged in spirit (container IPs → name → host fallbacks). This PR's own CI run exercises the whole path — and any future overlapping runs are the real test.
🤖 Generated with Claude Code
Two PRs' CI runs overlapped on the shared runner and both went red: every job began with `docker rm -f ci-postgres`, killing the concurrent run's live database mid-suite, and the fixed -p 5432:5432 publish would have collided anyway. The container is now named ci-postgres-${GITHUB_RUN_ID} (pre-clean and teardown scoped to it) and publishes an ephemeral host port; the wait-and-detect step discovers the mapped port via `docker port` and exports PG_PORT alongside PG_HOST for the migration and postgres-tier steps. Container-side candidates (container name / network IPs) still connect to 5432 directly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>