Skip to content

chore(ci): extract E2E fixture seeding to a shared script instead of scraping deploy.yml #203

Open

Description

@diffwireauto

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 SQL heredoc delimiter
  • changing the quoting on the UPDATE observers line
  • 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:

  1. Extract the seeding into scripts/e2e-seed-fixture.sh "$DB" — the UPDATE observers IATA repair and the #1486 grouped-packet row, i.e. the Seed observer IATA codes and Seed grouped-packet row for #1486 collapse test steps [repo: .github/workflows/deploy.yml:321,325].
  2. Change those workflow steps to call it.
  3. Change e2e-local.sh to 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.

Refs #198, #200, #199, #201

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions