Files
ServerKit/.github
Juan DenisandClaude Opus 5 ac48dc5b4e perf(ci): shard the backend suite across 4 runners
Backend CI was the entire pipeline wait. Measured on the last dev push:

    Extensions CI            12s
    Version Bump             18s
    Test System Utilities    35s
    Security Scan            41s
    Scripts CI               66s
    Release Build Smoke      68s
    Backend CI           21m 50s   <- everything else finished in a minute

Step timings put all of it in the test run itself (install deps 22s, ratchet
9s), so there is no caching win to take — it is 3173 tests against a
function-scoped `app` fixture that rebuilds the Flask app and all 80+ tables
per test. Fixing that fixture is the real repair and is planned separately;
this change buys the wall-clock back now without touching a single test.

Split over 4 runners via pytest-split (794/794/794/791). Sharding rather than
pytest-xdist is deliberate: each shard is its own VM, so the process-shared
state that makes in-process parallelism unsafe here (templates.json, APPS_DIR
— see the per-PID DB dance in tests/conftest.py) simply isn't shared, and no
test code has to change.

The ratchet moves to its own job because it must see the whole suite; a shard
only collects its quarter. It runs beside the shards and costs no wall-clock.

Two details:

- The shard command is scoped to `tests` rather than a bare `pytest`.
  Identical in CI (3173 either way, backend/dev-data/ being gitignored), but a
  bare pytest on a dev box tries to collect the locally deployed apps under
  backend/dev-data/ and dies during collection. The line is now copy-pasteable
  for debugging a red shard locally.
- With no .test_durations file, pytest-split balances by test count, not time,
  and these tests range from 0.1s to 10s+. If one shard becomes the new
  critical path, run once with --store-durations and commit the file.

main also drops out of `push` here: release.yml gates itself on this workflow
via ci-gate, so listing main ran the whole suite a second time on every merge.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 01:18:26 -04:00
..