feat(ci): duration-balanced E2E shards via LPT bin-packing (WS4.1) (#7090)

Playwright --shard distributes by count (per file with fullyParallel:false),
blind to duration — measured skew on the 9-shard matrix: 24m47s worst vs 1m47s
best (14x), putting E2E on the CI critical path (~25min of the 33min gate).

- scripts/quality/balance-e2e-shards.mjs: LPT greedy (heaviest first into the
  lightest shard) over config/quality/e2e-timings.json; deterministic
  (weight desc, filename tiebreak); new specs get the median weight; the CLI
  self-verifies the shard union equals the discovered spec list and exits
  non-zero on ANY inconsistency (missing timings, lost spec) so the CI step
  falls back to plain --shard — never fewer specs than before.
- config/quality/e2e-timings.json: relative weights seeded from spec LOC
  (proxy); replace with real per-file durations from a full run when convenient
  (documented in _meta). LOC-seeded packing already lands at 742-761 per shard
  (1.03x skew) vs the alphabetical round-robin that produced 14x.
- ci.yml test-e2e: balanced list per shard with logged assignment + fallback.
TDD: 5 unit tests (LPT invariants, determinism, completeness, median fallback,
seed-vs-specs drift guard).
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-07-14 07:07:27 -03:00
committed by GitHub
parent 413e8015f1
commit 4505e67c04
5 changed files with 231 additions and 1 deletions

View File

@@ -1000,7 +1000,23 @@ jobs:
- name: Extract Next.js build artifact
run: |
tar -xzf /tmp/e2e-build.tar.gz
- run: npx playwright test tests/e2e/*.spec.ts --shard=${{ matrix.shard }}/9
# WS4.1: duration-balanced shards (LPT over config/quality/e2e-timings.json).
# Measured skew of plain --shard was 14× (24m47s vs 1m47s) — E2E was the CI
# critical path. The balancer self-verifies completeness and exits non-zero on
# any inconsistency, falling back to plain --shard (never fewer specs).
- name: Run E2E tests (duration-balanced shard)
env:
SHARD: ${{ matrix.shard }}
run: |
if FILES=$(node scripts/quality/balance-e2e-shards.mjs "$SHARD" 9); then
if [ -z "$FILES" ]; then echo "[e2e-balance] shard $SHARD has no files"; exit 0; fi
echo "[e2e-balance] shard $SHARD runs:"; echo "$FILES"
# shellcheck disable=SC2086 — FILES is our own newline-separated path list
npx playwright test $(echo "$FILES" | tr '\n' ' ')
else
echo "[e2e-balance] balancer unavailable — plain --shard fallback"
npx playwright test tests/e2e/*.spec.ts --shard="$SHARD"/9
fi
test-integration:
name: Integration Tests (${{ matrix.shard }}/2)