An open source design system that's fully customizable and agent ready
TypeScript
ci: the WebKit interaction proofs run in one leg while they fit ten minutes (#10072)
Cindy Zhang4b69beb816e6
diff --git a/.github/scripts/ci-interaction-webkit.test.mjs b/.github/scripts/ci-interaction-webkit.test.mjsindex 978535946d..2157a32468 100644--- a/.github/scripts/ci-interaction-webkit.test.mjs+++ b/.github/scripts/ci-interaction-webkit.test.mjs@@ -96,16 +96,26 @@ describe('WebKit interaction proof routing', () => {const guards = new Set(["Require this pull request's Storybook build",'Skip the WebKit proofs outside their scope',+ 'Leave the proofs to the first leg',]);- for (const candidate of webkit.steps.slice(2)) {- if (guards.has(candidate.name)) continue;+ // Every step after the leg count also waits for this leg to have a share.+ const counted = webkit.steps.indexOf(+ step(webkit, "Count this run's WebKit legs"),+ );+ const share = "steps.legs.outputs.runs == 'true'";+ for (const [index, candidate] of webkit.steps.entries()) {+ if (index < 2 || guards.has(candidate.name)) continue;+ const gate = index <= counted ? applies : `${applies} && ${share}`;// A leg whose plan holds no spec file runs no proofs.expect(candidate.if, candidate.name ?? candidate.uses).toMatch(new RegExp(- `^(always\\(\\) && )?${applies.replace(/[.()|]/g, '\\$&')}( && steps\\.plan\\.outputs\\.files != '0')?$`,+ `^(always\\(\\) && )?${gate.replace(/[.()|]/g, '\\$&')}( && steps\\.plan\\.outputs\\.files != '0')?$`,),);}+ expect(step(webkit, 'Leave the proofs to the first leg').if).toBe(+ `${applies} && steps.legs.outputs.runs != 'true'`,+ );});it('runs the interaction config in WebKit against the exact PR head', () => {@@ -224,7 +234,10 @@ describe('WebKit interaction proof routing', () => {it('runs only the specs whose code its scope covers', () => {// Each leg plans its share from these paths and runs only that share.- const run = step(webkit, "Plan this leg's WebKit interaction proofs").run;+ const run = webkit.env.WEBKIT_SPEC_PATHS;+ expect(+ step(webkit, "Plan this leg's WebKit interaction proofs").run,+ ).toContain('"${SPEC_PATHS[@]}"');const targets = ['packages/core/src/gestures/','packages/core/src/motion/__tests__/animatedLayout.interaction',@@ -306,8 +319,8 @@ describe('WebKit interaction proof routing', () => {{mode: 0o755},);const script = step(webkit, "Plan this leg's WebKit interaction proofs")- .run.replaceAll('${{ matrix.leg }}', '1')- .replaceAll('${{ strategy.job-total }}', '2');+ .run.replaceAll('${{ steps.legs.outputs.leg }}', '1')+ .replaceAll('${{ steps.legs.outputs.count }}', '2');const out = execFileSync('bash', ['-e', '-c', script], {cwd: dir,encoding: 'utf8',@@ -316,6 +329,7 @@ describe('WebKit interaction proof routing', () => {PATH: `${bin}:${process.env.PATH}`,RUNNER_TEMP: dir,CHANGED_FILES: list,+ WEBKIT_SPEC_PATHS: webkit.env.WEBKIT_SPEC_PATHS,},});return out.trim().split('\n');diff --git a/.github/scripts/playwright-legs.mjs b/.github/scripts/playwright-legs.mjsindex 311c3decbc..a6ecc40785 100644--- a/.github/scripts/playwright-legs.mjs+++ b/.github/scripts/playwright-legs.mjs@@ -6,11 +6,14 @@* @description Splits the spec files of one Playwright suite into legs of* about equal running time, from the per-file times a CI run recorded* (spec:AST-030 FR13).- * @input `plan`: the suite's times key, its config and project, this leg and- * the leg count, and any Playwright path filters;- * `.github/playwright-leg-durations.json`. `record`: CI job logs of the list- * reporter.- * @output `plan`: this leg's spec files, one per line, for Playwright's+ * @input `legs`: the suite's times key, its path filters, the changed files,+ * a leg's setup time and time limit. `plan`: the suite's times key, its+ * config and project, this leg and the leg count, and any Playwright path+ * filters; `.github/playwright-leg-durations.json`. `record`: CI job logs+ * of the list reporter.+ * @output `legs`: `count=<legs>`, `runs=<true|false>` and the `leg=<i>` this+ * leg plans, for `$GITHUB_OUTPUT`.+ * `plan`: this leg's spec files, one per line, for Playwright's* `--test-list`, and `files=<count>` for `$GITHUB_OUTPUT`. `record`: the* durations file, rewritten for the suite.* @position The pr-interaction, pr-interaction-webkit and docsite-browser@@ -22,7 +25,11 @@ import fs from 'node:fs';import path from 'node:path';import {fileURLToPath} from 'node:url';-import {costOf, splitByDuration} from '../../scripts/lib/duration-split.mjs';+import {+ costOf,+ medianOf,+ splitByDuration,+} from '../../scripts/lib/duration-split.mjs';import {listedFiles} from './a11y-pr-contracts.mjs';// CI may run this file from the workflow's own commit, outside the checkout,@@ -50,6 +57,55 @@ export function planLegs(files, durations, legs) {}));}+/**+ * The seconds a suite's proofs take: each listed spec file a filter selects,+ * and each changed spec, at its recorded time. A spec with no time of its own+ * counts its time in `fallback` (another browser's), else the median.+ */+export function estimateSeconds(+ times,+ filters,+ {listed = [], changed = [], fallback = {}} = {},+) {+ const files = new Set(+ listed.filter(file => filters.some(filter => file.includes(filter))),+ );+ for (const file of changed) files.add(file);+ const median = medianOf(Object.values(times));+ let seconds = 0;+ for (const file of files) seconds += times[file] ?? fallback[file] ?? median;+ return seconds;+}++/**+ * The fewest legs, at most `maxLegs`, in which each leg's setup and share of+ * the proofs fits `maxSeconds`. One leg while the whole estimate fits.+ */+export function legCount({seconds, setupSeconds, maxSeconds, maxLegs}) {+ if (!Number.isFinite(seconds) || seconds < 0)+ throw new Error(`the proofs' estimate is not a time: ${seconds}`);+ if (!(maxSeconds > setupSeconds) || !(maxLegs >= 1))+ throw new Error(+ 'a leg needs more time than its setup, and one leg at least',+ );+ const needed = Math.ceil(seconds / (maxSeconds - setupSeconds));+ return Math.min(maxLegs, Math.max(1, needed));+}++/**+ * Whether a file is an interaction proof spec, as playwright.interaction+ * .config.ts matches them: any `*.interaction.browser.spec.ts`, and the+ * gesture system's own `*.browser.spec.ts` proofs.+ */+export function isInteractionSpec(file) {+ return (+ file.endsWith('.interaction.browser.spec.ts') ||+ /^packages\/core\/src\/gestures\/__tests__\/browser\/[^/]+\.browser\.spec\.ts$/.test(+ file,+ )+ );+}+// A suite with one unnamed project prints no `[project]`.const TEST_LINE =/^(\S+Z)\s+\S+\s+\d+\s+(?:\[([\w-]+)\] › )?([^:\s]+):\d+:\d+ › /;@@ -184,6 +240,64 @@ function plan(args) {);}+function legs(args) {+ const split = args.indexOf('--');+ const own = split === -1 ? args : args.slice(0, split);+ const filters = split === -1 ? [] : args.slice(split + 1);+ const key = option(own, '--key');+ const leg = Number(option(own, '--leg'));+ const limits = {+ setupSeconds: Number(option(own, '--setup-seconds')),+ maxSeconds: Number(option(own, '--max-seconds')),+ maxLegs: Number(option(own, '--max-legs')),+ };+ if (!key || !Number.isInteger(leg) || leg < 1 || filters.length === 0)+ throw new Error(+ 'usage: legs --key <times key> --leg <i> --listed <file> --setup-seconds <s> --max-seconds <s> --max-legs <n> [--fallback-key <times key>] [--durations <file>] [--changed <file>] -- <filters...>',+ );+ const specs = file =>+ fs.readFileSync(file, 'utf8').split('\n').filter(isInteractionSpec);+ const listedFile = option(own, '--listed');+ const listed =+ listedFile && fs.existsSync(listedFile) ? specs(listedFile) : [];+ if (listed.length === 0)+ throw new Error(`--listed names no ${key} spec files to count`);+ const changedFile = option(own, '--changed');+ // Each leg counts on its own. A leg without the changed files could count+ // fewer legs than the others and leave a share of the proofs to no leg, so+ // it plans itself as the only leg and runs every proof instead.+ if (+ own.includes('--changed') &&+ !(changedFile && fs.existsSync(changedFile))+ ) {+ console.log(+ `::warning title=Leg count without the changed files::The scope step could not list the changed files, so ${key} leg ${leg} runs every planned proof as a leg of its own.`,+ );+ if (process.env.GITHUB_OUTPUT)+ fs.appendFileSync(+ process.env.GITHUB_OUTPUT,+ 'count=1\nruns=true\nleg=1\n',+ );+ return;+ }+ const durations = readDurations(option(own, '--durations') ?? DURATIONS);+ const seconds = estimateSeconds(durations[key] ?? {}, filters, {+ listed,+ changed: changedFile ? specs(changedFile) : [],+ fallback: durations[option(own, '--fallback-key')] ?? {},+ });+ const count = legCount({seconds, ...limits});+ const runs = leg <= count;+ console.log(+ `${key}: about ${Math.round(seconds)} s of proofs and ${limits.setupSeconds} s of setup a leg, so ${count} leg${count === 1 ? '' : 's'} within ${limits.maxSeconds} s; leg ${leg} ${runs ? 'runs' : 'has no share'}`,+ );+ if (process.env.GITHUB_OUTPUT)+ fs.appendFileSync(+ process.env.GITHUB_OUTPUT,+ `count=${count}\nruns=${runs}\nleg=${leg}\n`,+ );+}+function record(args) {const key = option(args, '--key');const project = option(args, '--project');@@ -224,9 +338,10 @@ if () {const [command, ...args] = process.argv.slice(2);try {- if (command === 'plan') plan(args);+ if (command === 'legs') legs(args);+ else if (command === 'plan') plan(args);else if (command === 'record') record(args);- else throw new Error('usage: playwright-legs.mjs plan|record ...');+ else throw new Error('usage: playwright-legs.mjs legs|plan|record ...');} catch (error) {console.error(error.message);process.exitCode = 1;diff --git a/.github/scripts/playwright-legs.test.mjs b/.github/scripts/playwright-legs.test.mjsindex a00c35bab3..15bc4b8f5c 100644--- a/.github/scripts/playwright-legs.test.mjs+++ b/.github/scripts/playwright-legs.test.mjs@@ -2,13 +2,20 @@import {execFileSync, spawnSync} from 'node:child_process';import fs from 'node:fs';+import os from 'node:os';import path from 'node:path';import {fileURLToPath} from 'node:url';import {describe, expect, it} from 'vitest';import yaml from 'yaml';-import {planLegs, recordLog} from './playwright-legs.mjs';+import {+ estimateSeconds,+ isInteractionSpec,+ legCount,+ planLegs,+ recordLog,+} from './playwright-legs.mjs';const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)),@@ -75,6 +82,101 @@ describe('planLegs', () => {});});+describe('estimateSeconds and legCount', () => {+ const times = {+ 'internal/harness.spec.ts': 170,+ 'packages/gestures/a.spec.ts': 50,+ 'packages/List/row.spec.ts': 30,+ };++ const listed = Object.keys(times);++ it('adds the times of the listed files a filter selects and of each changed spec', () => {+ expect(+ estimateSeconds(times, ['internal/', 'packages/gestures/'], {listed}),+ ).toBe(220);+ // A changed spec already selected counts once.+ expect(+ estimateSeconds(times, ['internal/'], {+ listed,+ changed: ['internal/harness.spec.ts'],+ }),+ ).toBe(170);+ // A changed spec with no time of its own takes another browser's time,+ // then the median of this suite's times.+ expect(+ estimateSeconds(times, ['internal/'], {+ listed,+ changed: ['new.spec.ts'],+ fallback: {'new.spec.ts': 12},+ }),+ ).toBe(182);+ expect(+ estimateSeconds(times, ['internal/'], {+ listed,+ changed: ['other.spec.ts'],+ }),+ ).toBe(170 + 50);+ });++ it('counts a listed spec in the lane that has no recorded time yet', () => {+ expect(+ estimateSeconds(times, ['internal/'], {+ listed: [...listed, 'internal/pointer.spec.ts'],+ }),+ ).toBe(170 + 50);+ });++ it('plans one leg while setup and every proof fit the limit, and more past it', () => {+ const limits = {setupSeconds: 90, maxSeconds: 600, maxLegs: 2};+ expect(legCount({seconds: 0, ...limits})).toBe(1);+ expect(legCount({seconds: 510, ...limits})).toBe(1);+ expect(legCount({seconds: 511, ...limits})).toBe(2);+ // Never more legs than the matrix has.+ expect(legCount({seconds: 5000, ...limits})).toBe(2);+ expect(() =>+ legCount({seconds: 1, setupSeconds: 600, maxSeconds: 600, maxLegs: 2}),+ ).toThrow();+ // A broken estimate stops the leg rather than planning one leg.+ for (const seconds of [Number.NaN, Number.POSITIVE_INFINITY, -1])+ expect(() => legCount({seconds, ...limits})).toThrow(+ "the proofs' estimate is not a time",+ );+ });++ it('counts the spec files the interaction config runs, and no others', () => {+ const config = fs.readFileSync(+ path.join(root, 'playwright.interaction.config.ts'),+ 'utf8',+ );+ // The config's patterns, which isInteractionSpec follows.+ for (const pattern of [+ "'internal/interaction-harness/src/**/*.interaction.browser.spec.ts'",+ "'packages/*/src/**/*.interaction.browser.spec.ts'",+ "'packages/core/src/gestures/__tests__/browser/*.browser.spec.ts'",+ ])+ expect(config).toContain(pattern);+ expect(+ isInteractionSpec(+ 'packages/core/src/List/__tests__/ListRowPress.interaction.browser.spec.ts',+ ),+ ).toBe(true);+ expect(+ isInteractionSpec(+ 'packages/core/src/gestures/__tests__/browser/flick.browser.spec.ts',+ ),+ ).toBe(true);+ expect(+ isInteractionSpec(+ 'packages/core/src/List/__tests__/List.browser.spec.ts',+ ),+ ).toBe(false);+ expect(isInteractionSpec('packages/core/src/gestures/flick.ts')).toBe(+ false,+ );+ });+});+describe('the list reader and recordLog', () => {it('reads the list report with the reader the accessibility contracts use', () => {const source = fs.readFileSync(@@ -131,6 +233,9 @@ describe('the interaction proof legs in ci.yml', () => {run: 'Run interaction proofs',plan: "Plan this leg's interaction proofs",evidence: 'interaction-evidence-${{ matrix.leg }}',+ gate: "steps.scope.outputs.applies == 'true'",+ leg: '${{ matrix.leg }}',+ of: '${{ strategy.job-total }}',},{id: 'pr-interaction-webkit',@@ -139,6 +244,10 @@ describe('the interaction proof legs in ci.yml', () => {run: 'Run WebKit interaction proofs',plan: "Plan this leg's WebKit interaction proofs",evidence: 'interaction-evidence-webkit-${{ matrix.leg }}',+ // One leg runs every proof while they fit; see the leg count below.+ gate: "steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'",+ leg: '${{ steps.legs.outputs.leg }}',+ of: '${{ steps.legs.outputs.count }}',},];@@ -154,7 +263,7 @@ describe('the interaction proof legs in ci.yml', () => {);const plan = step(job, lane.plan);expect(plan.id).toBe('plan');- expect(plan.if).toBe("steps.scope.outputs.applies == 'true'");+ expect(plan.if).toBe(lane.gate);// A head cut before the legs has neither the planner nor the times,// so both come from the scope checkout: the workflow's own commit.const scope = job.steps[0];@@ -193,15 +302,11 @@ describe('the interaction proof legs in ci.yml', () => {'--durations "$RUNNER_TEMP/interaction-legs/.github/playwright-leg-durations.json"',);expect(plan.run).not.toMatch(/git (fetch|show)/);- expect(plan.run).toContain(- '--leg ${{ matrix.leg }} --of ${{ strategy.job-total }}',- );+ expect(plan.run).toContain(`--leg ${lane.leg} --of ${lane.of}`);expect(plan.run).toContain('--out "$RUNNER_TEMP/interaction-leg.txt"');const run = step(job, lane.run);expect(job.steps.indexOf(plan)).toBeLessThan(job.steps.indexOf(run));- expect(run.if).toBe(- "steps.scope.outputs.applies == 'true' && steps.plan.outputs.files != '0'",- );+ expect(run.if).toBe(`${lane.gate} && steps.plan.outputs.files != '0'`);expect(run.run).toContain('--test-list "$RUNNER_TEMP/interaction-leg.txt"',);@@ -216,6 +321,165 @@ describe('the interaction proof legs in ci.yml', () => {});}+ describe("the WebKit legs' count", () => {+ const job = ci.jobs['pr-interaction-webkit'];+ const count = step(job, "Count this run's WebKit legs");++ it('decides before any setup, from the workflow commit’s planner and times', () => {+ expect(count.id).toBe('legs');+ expect(count.if).toBe("steps.scope.outputs.applies == 'true'");+ const at = job.steps.indexOf(count);+ expect(at).toBeGreaterThan(+ job.steps.indexOf(+ step(job, "Keep the leg planner from the workflow's commit"),+ ),+ );+ expect(at).toBeLessThan(+ job.steps.indexOf(step(job, 'Check out the heavy-suite caps')),+ );+ expect(count.env.CHANGED_FILES).toBe(+ '${{ steps.scope.outputs.changed_files_path }}',+ );+ for (const part of [+ '--key interaction-webkit --fallback-key interaction-chromium',+ '--durations "$RUNNER_TEMP/interaction-legs/.github/playwright-leg-durations.json"',+ '--setup-seconds 90 --max-seconds 600',+ '--leg ${{ matrix.leg }} --max-legs ${{ strategy.job-total }}',+ // Every spec file in the merge commit, recorded or not.+ 'git -C .test-scope ls-tree -r --name-only HEAD > "$RUNNER_TEMP/interaction-legs/listed.txt"',+ '--listed "$RUNNER_TEMP/interaction-legs/listed.txt"',+ ])+ expect(count.run).toContain(part);+ });++ // Runs the count step with the real planner on these recorded times.+ function countFor(leg, webkitTimes, changed = [], unrecorded = []) {+ // The real path: the planner runs only when invoked as its own file.+ const dir = fs.realpathSync(+ fs.mkdtempSync(path.join(os.tmpdir(), 'webkit-legs-')),+ );+ try {+ const copy = path.join(dir, 'interaction-legs');+ fs.mkdirSync(path.join(copy, '.github/scripts'), {recursive: true});+ fs.mkdirSync(path.join(copy, 'scripts/lib'), {recursive: true});+ for (const file of [+ '.github/scripts/playwright-legs.mjs',+ '.github/scripts/a11y-pr-contracts.mjs',+ 'scripts/lib/duration-split.mjs',+ ])+ fs.copyFileSync(path.join(root, file), path.join(copy, file));+ fs.writeFileSync(+ path.join(copy, '.github/playwright-leg-durations.json'),+ JSON.stringify({+ 'interaction-webkit': webkitTimes,+ 'interaction-chromium': {},+ }),+ );+ // The scope checkout: a repository whose tree holds the spec files.+ const scope = path.join(dir, '.test-scope');+ for (const file of [...Object.keys(webkitTimes), ...unrecorded]) {+ fs.mkdirSync(path.join(scope, path.dirname(file)), {recursive: true});+ fs.writeFileSync(path.join(scope, file), '');+ }+ const git = args =>+ execFileSync('git', ['-C', scope, ...args], {stdio: 'ignore'});+ git(['init', '-q']);+ git(['add', '-A']);+ git([+ '-c',+ 'user.name=t',+ '-c',+ '[email protected]',+ 'commit',+ '-qm',+ 'scope',+ '--no-verify',+ ]);+ // A null list stands for a scope step that could not list the files.+ const list = changed == null ? '' : path.join(dir, 'changed.txt');+ if (list)+ fs.writeFileSync(list, changed.map(file => `${file}\n`).join(''));+ const output = path.join(dir, 'output.txt');+ execFileSync(+ 'bash',+ [+ '-e',+ '-c',+ count.run+ .replaceAll('${{ matrix.leg }}', String(leg))+ .replaceAll('${{ strategy.job-total }}', '2'),+ ],+ {+ cwd: dir,+ encoding: 'utf8',+ env: {+ ...process.env,+ RUNNER_TEMP: dir,+ CHANGED_FILES: list,+ GITHUB_OUTPUT: output,+ WEBKIT_SPEC_PATHS: job.env.WEBKIT_SPEC_PATHS,+ },+ },+ );+ return Object.fromEntries(+ fs+ .readFileSync(output, 'utf8')+ .trim()+ .split('\n')+ .map(line => line.split('=')),+ );+ } finally {+ fs.rmSync(dir, {recursive: true, force: true});+ }+ }++ it('gives the whole suite to the first leg at today’s recorded times', () => {+ const times = durations['interaction-webkit'];+ expect(countFor(1, times)).toEqual({count: '1', runs: 'true', leg: '1'});+ expect(countFor(2, times)).toEqual({count: '1', runs: 'false', leg: '2'});+ });++ it('adds the second leg once setup and the proofs pass ten minutes', () => {+ const times = {+ 'internal/interaction-harness/src/harness.interaction.browser.spec.ts': 400,+ 'packages/core/src/gestures/__tests__/browser/gestures.interaction.browser.spec.ts': 111,+ };+ expect(countFor(2, times)).toEqual({count: '2', runs: 'true', leg: '2'});+ // A changed spec counts too: here it tips one leg into two.+ const near = {+ 'internal/interaction-harness/src/harness.interaction.browser.spec.ts': 500,+ };+ expect(countFor(2, near)).toEqual({count: '1', runs: 'false', leg: '2'});+ // So does a planned spec with no recorded time: here the median, 500 s.+ expect(+ countFor(+ 2,+ near,+ [],+ [+ 'internal/interaction-harness/src/pointer.interaction.browser.spec.ts',+ ],+ ),+ ).toEqual({count: '2', runs: 'true', leg: '2'});+ expect(+ countFor(2, near, [+ 'packages/core/src/List/__tests__/ListRowPress.interaction.browser.spec.ts',+ 'packages/core/src/List/ListRow.tsx',+ ]),+ ).toEqual({count: '2', runs: 'true', leg: '2'});+ });++ it('runs every proof in a leg that has no changed-file list, as a leg of its own', () => {+ // Whatever the other leg counts, every proof then runs in some leg.+ for (const leg of [1, 2])+ expect(countFor(leg, durations['interaction-webkit'], null)).toEqual({+ count: '1',+ runs: 'true',+ leg: '1',+ });+ });+ });+it('a change to the planner, its modules or the recorded times runs both lanes', () => {for (const id of ['pr-interaction', 'pr-interaction-webkit']) {const scope = ci.jobs[id].steps.find(each => each.id === 'scope');@@ -231,24 +495,34 @@ describe('the interaction proof legs in ci.yml', () => {});it('the WebKit legs plan only the paths the WebKit lane covers', () => {- const plan = step(- ci.jobs['pr-interaction-webkit'],- "Plan this leg's WebKit interaction proofs",- ).run;- const filters = plan- .slice(plan.indexOf(' -- ') + 4)- .replaceAll('\\', '')- .trim()- .split(/\s+/);- expect(filters).toEqual([+ const job = ci.jobs['pr-interaction-webkit'];+ expect(job.env.WEBKIT_SPEC_PATHS.split(' ')).toEqual(['packages/core/src/gestures/','packages/core/src/motion/__tests__/animatedLayout.interaction','packages/core/src/motion/__tests__/animator.interaction','packages/core/src/hooks/__tests__/usePager.interaction','internal/interaction-harness/',- // Plus the interaction specs this pull request changes.- '"${CHANGED_SPECS[@]}"',]);+ // The leg count and the plan read the same paths; the plan adds the+ // interaction specs this pull request changes.+ for (const name of [+ "Count this run's WebKit legs",+ "Plan this leg's WebKit interaction proofs",+ ]) {+ const {run} = step(job, name);+ expect(run, name).toContain(+ 'read -ra SPEC_PATHS <<< "$WEBKIT_SPEC_PATHS"',+ );+ expect(run, name).toContain('"${SPEC_PATHS[@]}"');+ }+ const plan = step(job, "Plan this leg's WebKit interaction proofs").run;+ expect(+ plan+ .slice(plan.indexOf(' -- ') + 4)+ .replaceAll('\\', '')+ .trim()+ .split(/\s+/),+ ).toEqual(['"${SPEC_PATHS[@]}"', '"${CHANGED_SPECS[@]}"']);});it("the test join reads each lane's whole result, so a failed, cancelled or skipped leg fails it", () => {diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 774c955dc3..1d7fd44008 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -2646,8 +2646,9 @@ jobs:needs: [room, admission, heavy-ci, build-storybook]if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.draft && (github.event.pull_request.head.repo.full_name == github.repository || contains(github.event.pull_request.labels.*.name, 'ci:run'))) && (!cancelled() && needs.heavy-ci.outputs.deferred != 'true' && (github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.room.outputs.full != 'true' && needs.admission.outputs.full != 'true')) }}# Frame evidence measures timing: four cores, one Playwright worker.- # Two legs share the spec files by their recorded times, as the Chromium- # proofs' two do; the harness spec alone fills one.+ # One leg runs every spec while the planner's estimate fits; past that two+ # legs share the spec files by their recorded times, as the Chromium+ # proofs' two do.strategy:fail-fast: falsematrix:@@ -2666,6 +2667,15 @@ jobs:defaults:run:shell: bash+ env:+ # The specs the WebKit legs run, besides each interaction spec the pull+ # request changes.+ WEBKIT_SPEC_PATHS: >-+ packages/core/src/gestures/+ packages/core/src/motion/__tests__/animatedLayout.interaction+ packages/core/src/motion/__tests__/animator.interaction+ packages/core/src/hooks/__tests__/usePager.interaction+ internal/interaction-harness/permissions:# The heavy-suite caps read the author's pull requests and runs.actions: read@@ -2723,11 +2733,39 @@ jobs:cp .test-scope/.github/scripts/lane-environment.mjs "$RUNNER_TEMP/interaction-legs/.github/scripts/"cp .test-scope/.github/lane-environments.json "$RUNNER_TEMP/interaction-legs/.github/"+ # One leg runs every proof while its setup and the recorded times fit+ # ten minutes, which leaves a third of the job's limit for a slow+ # runner. Past that the planner adds the second leg, so a growing suite+ # does not reach the limit. Each leg decides the same way, before its+ # own setup, from the workflow's times and the changed files. The spec+ # files come from the merge commit's tree, which the scope checkout+ # fetched whole, so a spec with no recorded time still counts.+ - name: Count this run's WebKit legs+ id: legs+ if: steps.scope.outputs.applies == 'true'+ env:+ CHANGED_FILES: ${{ steps.scope.outputs.changed_files_path }}+ run: |+ read -ra SPEC_PATHS <<< "$WEBKIT_SPEC_PATHS"+ git -C .test-scope ls-tree -r --name-only HEAD > "$RUNNER_TEMP/interaction-legs/listed.txt"+ node "$RUNNER_TEMP/interaction-legs/.github/scripts/playwright-legs.mjs" legs \+ --listed "$RUNNER_TEMP/interaction-legs/listed.txt" \+ --key interaction-webkit --fallback-key interaction-chromium \+ --durations "$RUNNER_TEMP/interaction-legs/.github/playwright-leg-durations.json" \+ --changed "${CHANGED_FILES:-}" \+ --setup-seconds 90 --max-seconds 600 \+ --leg ${{ matrix.leg }} --max-legs ${{ strategy.job-total }} \+ -- "${SPEC_PATHS[@]}"++ - name: Leave the proofs to the first leg+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs != 'true'+ run: echo "One leg holds this run's WebKit proofs (${{ steps.legs.outputs.count }} leg planned), so this leg runs none."+# The caps step comes from the merge commit, not the pull request's# head: a head that predates the step does not have it. The head# checkout below replaces this directory.- name: Check out the heavy-suite caps- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'uses: actions/checkout@v7with:path: .heavy-caps@@ -2735,16 +2773,16 @@ jobs:persist-credentials: false- name: Per-author heavy-suite caps- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'uses: ./.heavy-caps/.github/actions/heavy-caps# The daily heavy-run cap counts this step (spec:AST-030 FR16).- name: Heavy suite runs- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'run: 'true'- name: Checkout- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'uses: actions/checkout@v7with:ref: ${{ github.event.pull_request.head.sha }}@@ -2752,11 +2790,11 @@ jobs:# The container runs as root over a workspace the runner owns, and git# refuses a repository another user owns unless it is marked safe.- name: Trust the checkout in the container- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'run: git config --global --add safe.directory "$GITHUB_WORKSPACE"- name: Verify evidence checkout- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'env:EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }}run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD_SHA"@@ -2764,20 +2802,20 @@ jobs:# The head's specs run in this lane's environment, which comes from the# merge commit. A head older than that environment stops here.- name: Require this lane's environment in the branch- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'run: >-node "$RUNNER_TEMP/interaction-legs/.github/scripts/lane-environment.mjs" check --lane interaction-webkit--workflow "$RUNNER_TEMP/interaction-legs/.github/lane-environments.json"--head .github/lane-environments.json- name: Setup Node and pnpm- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'uses: ./.github/actions/setupwith:install: 'false'- name: Download Storybook artifact- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'uses: actions/download-artifact@v8with:name: storybook-${{ needs.build-storybook.outputs.short_hash }}@@ -2787,7 +2825,7 @@ jobs:# libraries; `install` finds them in place and downloads nothing. A spec# that decodes a WebKit recording does so in the headless shell.- name: Install Playwright WebKit- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'run: pnpm install --frozen-lockfile && npx playwright install webkit chromium-headless-shell# This leg's share of the WebKit spec files, from the paths the lane@@ -2796,10 +2834,11 @@ jobs:# pull request changes runs here too, wherever it lives.- name: Plan this leg's WebKit interaction proofsid: plan- if: steps.scope.outputs.applies == 'true'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'env:CHANGED_FILES: ${{ steps.scope.outputs.changed_files_path }}run: |+ read -ra SPEC_PATHS <<< "$WEBKIT_SPEC_PATHS"CHANGED_SPECS=()if [ -n "${CHANGED_FILES:-}" ] && [ -s "$CHANGED_FILES" ]; thenwhile IFS= read -r file; do@@ -2812,14 +2851,10 @@ jobs:finode "$RUNNER_TEMP/interaction-legs/.github/scripts/playwright-legs.mjs" plan \--key interaction-webkit --config playwright.interaction.config.ts --project webkit \- --leg ${{ matrix.leg }} --of ${{ strategy.job-total }} \+ --leg ${{ steps.legs.outputs.leg }} --of ${{ steps.legs.outputs.count }} \--durations "$RUNNER_TEMP/interaction-legs/.github/playwright-leg-durations.json" \--out "$RUNNER_TEMP/interaction-leg.txt" -- \- packages/core/src/gestures/ \- packages/core/src/motion/__tests__/animatedLayout.interaction \- packages/core/src/motion/__tests__/animator.interaction \- packages/core/src/hooks/__tests__/usePager.interaction \- internal/interaction-harness/ \+ "${SPEC_PATHS[@]}" \"${CHANGED_SPECS[@]}"# WebKit renders through Mesa's llvmpipe, which sizes its thread pool@@ -2829,7 +2864,7 @@ jobs:# set (the job's share, rounded up); without a quota the count stays# nproc, llvmpipe's own default.- name: Run WebKit interaction proofs- if: steps.scope.outputs.applies == 'true' && steps.plan.outputs.files != '0'+ if: steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true' && steps.plan.outputs.files != '0'run: |LP_NUM_THREADS="$(nproc)"if [ -r /sys/fs/cgroup/cpu.max ]; then@@ -2852,7 +2887,7 @@ jobs:--output interaction-proof-output-webkit- name: Upload WebKit interaction evidence- if: always() && steps.scope.outputs.applies == 'true'+ if: always() && steps.scope.outputs.applies == 'true' && steps.legs.outputs.runs == 'true'uses: actions/upload-artifact@v7with:name: interaction-evidence-webkit-${{ matrix.leg }}diff --git a/scripts/lib/duration-split.test.mjs b/scripts/lib/duration-split.test.mjsindex e5dcd47c23..52f05ac248 100644--- a/scripts/lib/duration-split.test.mjs+++ b/scripts/lib/duration-split.test.mjs@@ -70,7 +70,7 @@ describe('splitting test files by recorded time', () => {/import \{medianOf\} from '\.\.\/\.\.\/scripts\/lib\/duration-split\.mjs'/,);expect(read('.github/scripts/playwright-legs.mjs')).toMatch(- /import \{costOf, splitByDuration\} from '\.\.\/\.\.\/scripts\/lib\/duration-split\.mjs'/,+ /import \{[^}]*costOf[^}]*splitByDuration[^}]*\} from '\.\.\/\.\.\/scripts\/lib\/duration-split\.mjs'/,);for (const file of ['scripts/vitest-shard-sequencer.mjs',