Skip to content

Commit 9db6e34

Browse files
authored
ci: the leg-count test fails only when the planner cannot fit the matrix, and the WebKit matrix has six legs (#10631)
ci: the leg-count test fails only when the planner cannot fit the matrix, and the WebKit matrix has six legs
1 parent 31dc63f commit 9db6e34

3 files changed

Lines changed: 91 additions & 30 deletions

File tree

‎.github/scripts/playwright-legs.mjs‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,41 @@ export function planLegs(files, durations, legs) {
6363
}));
6464
}
6565

66+
/**
67+
* Why a suite's proofs do not fit its matrix, or null when they do: the leg
68+
* count the planner takes for `seconds` must be no more than `maxLegs`, and
69+
* every leg it plans, with its setup, within `maxSeconds` plus `slackSeconds`
70+
* (one spec cannot be split across legs). The message names the heaviest
71+
* specs, which are where the time goes.
72+
*/
73+
export function legsFitMessage({
74+
seconds,
75+
files,
76+
costs,
77+
setupSeconds,
78+
maxSeconds,
79+
maxLegs,
80+
slackSeconds = 60,
81+
}) {
82+
const needed = Math.ceil(seconds / (maxSeconds - setupSeconds));
83+
const legs = legCount({seconds, setupSeconds, maxSeconds, maxLegs});
84+
const planned = planLegs(files, costs, legs);
85+
const longest = Math.max(0, ...planned.map(leg => leg.seconds));
86+
if (needed <= maxLegs && longest + setupSeconds <= maxSeconds + slackSeconds)
87+
return null;
88+
const heaviest = [...new Set(files)]
89+
.map(file => [file, costs[file] ?? 0])
90+
.sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1))
91+
.slice(0, 5)
92+
.map(([file, cost]) => `${file} (${Math.round(cost)} s)`)
93+
.join(', ');
94+
return (
95+
`${Math.round(seconds)} s of proofs need ${needed} legs of ${Math.round(maxSeconds - setupSeconds)} s; ` +
96+
`the matrix has ${maxLegs}, and its longest leg takes ${Math.round(longest + setupSeconds)} s with setup. ` +
97+
`Heaviest specs: ${heaviest}`
98+
);
99+
}
100+
66101
/**
67102
* The seconds a suite's proofs take: each listed spec file a filter selects
68103
* (every listed spec with no filter), and each changed spec, at its recorded

‎.github/scripts/playwright-legs.test.mjs‎

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
folderSpecs,
1717
isInteractionSpec,
1818
legCount,
19+
legsFitMessage,
1920
planLegs,
2021
recordLog,
2122
selectProofs,
@@ -37,6 +38,37 @@ const durations = JSON.parse(
3738
);
3839
const step = (job, name) => job.steps.find(each => each.name === name);
3940

41+
describe('legsFitMessage', () => {
42+
const limits = {setupSeconds: 90, maxSeconds: 600, maxLegs: 3};
43+
const costs = {'a.spec.ts': 500, 'b.spec.ts': 500, 'c.spec.ts': 480};
44+
45+
it('fits when the proofs need the last leg the matrix has', () => {
46+
expect(
47+
legsFitMessage({seconds: 1480, files: Object.keys(costs), costs, ...limits}),
48+
).toBeNull();
49+
});
50+
51+
it('names the heaviest specs when the proofs need more legs than the matrix has', () => {
52+
const more = {...costs, 'd.spec.ts': 400};
53+
const message = legsFitMessage({
54+
seconds: 1880,
55+
files: Object.keys(more),
56+
costs: more,
57+
...limits,
58+
});
59+
expect(message).toContain('need 4 legs');
60+
expect(message).toContain('the matrix has 3');
61+
expect(message).toContain('a.spec.ts (500 s), b.spec.ts (500 s), c.spec.ts (480 s)');
62+
});
63+
64+
it('names the spec when one spec alone outlasts a leg', () => {
65+
const one = {'huge.spec.ts': 700};
66+
expect(
67+
legsFitMessage({seconds: 700, files: ['huge.spec.ts'], costs: one, ...limits}),
68+
).toContain('huge.spec.ts (700 s)');
69+
});
70+
});
71+
4072
describe('planLegs', () => {
4173
const times = {a: 120, b: 100, c: 80, d: 50, e: 40, f: 30, g: 20, h: 10};
4274
const files = Object.keys(times);
@@ -290,7 +322,7 @@ describe('the interaction proof legs in ci.yml', () => {
290322
{
291323
id: 'pr-interaction-webkit',
292324
project: 'webkit',
293-
legs: [1, 2, 3, 4, 5],
325+
legs: [1, 2, 3, 4, 5, 6],
294326
run: 'Run WebKit interaction proofs',
295327
plan: "Plan this leg's WebKit interaction proofs",
296328
evidence: 'interaction-evidence-webkit-${{ matrix.leg }}',
@@ -872,34 +904,28 @@ describe('the interaction proof legs in ci.yml', () => {
872904
testsOf,
873905
perTest,
874906
});
875-
// The matrix still has room: the count stays under its legs.
876-
const needed = Math.ceil(
877-
seconds / (limits.maxSeconds - limits.setupSeconds),
878-
);
907+
// The planner fits the matrix: no more legs than it has, and no leg
908+
// over ten minutes (plus one spec's slack). It fails naming the
909+
// heaviest specs, not by a margin under the matrix.
879910
expect(
880-
needed,
881-
`${label}: ${Math.round(seconds)} s of proofs`,
882-
).toBeLessThan(lane.legs.length);
883-
const legsNow = legCount({seconds, ...limits});
884-
const planned = planLegs(
885-
specs.filter(
886-
file =>
887-
filters.length === 0 ||
888-
filters.some(each => file.includes(each)) ||
889-
changed.includes(file),
890-
),
891-
Object.fromEntries(
892-
specs.map(file => [
893-
file,
894-
times[file] ?? fallback[file] ?? testsOf(file) * perTest,
895-
]),
896-
),
897-
legsNow,
898-
);
899-
for (const leg of planned)
900-
expect(leg.seconds + limits.setupSeconds, label).toBeLessThanOrEqual(
901-
limits.maxSeconds + 60,
902-
);
911+
legsFitMessage({
912+
seconds,
913+
files: specs.filter(
914+
file =>
915+
filters.length === 0 ||
916+
filters.some(each => file.includes(each)) ||
917+
changed.includes(file),
918+
),
919+
costs: Object.fromEntries(
920+
specs.map(file => [
921+
file,
922+
times[file] ?? fallback[file] ?? testsOf(file) * perTest,
923+
]),
924+
),
925+
...limits,
926+
}),
927+
label,
928+
).toBeNull();
903929
}
904930
}
905931
});

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,11 +2754,11 @@ jobs:
27542754
# Frame evidence measures timing: four cores, one Playwright worker.
27552755
# The leg count plans as many legs as keep each one's setup and proofs
27562756
# within ten minutes, as the Chromium proofs' count does. The matrix is
2757-
# the ceiling; a leg with no share passes at once.
2757+
# the ceiling, six legs as for Chromium; a leg with no share passes at once.
27582758
strategy:
27592759
fail-fast: false
27602760
matrix:
2761-
leg: [1, 2, 3, 4, 5]
2761+
leg: [1, 2, 3, 4, 5, 6]
27622762
runs-on: ubuntu-latest
27632763
timeout-minutes: 15
27642764
# Playwright's own image for the version the lockfile resolves, with

0 commit comments

Comments
 (0)