e2e/CI: dual-engine suites, per-engine screenshots, SwiftShader retired, prod web suite, CI-coverage gate
Squash of experiment/ff-big-modules vs main.
Big-module routing removed: native-EH shrank kicad_editor below
SpiderMonkey's x86-64 code budget (runs 29355049705/29356152413 green on
stock Firefox), so BIG_MODULE_SPECS routing and the baseline-only-JIT
crutch are gone — kicad-firefox and kicad-chromium both run the full
suite, with the module compiled the way real users' browsers compile it.
Per-engine screenshots end to end: stableShot/shotPath write
test-results/<engine>/<name>.png; baselines move to
baseline-screenshots/{chromium,firefox}/ and the whole tools/screenshots
pipeline (compare/promote/manifest/spec-map/changelog/Discord) keys on
<engine>/<name>. Previously Firefox and Chromium renders of one spec
overwrote each other and Firefox renders were never actually gated.
Seeded from CI run 29421380806 (92 new firefox baselines, +24 chromium
web-suite shots); manifest generated from the baseline tree.
One merged playwright.config.ts (kicad/asyncify/coroutine/perf as
projects); ~25 dead npm scripts dropped. The web suite is gated in CI for
the first time ever (4 rotted specs fixed, 5 broken lib-bridge specs
triaged as fixme in docs/features/web-e2e-rot/); cheap lint step after
npm ci; last 26 blind-sleep violations fixed.
SwiftShader retired: CI Chromium renders WebGL on ANGLE → Mesa llvmpipe
(--use-gl=angle --use-angle=gl --ignore-gpu-blocklist; the blocklist flag
is mandatory — llvmpipe is blocklisted and WebGL is silently unavailable
without it) in BOTH configs. Under WORKERS=4 congestion SwiftShader
transiently failed the first post-board-load draw and the recovery
cascade ended in a silent permanent Cairo fallback — that engine flip was
the "~1.2% changedRatio both directions" occ-export baseline flake.
Validated 160/160 across two 80-repeat rigs; full analysis in
docs/features/wx-parity-bugs/occ-export-context-eviction.md. Chromium
baselines shift slightly on llvmpipe — promote once from the first green
run. Deflakes the new coverage exposed: presence baselines settle before
capture; presence fixtures declare current file formats; perf gets its
own outputDir so CI evidence survives; occ-export settles the board paint
before the export dialog; menu-item waits (waitForRenderedByLabel before
clickMenuItem) in 4 specs + the TESTING.md rule.
Web suite runs the PROD build, in parallel: webServer becomes backend
`start` + the standalone's e2e:preview (build-preview.mjs: link-wasm →
stash the public/wasm symlink aside during vite build, build-demo.mjs's
move — then vite preview as the persistent server). The wasm middleware
serves /wasm/* in preview and emits COOP/COEP/CORP itself (a pthread
worker script's own response must carry COEP or Chrome kills it with
ERR_BLOCKED_BY_RESPONSE). VITE_* flags bake at build time;
VITE_ALLOW_USER_OVERRIDE joins turbo globalEnv. fullyParallel + default
workers: 5.2m → 1.4m. Determinism fixes the parallel run exposed:
shared-page specs become serial groups; locks.spec grabs alice's exact
item via the new kicadCollabTestSelectByUuid hook (cross-tab "first
footprint" order is not a ysync invariant); quit specs poll page.url()
(quit supersedes its own navigation — NS_BINDING_ABORTED on Firefox).
Suite: 51 passed / 12 skipped / 0 failed in 1.6m.
CI-coverage gate (lint:ci-coverage): every tests/**/*.spec.ts must be
reachable from the npm scripts the workflows invoke — scraped from
.github/workflows/, resolved through package.json, coverage asked from
playwright --list itself. Rules: uncovered-spec + orphan-project (with a
documented LOCAL_ONLY_PROJECTS allowlist). Gating next to
lint:determinism; 138 spec files / 13 projects accounted for.
Product fixes kept from the investigations (reachable on real GPUs too):
wx 7799fd1be5 — paint flags clear before dispatch + Invalidate always
propagates; kicad 3dcfea5e45 — SwiftShader pass-boundary flush +
per-instance font texture + first-frame GL-error drain (GAL recovery
recovers instead of falling back to Cairo) + the user-facing eeschema
switch navigates again under __EMSCRIPTEN__ (project-sync's
FaceRegistered gate had rerouted it into the hidden sync player; caught
by the newly-gated web suite).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018eUxiPApHgGiu9NFyQfhAq
This commit is contained in:
parent
8a20f69c5e
commit
63ed1f3c1f
556 changed files with 2470 additions and 1389 deletions
|
|
@ -3,6 +3,22 @@ import { execSync } from 'child_process';
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
// THE merged Playwright config for every suite that runs against the static
|
||||
// `apps` server: the wx widget suite (e2e/), the KiCad editor suite (kicad/),
|
||||
// the asyncify race harness (asyncify/) and the coroutine harness
|
||||
// (e2e/coroutine*). One config = one invocation = one webServer, one port file
|
||||
// and ONE start-of-run outputDir wipe — which is what retired the old
|
||||
// per-suite pw-artifacts/{wx,asyncify,kicad} redirect dance (each sequential
|
||||
// CI invocation used to wipe the previous suite's artifacts).
|
||||
//
|
||||
// The web-app suite (web/) stays in playwright-web.config.ts: it runs against
|
||||
// the React editor + backend stack (`pnpm --dir ../web dev`), not this server.
|
||||
//
|
||||
// CI runs: npm run test:e2e (wx-chromium, kicad-firefox, kicad-chromium,
|
||||
// asyncify-firefox, coroutine-firefox)
|
||||
// npm run test:perf (perf project, non-gating, separate invocation)
|
||||
// Local-only projects (system Chrome / WebKit) are listed at the bottom.
|
||||
|
||||
const PORT_FILE = path.join(__dirname, '.test-port');
|
||||
|
||||
// Resolve the static-server port for this run.
|
||||
|
|
@ -13,19 +29,11 @@ const PORT_FILE = path.join(__dirname, '.test-port');
|
|||
// *recreates* a worker mid-run after a test times out or crashes — and that new
|
||||
// worker re-imports this config.
|
||||
//
|
||||
// The previous heuristic ("reuse .test-port if it's <60s old, else pick a new
|
||||
// free port") broke exactly there: once a run passed the 60s mark, a recreated
|
||||
// worker treated the file as stale, picked a DIFFERENT free port, and every
|
||||
// subsequent page.goto hit a dead port (net::ERR_CONNECTION_REFUSED) because the
|
||||
// webServer was still listening on the original port. A single failing test
|
||||
// thus cascaded into ~all later tests failing.
|
||||
//
|
||||
// Fix (same as playwright-kicad.config.ts): drop the time window entirely. The
|
||||
// main runner always picks a fresh port and writes it; workers always reuse
|
||||
// whatever the main runner wrote. The main runner is the only process whose
|
||||
// argv carries the `test` command (workers are forked with an empty argv), and
|
||||
// it imports this config — and so writes the file — before any worker is
|
||||
// spawned.
|
||||
// The main runner is the only process whose argv carries the `test` command
|
||||
// (workers are forked with an empty argv); it always picks a fresh port and
|
||||
// writes the file before any worker spawns, and workers always reuse it — no
|
||||
// freshness window, so a recreated worker can never rotate to a dead port
|
||||
// (the old ERR_CONNECTION_REFUSED cascade).
|
||||
function resolvePort(): number {
|
||||
const isMainRunner = process.argv.slice(2).includes('test');
|
||||
if (!isMainRunner) {
|
||||
|
|
@ -45,9 +53,7 @@ function resolvePort(): number {
|
|||
return port;
|
||||
}
|
||||
|
||||
// Find a free port dynamically using a shell command
|
||||
function findFreePort(): number {
|
||||
// Use Python to find a free port (works on macOS and Linux)
|
||||
try {
|
||||
const result = execSync(
|
||||
'python3 -c "import socket; s=socket.socket(); s.bind((\'\',0)); print(s.getsockname()[1]); s.close()"',
|
||||
|
|
@ -57,7 +63,6 @@ function findFreePort(): number {
|
|||
);
|
||||
return parseInt(result.trim());
|
||||
} catch {
|
||||
// Fallback to default port range
|
||||
return 9000 + Math.floor(Math.random() * 1000);
|
||||
}
|
||||
}
|
||||
|
|
@ -66,50 +71,212 @@ const port = resolvePort();
|
|||
|
||||
const appsDir = 'apps';
|
||||
|
||||
// Runtime-perf specs run ONLY on the Chromium 'perf' project: they need CDP
|
||||
// CPU throttling (Chromium-only). Excluded from the kicad projects so they
|
||||
// don't double-run there.
|
||||
const PERF_SPECS = ['**/*-perf.spec.ts'];
|
||||
|
||||
// Bundled Chromium on GPU-less CI: use ANGLE over desktop GL (Mesa llvmpipe
|
||||
// via the Xvfb display CI already provides — the whole e2e step runs under
|
||||
// `xvfb-run -a`) instead of SwiftShader. SwiftShader under multi-worker
|
||||
// contention transiently fails WebGL calls ("Requested render buffer size is
|
||||
// not supported", LRU context evictions at 3 live contexts, cross-context
|
||||
// object errors), which stochastically drove KiCad's GAL error-recovery and
|
||||
// flipped the occ-export screenshots between runs. llvmpipe — the same
|
||||
// software-GL stack the Firefox projects run on — never exhibited any of it.
|
||||
// Flags tested useless against the SwiftShader eviction before the switch:
|
||||
// --max-active-webgl-contexts=64, --force-gpu-mem-available-mb,
|
||||
// --disable-low-end-device-mode, --disable-gpu-driver-bug-workarounds.
|
||||
// See docs/features/wx-parity-bugs/occ-export-context-eviction.md.
|
||||
const CHROMIUM_CI_ARGS = process.env.CI
|
||||
? {
|
||||
launchOptions: { args: [
|
||||
'--use-gl=angle',
|
||||
'--use-angle=gl',
|
||||
// llvmpipe is on Chromium's software-GL blocklist (the analog of the
|
||||
// Firefox projects' webgl.force-enabled pref) — without this, WebGL
|
||||
// is simply unavailable and the app falls back to Cairo rendering.
|
||||
'--ignore-gpu-blocklist',
|
||||
] },
|
||||
}
|
||||
: {};
|
||||
|
||||
// CI-only Firefox prefs: GPU-less CI VMs can't create a headless GL context
|
||||
// (FEATURE_FAILURE_WEBGL_EXHAUSTED_DRIVERS) — run headed under Xvfb, where
|
||||
// GLX + Mesa llvmpipe provides software WebGL, and bypass the no-GPU
|
||||
// blocklist so the GAL canvas gets a context. CI invokes the suite via
|
||||
// `xvfb-run`.
|
||||
const FIREFOX_CI_OPTS = process.env.CI
|
||||
? {
|
||||
headless: false,
|
||||
launchOptions: {
|
||||
firefoxUserPrefs: {
|
||||
'webgl.force-enabled': true,
|
||||
},
|
||||
},
|
||||
}
|
||||
: {};
|
||||
|
||||
export default defineConfig({
|
||||
globalSetup: './global-setup.ts',
|
||||
testDir: './e2e',
|
||||
// In CI, redirect Playwright's start-of-run outputDir cleanup to a throwaway dir so it
|
||||
// never wipes test-results/ — the committed-baseline screenshots (page.screenshot to
|
||||
// 'test-results/…') must survive across the sequential wx/asyncify/kicad/perf runs for the
|
||||
// screenshot compare. Local dev keeps the default (test-results cleaned each single run).
|
||||
outputDir: process.env.CI ? 'pw-artifacts/wx' : 'test-results',
|
||||
// Every suite writes its gate screenshots to test-results/<engine>/ via
|
||||
// stableShot/shotPath — NOT into outputDir. On CI, outputDir points at a
|
||||
// throwaway dir so Playwright's start-of-run cleanup never touches the
|
||||
// accumulated screenshots (the perf run is a separate later invocation).
|
||||
outputDir: process.env.CI ? 'pw-artifacts/e2e' : 'test-results',
|
||||
fullyParallel: true,
|
||||
forbidOnly: !!process.env.CI,
|
||||
// retries:0 — the suite is deterministic (no blind sleeps, no "if element exists"
|
||||
// branches; screenshots are captured via stableShot for the offline gate, not asserted
|
||||
// inline), so a failure is a real failure, not flake to paper over with a retry.
|
||||
// retries:0 — the suites are deterministic (no blind sleeps or "if element
|
||||
// exists" branches; screenshots go through stableShot for the offline gate,
|
||||
// not asserted inline), so a failure is a real failure rather than flake to
|
||||
// mask with a retry.
|
||||
retries: 0,
|
||||
// Run parallel workers on CI too (Playwright default ≈ 50% of cores), same as
|
||||
// local — the serial CI run was the dominant wall-clock cost. Cap (e.g. '50%'
|
||||
// or a fixed count) if contention OOMs/flakes; retries:2 covers transient.
|
||||
// Parallel workers on CI too (Playwright default ≈ 50% of cores) — the
|
||||
// serial CI run was the dominant wall-clock cost.
|
||||
workers: undefined,
|
||||
reporter: 'html',
|
||||
timeout: 60000, // WASM can be slow to load
|
||||
timeout: 60000, // wx-suite default; the heavier projects override below
|
||||
|
||||
// No expect.toHaveScreenshot block: screenshots are captured via stableShot() (render-settle +
|
||||
// raw PNG to test-results/) and compared OFFLINE by tools/screenshots against tests/baseline-
|
||||
// screenshots on CI's deterministic Linux render — Playwright does no inline pixel comparison.
|
||||
// No expect.toHaveScreenshot: screenshots are captured via stableShot()
|
||||
// (render-settle + raw PNG to test-results/<engine>/) and compared OFFLINE
|
||||
// by tools/screenshots against tests/baseline-screenshots/<engine>/ on CI's
|
||||
// deterministic Linux render.
|
||||
|
||||
use: {
|
||||
baseURL: `http://localhost:${port}`,
|
||||
trace: 'on-first-retry',
|
||||
// Grant clipboard and font permissions for tests
|
||||
permissions: ['clipboard-read', 'clipboard-write', 'local-fonts'],
|
||||
trace: 'retain-on-failure',
|
||||
screenshot: 'only-on-failure',
|
||||
},
|
||||
|
||||
projects: [
|
||||
// ── CI projects (npm run test:e2e) ──────────────────────────────────
|
||||
{
|
||||
name: 'chromium',
|
||||
// The wx widget/test-app suite. Chromium-only by design (the wx PORT is
|
||||
// exercised cross-engine by the kicad + coroutine projects).
|
||||
name: 'wx-chromium',
|
||||
testDir: './e2e',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
// CI runners have no GPU and several wx specs use WebGL
|
||||
// (gal-webgl.spec.ts etc.): newer headless Chromium refuses software
|
||||
// WebGL without --enable-unsafe-swiftshader. CI-gated so local runs
|
||||
// keep stock behavior (same pattern as playwright-kicad.config.ts).
|
||||
...(process.env.CI ? {
|
||||
launchOptions: { args: ['--enable-unsafe-swiftshader'] },
|
||||
} : {}),
|
||||
permissions: ['clipboard-read', 'clipboard-write', 'local-fonts'],
|
||||
...CHROMIUM_CI_ARGS,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'kicad-firefox',
|
||||
testDir: './kicad',
|
||||
testIgnore: PERF_SPECS,
|
||||
timeout: 180000, // KiCad WASM needs more time to load
|
||||
use: {
|
||||
...devices['Desktop Firefox'],
|
||||
viewport: { width: 1280, height: 720 },
|
||||
...FIREFOX_CI_OPTS,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'kicad-chromium',
|
||||
testDir: './kicad',
|
||||
testIgnore: PERF_SPECS,
|
||||
timeout: 180000,
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
viewport: { width: 1280, height: 720 },
|
||||
...CHROMIUM_CI_ARGS,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Asyncify race-condition red-green harness. One heavy WASM app at a
|
||||
// time within the (single) spec file.
|
||||
name: 'asyncify-firefox',
|
||||
testDir: './asyncify',
|
||||
testMatch: /asyncify-races.*\.spec\.ts$/,
|
||||
fullyParallel: false,
|
||||
timeout: 120000,
|
||||
use: {
|
||||
...devices['Desktop Firefox'],
|
||||
viewport: { width: 1280, height: 720 },
|
||||
...FIREFOX_CI_OPTS,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Coroutine harness on real Firefox — the wx-chromium project already
|
||||
// covers these specs on bundled Chromium; this is the cross-engine leg.
|
||||
name: 'coroutine-firefox',
|
||||
testDir: './e2e',
|
||||
testMatch: /coroutine.*\.spec\.ts$/,
|
||||
fullyParallel: false,
|
||||
timeout: 120000,
|
||||
use: {
|
||||
...devices['Desktop Firefox'],
|
||||
viewport: { width: 1280, height: 720 },
|
||||
...FIREFOX_CI_OPTS,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Runtime-perf specs: bundled Chromium for CDP CPU throttling. Run as a
|
||||
// SEPARATE, non-gating invocation (npm run test:perf) — hence its own CI
|
||||
// outputDir so its start-of-run wipe can't delete the e2e run's traces.
|
||||
name: 'perf',
|
||||
testDir: './kicad',
|
||||
testMatch: PERF_SPECS,
|
||||
timeout: 180000,
|
||||
...(process.env.CI ? { outputDir: 'pw-artifacts/perf' } : {}),
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
viewport: { width: 1280, height: 720 },
|
||||
...CHROMIUM_CI_ARGS,
|
||||
},
|
||||
},
|
||||
|
||||
// ── local-only projects (system Chrome / WebKit; CI installs neither) ─
|
||||
{
|
||||
// System Chrome (real GPU/V8) for headed KiCad debugging:
|
||||
// npx playwright test --project=kicad-chrome --headed kicad/pcbnew.spec.ts
|
||||
name: 'kicad-chrome',
|
||||
testDir: './kicad',
|
||||
testIgnore: PERF_SPECS,
|
||||
timeout: 180000,
|
||||
use: {
|
||||
channel: 'chrome',
|
||||
viewport: { width: 1280, height: 720 },
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'asyncify-chrome',
|
||||
testDir: './asyncify',
|
||||
testMatch: /asyncify-races.*\.spec\.ts$/,
|
||||
fullyParallel: false,
|
||||
timeout: 120000,
|
||||
use: {
|
||||
channel: 'chrome',
|
||||
viewport: { width: 1280, height: 720 },
|
||||
permissions: ['clipboard-read', 'clipboard-write'],
|
||||
},
|
||||
},
|
||||
{
|
||||
// WebKit (Safari's engine) — project policy: every asyncify spec must be
|
||||
// green in all three engines. Run via npm run test:asyncify:safari.
|
||||
name: 'asyncify-webkit',
|
||||
testDir: './asyncify',
|
||||
testMatch: /asyncify-races.*\.spec\.ts$/,
|
||||
fullyParallel: false,
|
||||
timeout: 120000,
|
||||
use: {
|
||||
...devices['Desktop Safari'],
|
||||
viewport: { width: 1280, height: 720 },
|
||||
},
|
||||
},
|
||||
{
|
||||
// Coroutine harness on system Chrome (real V8/GPU — where the KiCad
|
||||
// coroutine crash historically manifested). Must be --headed on ARM Mac.
|
||||
name: 'coroutine-chrome',
|
||||
testDir: './e2e',
|
||||
testMatch: /coroutine.*\.spec\.ts$/,
|
||||
fullyParallel: false,
|
||||
timeout: 120000,
|
||||
use: {
|
||||
channel: 'chrome',
|
||||
viewport: { width: 1280, height: 720 },
|
||||
permissions: ['clipboard-read', 'clipboard-write', 'local-fonts'],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue