Repository navigation
chore(ci): extract E2E fixture seeding to a shared script instead of scraping deploy.yml #203
Description
Follow-up to #198 (merged as d36d1ecc). Raised in review, deliberately not blocking that merge, filed so it is not lost.
The problem
scripts/e2e-local.sh gets its fixture-seeding SQL by parsing .github/workflows/deploy.yml with grep/sed/awk and piping the result into bash and sqlite3:
WF=.github/workflows/deploy.yml
grep -E "sqlite3 test-fixtures/e2e-fixture.db \"UPDATE observers" "$WF" \
| sed -E 's/^ *run: *//; s#test-fixtures/e2e-fixture.db#'"$DB"'#' | bash
awk '/sqlite3 test-fixtures\/e2e-fixture.db <<.SQL.$/{f=1;next} /^ *SQL$/{f=0} f' "$WF" | sqlite3 "$DB"This couples local E2E to the formatting of the workflow rather than its behaviour. Any of these breaks it:
- re-indenting the
run:block - renaming the
SQLheredoc delimiter - changing the quoting on the
UPDATE observersline - splitting that step in two
The failure mode is silent. grep matches nothing, the pipeline into bash succeeds with empty input, set -euo pipefail does not catch an empty-but-successful pipeline, and the script proceeds with an under-seeded fixture. Local tests then fail for reasons that have nothing to do with the code under test — which is the same class of confusion #199/#201 existed to remove.
Why it was merged anyway
The blast radius is one developer's local run. Nothing in CI invokes scripts/e2e-local.sh, nothing on prod depends on it, and it cannot produce a bad release. Worst case is wasted debugging time. Holding a devcontainer that unblocks macOS development on a maintainability concern was poor value.
The fix, and it is a pattern already in the repo
#199 solved exactly this shape for the server start: duplicated inline logic was pulled into scripts/e2e-fresh-server.sh and deploy.yml was changed to call it. One definition, two callers.
Do the same for seeding:
- Extract the seeding into
scripts/e2e-seed-fixture.sh "$DB"— theUPDATE observersIATA repair and the#1486grouped-packet row, i.e. theSeed observer IATA codesandSeed grouped-packet row for #1486 collapse teststeps[repo: .github/workflows/deploy.yml:321,325]. - Change those workflow steps to call it.
- Change
e2e-local.shto call it, deleting the grep/sed/awk block.
Result: no YAML parsing, no silent empty-seed, and seeding changes land in one place for both CI and local.
Worth deciding while in there
Whether Migrate fixture DB to current schema (#1287) [repo: deploy.yml:312] should move into the same script. e2e-local.sh already runs its own corescope-migrate -baseline-stamp-migrate, so that logic is duplicated too — but the CI and local invocations differ slightly, so this is a judgment call rather than an obvious lift.
Done when
scripts/e2e-local.sh contains no reference to deploy.yml, both CI and the local runner seed the fixture through one shared script, and a formatting change to the workflow cannot silently under-seed a local fixture.
Activity