An open source design system that's fully customizable and agent ready
TypeScript
ci: the leg-count test fails only when the planner cannot fit the matrix, and the WebKit matrix has six legs (#10631)
Cindy Zhang9db6e3484f97
diff --git a/.github/scripts/playwright-legs.mjs b/.github/scripts/playwright-legs.mjsindex 162035be6b..b0d541f625 100644--- a/.github/scripts/playwright-legs.mjs+++ b/.github/scripts/playwright-legs.mjs@@ -63,6 +63,41 @@ export function planLegs(files, durations, legs) {}));}+/**+ * Why a suite's proofs do not fit its matrix, or null when they do: the leg+ * count the planner takes for `seconds` must be no more than `maxLegs`, and+ * every leg it plans, with its setup, within `maxSeconds` plus `slackSeconds`+ * (one spec cannot be split across legs). The message names the heaviest+ * specs, which are where the time goes.+ */+export function legsFitMessage({+ seconds,+ files,+ costs,+ setupSeconds,+ maxSeconds,+ maxLegs,+ slackSeconds = 60,+}) {+ const needed = Math.ceil(seconds / (maxSeconds - setupSeconds));+ const legs = legCount({seconds, setupSeconds, maxSeconds, maxLegs});+ const planned = planLegs(files, costs, legs);+ const longest = Math.max(0, ...planned.map(leg => leg.seconds));+ if (needed <= maxLegs && longest + setupSeconds <= maxSeconds + slackSeconds)+ return null;+ const heaviest = [...new Set(files)]+ .map(file => [file, costs[file] ?? 0])+ .sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1))+ .slice(0, 5)+ .map(([file, cost]) => `${file} (${Math.round(cost)} s)`)+ .join(', ');+ return (+ `${Math.round(seconds)} s of proofs need ${needed} legs of ${Math.round(maxSeconds - setupSeconds)} s; ` ++ `the matrix has ${maxLegs}, and its longest leg takes ${Math.round(longest + setupSeconds)} s with setup. ` ++ `Heaviest specs: ${heaviest}`+ );+}+/*** The seconds a suite's proofs take: each listed spec file a filter selects* (every listed spec with no filter), and each changed spec, at its recordeddiff --git a/.github/scripts/playwright-legs.test.mjs b/.github/scripts/playwright-legs.test.mjsindex b800d44c8b..89d903ea6d 100644--- a/.github/scripts/playwright-legs.test.mjs+++ b/.github/scripts/playwright-legs.test.mjs@@ -16,6 +16,7 @@ import {folderSpecs,isInteractionSpec,legCount,+ legsFitMessage,planLegs,recordLog,selectProofs,@@ -37,6 +38,37 @@ const durations = JSON.parse();const step = (job, name) => job.steps.find(each => each.name === name);+describe('legsFitMessage', () => {+ const limits = {setupSeconds: 90, maxSeconds: 600, maxLegs: 3};+ const costs = {'a.spec.ts': 500, 'b.spec.ts': 500, 'c.spec.ts': 480};++ it('fits when the proofs need the last leg the matrix has', () => {+ expect(+ legsFitMessage({seconds: 1480, files: Object.keys(costs), costs, ...limits}),+ ).toBeNull();+ });++ it('names the heaviest specs when the proofs need more legs than the matrix has', () => {+ const more = {...costs, 'd.spec.ts': 400};+ const message = legsFitMessage({+ seconds: 1880,+ files: Object.keys(more),+ costs: more,+ ...limits,+ });+ expect(message).toContain('need 4 legs');+ expect(message).toContain('the matrix has 3');+ expect(message).toContain('a.spec.ts (500 s), b.spec.ts (500 s), c.spec.ts (480 s)');+ });++ it('names the spec when one spec alone outlasts a leg', () => {+ const one = {'huge.spec.ts': 700};+ expect(+ legsFitMessage({seconds: 700, files: ['huge.spec.ts'], costs: one, ...limits}),+ ).toContain('huge.spec.ts (700 s)');+ });+});+describe('planLegs', () => {const times = {a: 120, b: 100, c: 80, d: 50, e: 40, f: 30, g: 20, h: 10};const files = Object.keys(times);@@ -290,7 +322,7 @@ describe('the interaction proof legs in ci.yml', () => {{id: 'pr-interaction-webkit',project: 'webkit',- legs: [1, 2, 3, 4, 5],+ legs: [1, 2, 3, 4, 5, 6],run: 'Run WebKit interaction proofs',plan: "Plan this leg's WebKit interaction proofs",evidence: 'interaction-evidence-webkit-${{ matrix.leg }}',@@ -872,34 +904,28 @@ describe('the interaction proof legs in ci.yml', () => {testsOf,perTest,});- // The matrix still has room: the count stays under its legs.- const needed = Math.ceil(- seconds / (limits.maxSeconds - limits.setupSeconds),- );+ // The planner fits the matrix: no more legs than it has, and no leg+ // over ten minutes (plus one spec's slack). It fails naming the+ // heaviest specs, not by a margin under the matrix.expect(- needed,- `${label}: ${Math.round(seconds)} s of proofs`,- ).toBeLessThan(lane.legs.length);- const legsNow = legCount({seconds, ...limits});- const planned = planLegs(- specs.filter(- file =>- filters.length === 0 ||- filters.some(each => file.includes(each)) ||- changed.includes(file),- ),- Object.fromEntries(- specs.map(file => [- file,- times[file] ?? fallback[file] ?? testsOf(file) * perTest,- ]),- ),- legsNow,- );- for (const leg of planned)- expect(leg.seconds + limits.setupSeconds, label).toBeLessThanOrEqual(- limits.maxSeconds + 60,- );+ legsFitMessage({+ seconds,+ files: specs.filter(+ file =>+ filters.length === 0 ||+ filters.some(each => file.includes(each)) ||+ changed.includes(file),+ ),+ costs: Object.fromEntries(+ specs.map(file => [+ file,+ times[file] ?? fallback[file] ?? testsOf(file) * perTest,+ ]),+ ),+ ...limits,+ }),+ label,+ ).toBeNull();}}});diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex b7165314ab..b81c68c421 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -2754,11 +2754,11 @@ jobs:# Frame evidence measures timing: four cores, one Playwright worker.# The leg count plans as many legs as keep each one's setup and proofs# within ten minutes, as the Chromium proofs' count does. The matrix is- # the ceiling; a leg with no share passes at once.+ # the ceiling, six legs as for Chromium; a leg with no share passes at once.strategy:fail-fast: falsematrix:- leg: [1, 2, 3, 4, 5]+ leg: [1, 2, 3, 4, 5, 6]runs-on: ubuntu-latesttimeout-minutes: 15# Playwright's own image for the version the lockfile resolves, with