From f44360c813f4db4adf2c645447d36922fa9dea1c Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Thu, 22 Oct 2026 08:38:29 +0200 Subject: [PATCH 1/4] =?UTF-8?q?test:=20reproduce=20#852=20=E2=80=94=20CI?= =?UTF-8?q?=20runs=20the=20whole=20console=20lane=20in=20one=2015-minute?= =?UTF-8?q?=20Console=20job?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test-lanes.test.ts | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/test-lanes.test.ts b/src/test-lanes.test.ts index 50826c62b..fb9dec185 100644 --- a/src/test-lanes.test.ts +++ b/src/test-lanes.test.ts @@ -150,3 +150,46 @@ describe("test lanes (package.json)", () => { expect(quality).toMatch(/needs:\s*\[[^\]]*\btiming\b/); }); }); + +/** why: a job's block is its two-space-indented key and every line up to the next one. */ +function ciJobs(ci: string): ReadonlyMap { + const body = /\njobs:\n([\s\S]*)$/.exec(ci)?.[1] ?? ""; + const jobs = new Map(); + for (const block of body.split(/\n(?= {2}[a-z][\w-]*:\n)/)) { + const id = /^ {2}([a-z][\w-]*):\n/.exec(block)?.[1]; + if (id !== undefined) jobs.set(id, block); + } + return jobs; +} + +// why: main's console lane needs about 33 minutes of one runner's two workers (#852), so each +// of four shards runs about 8 inside the 15-minute job timeout. +const CONSOLE_SHARDS_AT_LEAST = 4; + +describe("the console lane in CI (.github/workflows/ci.yml)", () => { + it("runs the console lane over a matrix of at least four shards, each passing its `--shard=/` in both browser modes, and the required `Console` check needs that job and fails when it does not pass", () => { + const ci = readFileSync(join(REPO_ROOT, ".github/workflows/ci.yml"), "utf8"); + const jobs = [...ciJobs(ci)]; + const lanes = jobs.filter(([, job]) => job.includes("pnpm test:console")); + const required = jobs.find(([, job]) => /\n {4}name: Console\n/.test(job)); + + expect(lanes.map(([id]) => id)).toHaveLength(1); + const [laneId, lane] = lanes[0] ?? ["", ""]; + const shards = /\n {8}shard: \[([^\]]*)\]/.exec(lane)?.[1]?.split(",") ?? []; + expect(shards.length, "shards in the console lane's matrix").toBeGreaterThanOrEqual( + CONSOLE_SHARDS_AT_LEAST, + ); + const runs = lane.match(/pnpm test:console[^\n]*/g) ?? []; + expect(runs, "the lane's chromium-only and every-browser commands").toHaveLength(2); + for (const run of runs) { + expect(/--shard[= ]"?\S+\/(\d+)"?/.exec(run)?.[1], run).toBe(String(shards.length)); + } + + expect(required, "a job named Console").toBeDefined(); + const [requiredId, requiredJob] = required ?? ["", ""]; + expect(requiredId).not.toBe(laneId); + expect(requiredJob).toMatch(new RegExp(`\\n {4}needs: \\[[^\\]]*\\b${laneId}\\b`)); + expect(requiredJob).toMatch(/\n {4}if: (\$\{\{ )?always\(\)/); + expect(requiredJob).toContain("needs.*.result"); + }); +}); From 4fcef72e2fd9b9dfa991b6954c476463bf7511d0 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Thu, 22 Oct 2026 08:47:28 +0200 Subject: [PATCH 2/4] fix(ci): shard the console lane over four jobs behind one required Console check (#852) --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8abe2d70..c5fde46db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -189,8 +189,8 @@ jobs: echo "browsers=chromium" >>"$GITHUB_OUTPUT" fi - console: - name: Console + console-lane: + name: Console (${{ matrix.shard }}/4) needs: changes # Runs unless Changes said there is nothing to test, so a broken Changes job runs the lane. if: ${{ !cancelled() && needs.changes.outputs.console != 'false' }} @@ -198,6 +198,11 @@ jobs: permissions: contents: read timeout-minutes: 15 + strategy: + # why: one red shard must not cancel the others, or their failures go unreported. + fail-fast: false + matrix: + shard: [1, 2, 3, 4] steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -223,13 +228,37 @@ jobs: - name: Browser lane env: BROWSERS: ${{ needs.changes.outputs.browsers }} + SHARD: ${{ matrix.shard }} run: | if [ "$BROWSERS" = chromium ]; then - pnpm test:console --project=chromium + pnpm test:console --project=chromium --shard="$SHARD/4" else - pnpm test:console + pnpm test:console --shard="$SHARD/4" fi + # why: branch protection requires the check named Console, so this job stands for the sharded + # lane. `always()` makes it report a failure when a shard fails, where a job skipped by a failed + # need would count as passed; a lane skipped by Changes leaves it green. + console: + name: Console + needs: [changes, console-lane] + if: always() + runs-on: ubuntu-24.04 + permissions: {} + timeout-minutes: 5 + steps: + - name: Every job passed + env: + RESULTS: ${{ join(needs.*.result, ' ') }} + run: | + echo "results: $RESULTS" + for result in $RESULTS; do + case $result in + success | skipped) ;; + *) echo "a job Console needs ended $result" >&2; exit 1 ;; + esac + done + fallow: name: Fallow runs-on: ubuntu-24.04 From eb09ba53114f1c34b0f62e4d5883493187fe74ba Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Thu, 22 Oct 2026 09:14:17 +0200 Subject: [PATCH 3/4] docs(toolchain): the console lane runs in four shards (#852) --- docs/internal/agent-rules/toolchain.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/internal/agent-rules/toolchain.md b/docs/internal/agent-rules/toolchain.md index 224476363..250e27e34 100644 --- a/docs/internal/agent-rules/toolchain.md +++ b/docs/internal/agent-rules/toolchain.md @@ -40,7 +40,8 @@ list and this one the same. - **CI:** what `pnpm check` runs, and Fallow, on every push. The `pnpm check` steps run as parallel jobs (static checks, unit tests, the timing tests, the e2e lane in three shards); the Quality check passes only when all of them - do. The console lane runs on + do. The console lane runs in four shards + (the required Console check passes only when they all do) on every push to `main`, and on a pull request when it changes a source, UI, console spec or build file: in every browser when it changes `ui/` or the console specs, else in Chromium only. From bae9c535b71e625876c746f2ecfd8886a51f42ac Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Thu, 22 Oct 2026 09:22:20 +0200 Subject: [PATCH 4/4] fix(ci): merge-pr re-runs a cancelled console shard; the lane test pins shard index and verdict (#852) --- .agents/scripts/merge-pr.sh | 10 +++++----- src/merge-pr.test.ts | 5 +++++ src/test-lanes.test.ts | 19 +++++++++++++++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.agents/scripts/merge-pr.sh b/.agents/scripts/merge-pr.sh index fbd026e43..41b183954 100755 --- a/.agents/scripts/merge-pr.sh +++ b/.agents/scripts/merge-pr.sh @@ -87,13 +87,13 @@ rerunnable_runs() { -q '.[] | select(.pull_request == null) | .title, .body // ""' | grep -oE '(e2e|src|ui)/[A-Za-z0-9_./-]+\.(test|spec)\.tsx?' || true) red=$(checks | grep -e '^fail ' -e '^cancel ' || true) - others=$(echo "$red" | awk '$3 != "Quality"') + others=$(echo "$red" | sed 's/^[^ ]* [^ ]* //' | grep -vxE 'Quality|Console' || true) echo "$red" | grep . | while read -r bucket link name; do - # why: Quality only sums up the CI jobs it needs and fails when one was cancelled, so - # next to a red job, judging it would call that job's cancel this PR's to fix. Red - # alone, Quality was cancelled itself and is re-run like any job. - [ "$name" != Quality ] || [ -z "$others" ] || continue + # why: Quality and Console only sum up the CI jobs they need and fail when one was + # cancelled, so next to a red job, judging them would call that job's cancel this PR's to + # fix. Red alone, they were cancelled themselves and are re-run like any job. + case $name in Quality | Console) [ -z "$others" ] || continue ;; esac run=$(echo "$link" | sed -n 's#.*/actions/runs/\([0-9][0-9]*\).*#\1#p') [ -n "$run" ] || { echo none; continue; } if [ "$bucket" = fail ]; then diff --git a/src/merge-pr.test.ts b/src/merge-pr.test.ts index 73e546c0a..d262490a7 100644 --- a/src/merge-pr.test.ts +++ b/src/merge-pr.test.ts @@ -387,6 +387,11 @@ describe("merge-pr.sh re-run of red CI", { timeout: 20_000 }, () => { runs: [run("cancelled", "E2E (2/3)"), run("failure")], runsAfterRerun: [run("success", "E2E (2/3)"), run("success")], }, + { + name: "a console shard, though the Console check that needs it failed,", + runs: [run("cancelled", "Console (2/4)"), run("failure", "Console")], + runsAfterRerun: [run("success", "Console (2/4)"), run("success", "Console")], + }, { name: "a Quality check, while every job it needs passed,", runs: [run("success", "E2E (2/3)"), run("cancelled")], diff --git a/src/test-lanes.test.ts b/src/test-lanes.test.ts index fb9dec185..9ab72cf39 100644 --- a/src/test-lanes.test.ts +++ b/src/test-lanes.test.ts @@ -1,3 +1,4 @@ +import { spawnSync } from "node:child_process"; import { readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; @@ -181,8 +182,13 @@ describe("the console lane in CI (.github/workflows/ci.yml)", () => { ); const runs = lane.match(/pnpm test:console[^\n]*/g) ?? []; expect(runs, "the lane's chromium-only and every-browser commands").toHaveLength(2); + expect(lane, "the shard index comes from the matrix").toMatch( + /\n {10}SHARD: \$\{\{ matrix\.shard \}\}/, + ); for (const run of runs) { - expect(/--shard[= ]"?\S+\/(\d+)"?/.exec(run)?.[1], run).toBe(String(shards.length)); + expect(run, "index from the matrix, count from its length").toMatch( + new RegExp(`--shard="\\$SHARD/${shards.length}"`), + ); } expect(required, "a job named Console").toBeDefined(); @@ -190,6 +196,15 @@ describe("the console lane in CI (.github/workflows/ci.yml)", () => { expect(requiredId).not.toBe(laneId); expect(requiredJob).toMatch(new RegExp(`\\n {4}needs: \\[[^\\]]*\\b${laneId}\\b`)); expect(requiredJob).toMatch(/\n {4}if: (\$\{\{ )?always\(\)/); - expect(requiredJob).toContain("needs.*.result"); + const body = /\n {8}run: \|\n((?: {10}[^\n]*\n?)+)/.exec(requiredJob)?.[1] ?? ""; + expect(body, "the Console job's run script").not.toBe(""); + const verdict = (results: string) => + spawnSync("bash", ["-c", body.replace(/^ {10}/gm, "")], { + env: { PATH: process.env["PATH"] ?? "", RESULTS: results }, + }).status; + expect(verdict("success skipped success"), "every need passed or was skipped").toBe(0); + for (const bad of ["success failure", "cancelled", "skipped failure skipped"]) { + expect(verdict(bad), `results ${bad}`).toBe(1); + } }); });