diff --git a/.changeset/dox-sunshine-inset-click-at-rest.md b/.changeset/dox-sunshine-inset-click-at-rest.md new file mode 100644 index 00000000..c64b310d --- /dev/null +++ b/.changeset/dox-sunshine-inset-click-at-rest.md @@ -0,0 +1,4 @@ +--- +--- + +No release. The Sunshine Protection Act inset-click test presses each frame once the drawing's arrival fade has ended. PR browser tests run in Chromium only, and WebKit runs them in the weekly sweep. That sweep now keeps one rolling `dox-gate` issue: a failing run rewrites it and a clean run closes it. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28aca2b0..c2e9d0d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -383,7 +383,7 @@ jobs: # The checks that open the built site in a browser, on the artifact `dox-site` uploaded. A failed # `dox-site` skips this job, so its failure shows once, on `dox-site`. dox-browser: - name: Dox browser tests (Chromium, WebKit) + name: Dox browser tests (Chromium) runs-on: ubuntu-latest needs: [determine-affected, dox-site] if: contains(fromJSON(needs.determine-affected.outputs.checks), 'dox-dist') || contains(fromJSON(needs.determine-affected.outputs.checks), 'dox-tables') @@ -446,17 +446,18 @@ jobs: uses: actions/cache@v6 with: path: ~/.cache/ms-playwright - key: playwright-${{ runner.os }}-${{ steps.pw.outputs.os }}-${{ steps.pw.outputs.version }}-chromium-webkit + key: playwright-${{ runner.os }}-${{ steps.pw.outputs.os }}-${{ steps.pw.outputs.version }}-chromium - # WebKit too: the industry tag test checks where Safari's engine places the tag definition. - - name: Install Chromium and WebKit + # Chromium only: WebKit runs these tests once a week (dox-gates-weekly.yml, the webkit-1 leg's + # step Browser tests, in WebKit). + - name: Install Chromium if: contains(fromJSON(env.CHECKS), 'dox-tables') - run: pnpm --filter @gmt/dox exec playwright install --with-deps chromium webkit + run: pnpm --filter @gmt/dox exec playwright install --with-deps chromium # The tests that launch a browser (`*.browser.test.ts`, left out of the Tests job, which # installs none): the industry tag definitions. The built # site is there, so a test that needs it fails rather than skips. - - name: Browser tests, in Chromium and WebKit + - name: Browser tests, in Chromium if: contains(fromJSON(env.CHECKS), 'dox-tables') env: DOX_DIST_REQUIRED: "1" diff --git a/.github/workflows/dox-gates-weekly.yml b/.github/workflows/dox-gates-weekly.yml index 7a84a91f..e846bfce 100644 --- a/.github/workflows/dox-gates-weekly.yml +++ b/.github/workflows/dox-gates-weekly.yml @@ -3,16 +3,16 @@ name: Dox gates weekly # Pulse check: dox-gates # # The PR job (ci.yml, `dox-gates`) checks the changed pages in Chromium. This sweep checks every page -# in three browsers and both themes, once a week, and files what fails as a `dox-gate` issue, one -# open issue per finding (apps/dox/scripts/gates/issue-plan.mjs). A failing gate fails its leg; the -# report job still runs and files. `force_finding` on a manual dispatch also files one [dry run] -# issue for a synthetic finding, to prove the filing path without a real failure. +# in three browsers and both themes, once a week, and files what fails in one rolling `dox-gate` +# issue (apps/dox/scripts/gates/issue-plan.mjs): each failing run rewrites it, a clean run closes it. +# A failing gate fails its leg; the report job still runs and files. `force_finding` on a manual +# dispatch also files one [dry run] rolling issue for a synthetic finding, to prove the filing path. # -# Legs: --shard i/n splits each gate's page list so the legs of one browser share the work: by name, -# round-robin starting at the gate's registry index (so the one-page gates spread over the legs). -# 4 Chromium legs, one Firefox and one WebKit leg leave about 10 minutes of headroom under the -# 40-minute deadline. Adding or removing a leg means changing the matrix and the LEGS list of the -# report job, which names every leg so one that crashed without uploading is still filed. +# Legs: one per browser. Chromium runs every page of `a11y-axe` in both themes, about 100 minutes; +# nobody waits on a weekly run, so it is one long leg rather than shards. --shard i/n can split a +# browser's pages over more legs again: by name, round-robin from the gate's registry index. Adding +# or removing a leg means changing the matrix and the LEGS list of the report job, which names every +# leg so one that crashed without uploading is still filed. # # A leg whose summary never reaches the report is sorted by its job (apps/dox/scripts/gates/ # issue-plan.mjs, `missingSummary`): if its "Check the summary was written" step passed, the runner @@ -24,7 +24,7 @@ on: workflow_dispatch: inputs: force_finding: - description: "Dry run: file one [dry run] issue for a synthetic finding" + description: "Dry run: also file one rolling [dry run] issue for a synthetic finding" type: boolean required: false default: false @@ -46,15 +46,12 @@ jobs: sweep: name: Sweep (${{ matrix.leg }}) runs-on: ubuntu-latest - timeout-minutes: 50 + timeout-minutes: 150 strategy: fail-fast: false matrix: include: - - { leg: chromium-1, browser: chromium, shard: "1/4" } - - { leg: chromium-2, browser: chromium, shard: "2/4" } - - { leg: chromium-3, browser: chromium, shard: "3/4" } - - { leg: chromium-4, browser: chromium, shard: "4/4" } + - { leg: chromium-1, browser: chromium, shard: "1/1" } - { leg: firefox-1, browser: firefox, shard: "1/1" } - { leg: webkit-1, browser: webkit, shard: "1/1" } steps: @@ -98,7 +95,38 @@ jobs: - name: Gates, every page (shard ${{ matrix.shard }}) run: > pnpm --filter dox gates --all --browsers ${{ matrix.browser }} - --themes dark,light --retries 1 --shard ${{ matrix.shard }} --deadline 40 + --themes dark,light --retries 1 --shard ${{ matrix.shard }} --deadline 140 + + # WebKit runs the browser tests here, once a week; every PR runs them in Chromium (ci.yml, + # `dox-browser`). This leg already has WebKit and the site the gates built. The result joins + # the leg's summary as a `browser-tests` row, so a failure lands in the rolling issue with the + # failing tests' lines. + - name: Browser tests, in WebKit + if: ${{ !cancelled() && matrix.browser == 'webkit' }} + env: + DOX_BROWSERS: webkit + DOX_DIST_REQUIRED: "1" + run: | + set +e + pnpm --filter dox exec vitest run --config vitest.browser.config.ts 2>&1 | tee "$RUNNER_TEMP/browser-tests.log" + code=${PIPESTATUS[0]} + node -e ' + const fs = require("node:fs"); + const [code, log] = process.argv.slice(1); + const file = "apps/dox/.gates/summary.json"; + if (!fs.existsSync(file)) process.exit(0); + const summary = JSON.parse(fs.readFileSync(file, "utf8")); + const lines = fs.readFileSync(log, "utf8").replace(/\x1b\[[0-9;]*m/g, "").split("\n"); + const failing = lines.filter((l) => / FAIL |Error/.test(l)); + summary.rows.push({ + id: "browser-tests", + status: code === "0" ? "PASS" : "FAIL", + detail: "*.browser.test.ts in WebKit", + logTail: (failing.length > 0 ? failing : lines).slice(-10), + }); + fs.writeFileSync(file, JSON.stringify(summary, null, 2)); + ' "$code" "$RUNNER_TEMP/browser-tests.log" + exit "$code" # Passes only when the runner left a summary the report can read. The report reads this # step's result from the jobs API to tell a leg that lost its upload from one that never @@ -177,7 +205,7 @@ jobs: GH_TOKEN: ${{ github.token }} FORCE_FINDING: ${{ inputs.force_finding }} # Every leg of the sweep job's matrix. - LEGS: chromium-1,chromium-2,chromium-3,chromium-4,firefox-1,webkit-1 + LEGS: chromium-1,firefox-1,webkit-1 run: | args=(--legs "$LEGS") if [ "$FORCE_FINDING" = "true" ]; then args+=(--dry-run-finding); fi diff --git a/apps/dox/scripts/ccsds-time-code-decoder-holds.browser.test.ts b/apps/dox/scripts/ccsds-time-code-decoder-holds.browser.test.ts index 1c6b6bcf..045beb57 100644 --- a/apps/dox/scripts/ccsds-time-code-decoder-holds.browser.test.ts +++ b/apps/dox/scripts/ccsds-time-code-decoder-holds.browser.test.ts @@ -1,13 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserType, - type Page, -} from "@playwright/test"; +import { type Browser, type Page } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -24,10 +19,7 @@ const EPSILON = 0.5; const WIDTHS = [300, 1280]; /** The widths the page is loaded at. */ const LOAD_WIDTHS = [390, 1440]; -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); /** * The boxes whose size the reader must never see change. A hold's live content (the code frame * inside the calls hold) may be shorter than the hold, so only the hold itself is measured. diff --git a/apps/dox/scripts/clock-row-height.browser.test.ts b/apps/dox/scripts/clock-row-height.browser.test.ts index 8d4737c4..56e21c5f 100644 --- a/apps/dox/scripts/clock-row-height.browser.test.ts +++ b/apps/dox/scripts/clock-row-height.browser.test.ts @@ -1,12 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserType, -} from "@playwright/test"; +import { type Browser } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -18,10 +14,7 @@ import { serveStatic } from "./lib/static-server.mjs"; */ const dist = distDirOrSkip(); -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); let server: Server | undefined; diff --git a/apps/dox/scripts/code-b-day-ruler-holds.browser.test.ts b/apps/dox/scripts/code-b-day-ruler-holds.browser.test.ts index f6116a8f..a699d7b4 100644 --- a/apps/dox/scripts/code-b-day-ruler-holds.browser.test.ts +++ b/apps/dox/scripts/code-b-day-ruler-holds.browser.test.ts @@ -1,14 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type ElementHandle, - type BrowserType, - type Page, -} from "@playwright/test"; +import { type Browser, type ElementHandle, type Page } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import type { ExpectStatic } from "vitest"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -31,10 +25,7 @@ const dist = distDirOrSkip(); const EPSILON = 0.5; const WIDTHS = [300, 390, 1280, 1440]; const THEMES = ["light", "dark"] as const; -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); const GATES = ["hold", "hero", "drawn"]; const PRESETS = ["after-leap-day", "day-366", "century"]; diff --git a/apps/dox/scripts/first-paint-layout.browser.test.ts b/apps/dox/scripts/first-paint-layout.browser.test.ts index 3b29d10d..16147fff 100644 --- a/apps/dox/scripts/first-paint-layout.browser.test.ts +++ b/apps/dox/scripts/first-paint-layout.browser.test.ts @@ -1,12 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserType, -} from "@playwright/test"; +import { type Browser } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -25,10 +21,7 @@ import { serveStatic } from "./lib/static-server.mjs"; */ const dist = distDirOrSkip(); -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); /** The issue's window, a laptop, and a phone held upright. */ const VIEWPORTS = [ diff --git a/apps/dox/scripts/fix-timestamp-reader-holds.browser.test.ts b/apps/dox/scripts/fix-timestamp-reader-holds.browser.test.ts index 74c397a2..c9f82d93 100644 --- a/apps/dox/scripts/fix-timestamp-reader-holds.browser.test.ts +++ b/apps/dox/scripts/fix-timestamp-reader-holds.browser.test.ts @@ -1,13 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserType, - type Page, -} from "@playwright/test"; +import { type Browser, type Page } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -24,10 +19,7 @@ const EPSILON = 0.5; const WIDTHS = [300, 1280]; /** The widths the page is loaded at. */ const LOAD_WIDTHS = [390, 1440]; -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); /** * The boxes whose size the reader must never see change. A hold's live content (the code frame * inside the calls hold) may be shorter than the hold, so only the hold itself is measured. diff --git a/apps/dox/scripts/gates/ci-legs.test.ts b/apps/dox/scripts/gates/ci-legs.test.ts index 97f7ecb9..d774fea4 100644 --- a/apps/dox/scripts/gates/ci-legs.test.ts +++ b/apps/dox/scripts/gates/ci-legs.test.ts @@ -48,15 +48,15 @@ describe("the Dox gates job in ci.yml", () => { }); describe("the weekly sweep legs", () => { - it("run 4 Chromium legs, one Firefox leg and one WebKit leg", () => { + it("run one leg per browser", () => { const matrix = (weekly.jobs.sweep?.strategy?.matrix?.include ?? []) as unknown as { browser: string }[]; const count = (browser: string) => matrix.filter((m) => m.browser === browser).length; expect([count("chromium"), count("firefox"), count("webkit")]).toEqual([ - 4, 1, 1, + 1, 1, 1, ]); - expect(matrix).toHaveLength(6); + expect(matrix).toHaveLength(3); }); it("stop their runner at least 10 minutes inside the job's timeout", () => { diff --git a/apps/dox/scripts/gates/file-issues.mjs b/apps/dox/scripts/gates/file-issues.mjs index 55a6215c..ef79300a 100644 --- a/apps/dox/scripts/gates/file-issues.mjs +++ b/apps/dox/scripts/gates/file-issues.mjs @@ -1,9 +1,10 @@ #!/usr/bin/env node /** - * Files the weekly gate sweep's findings as `dox-gate` issues. A thin shell around the pure decision + * Files the weekly gate sweep's findings as one rolling `dox-gate` issue. A thin shell around the pure decision * in `./issue-plan.mjs`, shaped like `scripts/canary-report.mjs`: it reads the `summary.json` each - * sweep leg wrote, asks the planner what to do against the open `dox-gate` issues and runs that - * through the GitHub CLI. + * sweep leg wrote, asks the planner what to do against the open `dox-gate` issues (open, edit or + * comment on the rolling issue, close it when clean, close the old per-finding issues) and runs + * that through the GitHub CLI. * * node apps/dox/scripts/gates/file-issues.mjs [--print] [--offline] [--dry-run-finding] * [--legs ] @@ -18,7 +19,7 @@ * action, then a count); with `$GITHUB_STEP_SUMMARY` set it also appends the plan there. * `--offline` plans with no `gh` call at all: no open issue is assumed and no job list is read, so * it runs anywhere and implies `--print`. Every action line shows its body's length; no body or - * comment may pass `BODY_LIMIT`, checked before the first write. `--dry-run-finding` adds one synthetic `[dry run]` finding under the `dox-gate-dry-run` label. + * comment may pass `BODY_LIMIT`, checked before the first write. `--dry-run-finding` adds one synthetic `[dry run]` finding in its own rolling issue under the `dox-gate-dry-run` label. * * Exit 0 when the actions were carried out (findings do not change it; the sweep legs already * fail), 1 when a `gh` call failed, 2 for usage (including a summary path with no leg or no @@ -130,7 +131,7 @@ export function listOpenGateIssues(gh) { "--limit", "1000", "--json", - "number,body,labels", + "number,title,body,labels", ]), ); } @@ -153,6 +154,25 @@ export function runActions(gh, actions) { ); return { action, ok: true }; } + if (action.kind === "edit") { + gh( + [ + "issue", + "edit", + String(action.issue), + "--title", + action.title, + "--body-file", + "-", + ], + action.body, + ); + return { action, ok: true }; + } + if (action.kind === "close") { + gh(["issue", "close", String(action.issue), "--comment", action.body]); + return { action, ok: true }; + } gh( [ "issue", @@ -260,8 +280,10 @@ export function readLegs(files, legs) { const actionLine = (a) => a.kind === "open" - ? `open ${a.key} ${a.title}${a.groups === undefined ? "" : ` ${a.groups} groups`} body ${a.body.length} chars` - : `comment #${a.issue} ${a.key} body ${a.body.length} chars`; + ? `open ${a.group} ${a.title} body ${a.body.length} chars` + : a.kind === "edit" + ? `edit #${a.issue} ${a.group} ${a.title} body ${a.body.length} chars` + : `${a.kind} #${a.issue} ${a.group} body ${a.body.length} chars`; /** The actions whose body is longer than GitHub accepts, as error lines. */ const oversize = (actions) => @@ -269,7 +291,7 @@ const oversize = (actions) => .filter((a) => a.body.length > BODY_LIMIT) .map( (a) => - `file-issues: the ${a.kind === "open" ? "issue" : "comment"} for ${a.key} is ${a.body.length} characters, over GitHub's ${BODY_LIMIT}`, + `file-issues: the ${a.kind} for ${a.group} is ${a.body.length} characters, over GitHub's ${BODY_LIMIT}`, ); /** diff --git a/apps/dox/scripts/gates/file-issues.test.ts b/apps/dox/scripts/gates/file-issues.test.ts index 2c105dda..6c06a053 100644 --- a/apps/dox/scripts/gates/file-issues.test.ts +++ b/apps/dox/scripts/gates/file-issues.test.ts @@ -18,10 +18,9 @@ import { } from "./file-issues.mjs"; import { DOWNLOAD_STEP, - NOT_UPLOADED_KEY, SUMMARY_STEP, UPLOAD_STEP, - marker, + rollingMarker, } from "./issue-plan.mjs"; type Call = { args: string[]; input?: string }; @@ -54,6 +53,13 @@ function summaryFile(leg: string, summary: unknown) { return file; } +/** The body of every issue a run created, as one text. */ +const created = (calls: Call[]) => + calls + .filter((c) => c.args[0] === "issue" && c.args[1] === "create") + .map((c) => c.input) + .join("\n"); + const failing = { status: "FAIL", rows: [ @@ -153,7 +159,7 @@ describe("the gh argument lists", () => { "--limit", "1000", "--json", - "number,body,labels", + "number,title,body,labels", ]); }); @@ -162,12 +168,12 @@ describe("the gh argument lists", () => { const results = runActions(gh, [ { kind: "open", - key: "k", + group: "weekly", title: "T", labels: ["dox-gate"], body: "B", }, - { kind: "comment", key: "k", issue: 12, body: "C" }, + { kind: "comment", group: "weekly", issue: 12, body: "C" }, ]); expect(results.every((r) => r.ok)).toBe(true); expect(calls).toEqual([ @@ -188,6 +194,25 @@ describe("the gh argument lists", () => { ]); }); + it("edits the title and body on stdin, and closes with the comment as an argument", () => { + const { gh, calls } = fakeGh(); + const results = runActions(gh, [ + { kind: "edit", group: "weekly", issue: 12, title: "T2", body: "B2" }, + { kind: "close", group: "legacy", issue: 593, body: "Folded into #12" }, + ]); + expect(results.every((r) => r.ok)).toBe(true); + expect(calls).toEqual([ + { + args: ["issue", "edit", "12", "--title", "T2", "--body-file", "-"], + input: "B2", + }, + { + args: ["issue", "close", "593", "--comment", "Folded into #12"], + input: undefined, + }, + ]); + }); + it("records a failed call and runs the next action", () => { let n = 0; const { gh } = fakeGh(() => { @@ -195,8 +220,8 @@ describe("the gh argument lists", () => { return ""; }); const results = runActions(gh, [ - { kind: "comment", key: "a", issue: 1, body: "x" }, - { kind: "comment", key: "b", issue: 2, body: "y" }, + { kind: "comment", group: "weekly", issue: 1, body: "x" }, + { kind: "comment", group: "weekly", issue: 2, body: "y" }, ]); expect(results.map((r) => r.ok)).toEqual([false, true]); }); @@ -288,8 +313,12 @@ describe("main", () => { expect(calls.map((c) => c.args[0] + " " + c.args[1])).toEqual([ "issue list", ]); - expect(out.join("")).toContain("open a11y-axe:color-contrast:/x/:page"); - expect(out.join("")).toContain("open dry-run:synthetic:/:body [dry run]"); + expect(out.join("")).toContain( + "open weekly Dox gates: 1 failure in 1 group body", + ); + expect(out.join("")).toContain( + "open dry-run [dry run] Dox gates: 1 failure in 1 group body", + ); expect(out.join("")).toContain("2 actions planned (not run)"); }); @@ -304,7 +333,9 @@ describe("main", () => { main(["--offline", "--legs", "chromium-1,firefox-1", file, missing], i), ).toBe(0); expect(calls).toHaveLength(0); - expect(out.join("")).toContain("open a11y-axe:color-contrast:/x/:page"); + expect(out.join("")).toContain( + "open weekly Dox gates: 2 failures in 2 groups", + ); expect(out.join("")).toContain("planned (not run)"); }); @@ -322,26 +353,42 @@ describe("main", () => { expect(calls).toHaveLength(0); }); - it("--print shows each body's length and a flood's group count", () => { + it("--print shows each action's kind, issue and body length", () => { const rows = Array.from({ length: 12 }, (_, i) => ({ ...failing.rows[0].findings![0], page: `/p${i}/`, })); - const flooding = { + const many = { status: "FAIL", rows: [{ ...failing.rows[0], findings: rows }], }; - const { gh } = fakeGh(() => "[]"); + const open = [ + { + number: 4, + title: "Dox gates: 3 failures in 1 group", + body: `${rollingMarker("weekly")}\nold`, + labels: [{ name: "dox-gate" }], + }, + { + number: 5, + title: "old", + body: '\nold', + labels: [{ name: "dox-gate" }], + }, + ]; + const { gh } = fakeGh(() => JSON.stringify(open)); const { out, io: i } = io(gh); - expect(main(["--print", summaryFile("chromium-1", flooding)], i)).toBe(0); + expect(main(["--print", summaryFile("chromium-1", many)], i)).toBe(0); expect(out.join("")).toMatch( - /open dox-gate:flood .* 12 groups {2}body \d+ chars/, + /edit #4 {2}weekly {2}Dox gates: 12 failures in 12 groups {2}body \d+ chars/, ); + expect(out.join("")).toMatch(/comment #4 {2}weekly {2}body \d+ chars/); + expect(out.join("")).toMatch(/close #5 {2}legacy {2}body \d+ chars/); }); - it("exits 1 before any gh call when a body is over the limit", () => { + it("cuts an oversize finding to fit, so the body is within the limit and filing goes on", () => { const { gh, calls } = fakeGh(() => "[]"); - const { err, io: i } = io(gh); + const { io: i } = io(gh); const huge = { status: "FAIL", rows: [ @@ -356,11 +403,10 @@ describe("main", () => { }, ], }; - expect(main([summaryFile("chromium-1", huge)], i)).toBe(1); - expect(calls).toHaveLength(0); - expect(err.join("")).toMatch( - /a11y-axe:color-contrast:\/p+.* is \d+ characters/, - ); + expect(main([summaryFile("chromium-1", huge)], i)).toBe(0); + const body = created(calls); + expect(body.length).toBeGreaterThan(0); + expect(body.length).toBeLessThan(65_536); }); it("files the findings: labels, then the issue, exit 0", () => { @@ -374,9 +420,7 @@ describe("main", () => { "label create", "issue create", ]); - expect(calls.at(-1)!.input!.split("\n")[0]).toBe( - marker("a11y-axe:color-contrast:/x/:page"), - ); + expect(calls.at(-1)!.input!.split("\n")[0]).toBe(rollingMarker("weekly")); }); it("makes no write call when nothing failed", () => { @@ -389,22 +433,14 @@ describe("main", () => { expect(out.join("")).toContain("0 actions"); }); + const okFile = () => summaryFile("chromium-1", { status: "PASS", rows: [] }); + it("files a leg named in --legs that has no summary as could-not-run", () => { - const { gh } = fakeGh(() => "[]"); - const { out, io: i } = io(gh); - expect( - main( - [ - "--print", - "--legs", - "chromium-1,webkit-2", - summaryFile("chromium-1", { status: "PASS", rows: [] }), - ], - i, - ), - ).toBe(0); - expect(out.join("")).toContain("dox-gate:could-not-run:webkit-2"); - expect(out.join("")).not.toContain("could-not-run:chromium-1"); + const { gh, calls } = fakeGh(() => "[]"); + const { io: i } = io(gh); + expect(main(["--legs", "chromium-1,webkit-2", okFile()], i)).toBe(0); + expect(created(calls)).toContain("could not run the webkit-2 leg"); + expect(created(calls)).not.toContain("the chromium-1 leg"); }); it("files a leg that wrote a summary the report never got as not-uploaded", () => { @@ -416,32 +452,22 @@ describe("main", () => { ]) : "[]", ); - const { out, err, io: i } = io(gh); - expect( - main( - [ - "--print", - "--legs", - "chromium-1,webkit-2", - summaryFile("chromium-1", { status: "PASS", rows: [] }), - ], - i, - ), - ).toBe(0); - expect(calls.map((c) => c.args[0])).toEqual(["api", "issue"]); - expect(out.join("")).toContain(`open ${NOT_UPLOADED_KEY}`); - expect(out.join("")).not.toContain("could-not-run"); + const { err, io: i } = io(gh); + expect(main(["--legs", "chromium-1,webkit-2", okFile()], i)).toBe(0); + expect(calls[0].args[0]).toBe("api"); + expect(created(calls)).toContain("leg findings did not reach the report"); + expect(created(calls)).not.toContain("could not run"); expect(err).toHaveLength(0); }); it("still files could-not-run when the job list cannot be read, and says so", () => { - const { gh } = fakeGh((args) => { + const { gh, calls } = fakeGh((args) => { if (args[0] === "api") throw new Error("HTTP 403"); return "[]"; }); - const { out, err, io: i } = io(gh); - expect(main(["--print", "--legs", "webkit-2"], i)).toBe(0); - expect(out.join("")).toContain("open dox-gate:could-not-run:webkit-2"); + const { err, io: i } = io(gh); + expect(main(["--legs", "webkit-2"], i)).toBe(0); + expect(created(calls)).toContain("could not run the webkit-2 leg"); expect(err.join("")).toContain("cannot read the run's jobs: HTTP 403"); }); @@ -455,17 +481,14 @@ describe("main", () => { stderr: () => {}, }); expect(calls.map((c) => c.args[0])).toEqual(["issue"]); - expect(out.join("")).toContain("open dox-gate:could-not-run:webkit-2"); + expect(out.join("")).toContain("open weekly Dox gates: 1 failure"); }); it("treats an unreadable summary of a named leg as could-not-run", () => { - const { gh } = fakeGh(() => "[]"); - const { out, io: i } = io(gh); - main( - ["--print", "--legs", "firefox-1", summaryFile("firefox-1", "not json")], - i, - ); - expect(out.join("")).toContain("dox-gate:could-not-run:firefox-1"); + const { gh, calls } = fakeGh(() => "[]"); + const { io: i } = io(gh); + main(["--legs", "firefox-1", summaryFile("firefox-1", "not json")], i); + expect(created(calls)).toContain("could not run the firefox-1 leg"); }); it("exits 2 with zero gh calls for a mistyped path without --legs", () => { @@ -479,49 +502,38 @@ describe("main", () => { }); it("files could-not-run for the one leg that is missing", () => { - const { gh } = fakeGh(() => "[]"); - const { out, io: i } = io(gh); - const ok = summaryFile("chromium-1", { status: "PASS", rows: [] }); + const { gh, calls } = fakeGh(() => "[]"); + const { io: i } = io(gh); expect( main( [ - "--print", "--legs", "chromium-1,chromium-2", - ok, + okFile(), "/gone/chromium-2/summary.json", ], i, ), ).toBe(0); - expect(out.join("")).toContain("open dox-gate:could-not-run:chromium-2"); - expect(out.join("")).not.toContain("could-not-run:chromium-1"); + expect(created(calls)).toContain("could not run the chromium-2 leg"); + expect(created(calls)).not.toContain("the chromium-1 leg"); }); - it("files one per leg when every leg is missing, with the glob unexpanded or empty", () => { + it("files one section per leg when every leg is missing, with the glob unexpanded or empty", () => { for (const files of [["artifacts/*/summary.json"], []]) { - const { gh } = fakeGh(() => "[]"); - const { out, err, io: i } = io(gh); - expect(main(["--print", "--legs", "a-1,b-2,c-3", ...files], i)).toBe(0); - const text = out.join(""); + const { gh, calls } = fakeGh(() => "[]"); + const { err, io: i } = io(gh); + expect(main(["--legs", "a-1,b-2,c-3", ...files], i)).toBe(0); + const text = created(calls); for (const leg of ["a-1", "b-2", "c-3"]) - expect(text).toContain(`open dox-gate:could-not-run:${leg}`); - expect(text).toContain("3 actions planned"); + expect(text).toContain(`### Dox weekly could not run the ${leg} leg`); + expect( + calls.filter((c) => c.args[0] === "issue" && c.args[1] === "create"), + ).toHaveLength(1); expect(err).toHaveLength(0); } }); - it("never plans a key that ends in a colon from a leg-less path", () => { - const { gh } = fakeGh(() => "[]"); - const { out, io: i } = io(gh); - main(["--print", "--legs", "a-1", "/nonexistent.json"], i); - expect(main(["--print", "/nonexistent.json"], i)).toBe(2); - for (const line of out.join("").split("\n")) { - const key = /^open {2}(\S+)/.exec(line)?.[1]; - if (key) expect(key.endsWith(":")).toBe(false); - } - }); - it("only plans outside GitHub Actions: no --print exits 2 with zero gh calls", () => { const { gh, calls } = fakeGh(() => "[]"); const out: string[] = []; diff --git a/apps/dox/scripts/gates/issue-plan.mjs b/apps/dox/scripts/gates/issue-plan.mjs index 8b97ce3c..89dd60cb 100644 --- a/apps/dox/scripts/gates/issue-plan.mjs +++ b/apps/dox/scripts/gates/issue-plan.mjs @@ -1,34 +1,38 @@ /** - * The pure decision behind the weekly gate issues. The summaries the sweep legs wrote and the - * open `dox-gate` issues go in; a list of `open` / `comment` actions comes out. Nothing here reads - * a file, the network, the process or the clock, so the whole rule set is tested offline - * (`issue-plan.test.ts`). It is modelled on `scripts/lib/canary-issues.mjs`; the `gh` shell is - * `file-issues.mjs`. + * The pure decision behind the weekly gate issue. The summaries the sweep legs wrote and the + * open `dox-gate` issues go in; a list of `open` / `edit` / `comment` / `close` actions comes out. + * Nothing here reads a file, the network, the process or the clock, so the whole rule set is + * tested offline (`issue-plan.test.ts`). It follows `scripts/lib/canary-issues.mjs`; the `gh` + * shell is `file-issues.mjs`. * - * One open issue per finding key. The key is `:::`, the target being the - * element's identity key (`lib/element-identity.mjs`: scope, role and accessible name); browsers, widths and themes are not in it, so one issue - * lists every place the finding was seen. Only `FAIL` rows file: `FLAKY` is listed in the step - * summary (`flakyRows`) and never filed. A leg with no readable `summary.json` is sorted by its - * sweep job (`missingSummary`): one whose `SUMMARY_STEP` passed wrote the file and lost it on the - * way, and joins the one `dox-gate:not-uploaded:all:` issue; any other files - * `dox-gate:could-not-run:`. A leg whose runner stopped at its `--deadline` (rows marked - * `outOfTime`) files `dox-gate:out-of-time:` with every gate's minutes; the structured - * findings it reached before the deadline still file. Any other `FAIL` row with no structured finding files - * `:unstructured:all:` with its log tail. A run that would open more than `FLOOD_LIMIT` new - * issues opens none and files one `dox-gate:flood` issue listing them, because that many at - * once is one systemic cause for a person to triage. + * One scheduled run files one issue. Each group keeps at most one open "rolling" issue, which + * carries the label `dox-gate` and, as its body's first line, a hidden marker naming the group: + * `weekly` for real findings, `dry-run` for the one synthetic finding of a forced dry run, so a + * dry run never touches the real issue. A failing run rewrites that issue (title and body) with + * every finding of the run, one section each, and adds a comment saying the run still fails and + * how many findings it held now and before. With no such issue open, the run opens it. A clean + * run closes the weekly one; the dry-run one is closed by a person. An open issue from the + * earlier one-issue-per-finding shape (marker `key="..."`: per-finding and flood issues) is + * closed as folded in, or as clean. Dry-run legacy issues are left alone. + * + * A finding is `:::`, the target being the element's identity key + * (`lib/element-identity.mjs`: scope, role and accessible name); browsers, widths and themes are + * not in it, so one section lists every place the finding was seen. Only `FAIL` rows count: + * `FLAKY` is listed in the step summary (`flakyRows`) and never filed. A leg with no readable + * `summary.json` is sorted by its sweep job (`missingSummary`): one whose `SUMMARY_STEP` passed + * wrote the file and lost it on the way, and joins the one `not-uploaded` section; any other + * gets a `could-not-run` section. A leg whose runner stopped at its `--deadline` (rows marked + * `outOfTime`) gets an `out-of-time` section with every gate's minutes; the structured findings + * it reached before the deadline still count. Any other `FAIL` row with no structured finding + * gets an `unstructured` section with its log tail. */ /** The one label every gate issue carries, and the one the open-issue query filters on. */ export const GATE_LABEL = "dox-gate"; -/** Label of the issue a dry run files, in place of `dox-gate`. */ +/** Label of the issue a dry run files, besides `dox-gate`. */ export const DRY_RUN_LABEL = "dox-gate-dry-run"; -/** More new issues than this in one run become the single flood issue. */ -export const FLOOD_LIMIT = 10; -/** The key of the flood issue. */ -export const FLOOD_KEY = "dox-gate:flood"; -/** The synthetic finding a dry run files. */ -export const DRY_RUN_KEY = "dry-run:synthetic:/:body"; +/** The summary row the WebKit leg adds for the `*.browser.test.ts` files; it has no structured findings. */ +export const BROWSER_TESTS_ROW = "browser-tests"; /** * Names in `.github/workflows/dox-gates-weekly.yml` that the report reads or points at. A test @@ -49,7 +53,7 @@ export const BODY_LIMIT = 65_536; export const BODY_BUDGET = 60_000; /** Rows a body or comment tables, so a sweep-wide failure cannot push a body past GitHub's limit. */ export const TABLE_ROWS = 40; -/** Example targets a flood row names. */ +/** Example targets a group row names. */ const EXAMPLES = 3; const EXAMPLE_CHARS = 100; /** Days the workflow keeps a leg's uploaded findings. */ @@ -72,12 +76,13 @@ const LOG_LINES = 10; * @typedef {{ leg: string, summary: Summary | null, job?: Job | null }} LegSummary * `summary` null: no readable `summary.json` reached the report. `job` is the leg's sweep job * from the run's job list; absent or null when that list could not be read or lacks the leg. - * @typedef {{ number: number, body: string, labels: { name: string }[] }} OpenIssue + * @typedef {{ number: number, title?: string, body: string, labels: { name: string }[] }} OpenIssue * @typedef {{ runUrl: string, sha: string, runId?: string, dryRun?: boolean }} Context - * @typedef {{ kind: "open", key: string, title: string, labels: string[], body: string } - * | { kind: "comment", key: string, issue: number, body: string }} Action - * @typedef {{ key: string, title: string, labels: string[], body: string, comment: string, - * entry?: ReturnType[number], groups?: number }} Planned + * @typedef {{ kind: "open", group: string, title: string, labels: string[], body: string } + * | { kind: "edit", group: string, issue: number, title: string, body: string } + * | { kind: "comment", group: string, issue: number, body: string } + * | { kind: "close", group: string, issue: number, body: string }} Action + * @typedef {{ title: string, section: string }} Planned */ /** Collapses every run of whitespace to one space and trims. */ @@ -95,22 +100,14 @@ export function keyOf(f) { return `${f.gate}:${f.rule}:${f.page}:${f.target}`; } -/** - * The hidden first line of a gate issue body. A key can hold `"`, `>` and `--` (an identity key - * does), none of which may sit in an HTML comment attribute unescaped, so each is written as an - * entity. The same function builds the line and the line it is matched against, so the escape never - * needs undoing. - * @param {string} key - */ -export function marker(key) { - const safe = key - .replace(/&/g, "&") - .replace(/"/g, """) - .replace(/>/g, ">") - .replace(/--/g, "--"); - return ``; +/** The first line a rolling issue's body starts with; `group` is `weekly` or `dry-run`. */ +export function rollingMarker(group) { + return ``; } +/** Start of the first line of an issue from the one-issue-per-finding shape. */ +const LEGACY_PREFIX = '`; +/** The body of the one open or edit action a failing run plans. */ +const bodyOf = (actions: any[]) => + actions.find((a) => a.kind === "open" || a.kind === "edit").body as string; + describe("planIssueActions", () => { - it("opens an issue when no open issue carries the marker", () => { - const actions = planIssueActions( - [leg("chromium-1", [failRow([finding()])])], - [], - context, - ); + it("opens one rolling issue when none is open, with the findings in sections", () => { + const actions = planIssueActions(failing, [], context) as any[]; expect(actions).toHaveLength(1); - const [a] = actions as any[]; + const [a] = actions; expect(a.kind).toBe("open"); - expect(a.title).toBe("Dox gate: color-contrast on /tools/foo/ (a11y-axe)"); + expect(a.title).toBe("Dox gates: 1 failure in 1 group"); expect(a.labels).toEqual(["dox-gate"]); expect(a.labels).not.toContain("bug"); - expect(a.body.split("\n")[0]).toBe( - marker(`a11y-axe:color-contrast:/tools/foo/:${TARGET}`), + expect(a.body.split("\n")[0]).toBe(weeklyMarker); + expect(a.body).toContain("One issue holds every finding"); + expect(a.body).toContain("Commit: abc1234"); + expect(a.body).toContain("Run: https://example.test/run/1"); + expect(a.body).toContain( + "### Dox gate: color-contrast on /tools/foo/ (a11y-axe)", ); expect(a.body).toContain( "pnpm --filter dox gates --only a11y-axe --pages /tools/foo/ --browsers chromium", ); - expect(a.body).toContain("https://example.test/run/1"); - expect(a.body).toContain("abc1234"); }); - it("comments on the lowest-numbered open issue that matches", () => { - const key = `a11y-axe:color-contrast:/tools/foo/:${TARGET}`; - const open = [ - issue(40, `${marker(key)}\nbody`), - issue(12, `${marker(key)}\nbody`), + it("titles the issue with the failures and the groups they fall in", () => { + const rows = [ + finding({ page: "/a/", target: "t1" }), + finding({ page: "/a/", target: "t2" }), + finding({ page: "/b/" }), ]; const [a] = planIssueActions( - [leg("chromium-1", [failRow([finding()])])], - open, + [leg("chromium-1", [failRow(rows)])], + [], context, ) as any[]; - expect(a).toMatchObject({ kind: "comment", issue: 12, key }); - expect(a.body).toContain( - "Still failing at abc1234: https://example.test/run/1", + expect(a.title).toBe("Dox gates: 3 failures in 2 groups"); + }); + + it("edits the lowest-numbered open rolling issue and comments with the counts", () => { + const open = [ + issue( + 40, + `${weeklyMarker}\nold`, + ["dox-gate"], + "Dox gates: 9 failures in 2 groups", + ), + issue( + 12, + `${weeklyMarker}\nold`, + ["dox-gate"], + "Dox gates: 4 failures in 1 group", + ), + ]; + const actions = planIssueActions(failing, open, context) as any[]; + expect(actions).toHaveLength(2); + expect(actions[0]).toMatchObject({ + kind: "edit", + issue: 12, + title: "Dox gates: 1 failure in 1 group", + }); + expect(actions[0].body.split("\n")[0]).toBe(weeklyMarker); + expect(actions[1]).toMatchObject({ kind: "comment", issue: 12 }); + expect(actions[1].body).toBe( + "Still failing at abc1234: https://example.test/run/1 (1 failure now, 4 before)", ); }); - it("does not match a marker on line 2, or an issue without the dox-gate label", () => { - const key = `a11y-axe:color-contrast:/tools/foo/:${TARGET}`; - expect(matches(issue(1, `intro\n${marker(key)}`), key)).toBe(false); - expect(matches(issue(1, marker(key), ["bug"]), key)).toBe(false); - expect(matches(issue(1, `${marker(key)}\nx`), key)).toBe(true); - const [a] = planIssueActions( - [leg("chromium-1", [failRow([finding()])])], - [issue(1, `intro\n${marker(key)}`)], + it("comments without a previous count when the title holds none", () => { + const [, c] = planIssueActions( + failing, + [issue(3, `${weeklyMarker}\nold`, ["dox-gate"], "renamed by hand")], context, + ) as any[]; + expect(c.body).toBe( + "Still failing at abc1234: https://example.test/run/1 (1 failure now)", ); + }); + + it("does not match a marker on line 2, or an issue without the dox-gate label", () => { + const lineTwo = issue(1, `intro\n${weeklyMarker}`); + const noLabel = issue(2, weeklyMarker, ["bug"]); + const [a] = planIssueActions(failing, [lineTwo, noLabel], context); expect(a.kind).toBe("open"); }); + it("closes the open weekly issue on a clean run", () => { + const actions = planIssueActions( + [leg("chromium-1", [])], + [issue(7, `${weeklyMarker}\nold`)], + context, + ); + expect(actions).toEqual([ + { + kind: "close", + group: "weekly", + issue: 7, + body: "Clean at abc1234: https://example.test/run/1", + }, + ]); + }); + + it("plans nothing on a clean run with nothing open", () => { + expect(planIssueActions([leg("chromium-1", [])], [], context)).toEqual([]); + }); + + it("closes a per-finding issue as folded into the rolling issue that is open", () => { + const actions = planIssueActions( + failing, + [issue(5, `${weeklyMarker}\nold`), issue(593, `${legacyKey}\nold`)], + context, + ) as any[]; + expect(actions.at(-1)).toEqual({ + kind: "close", + group: "legacy", + issue: 593, + body: "Folded into #5", + }); + }); + + it("closes a per-finding issue as folded into the rolling issue being opened", () => { + const actions = planIssueActions( + failing, + [issue(593, `${legacyKey}\nold`)], + context, + ) as any[]; + expect(actions.map((a) => a.kind)).toEqual(["open", "close"]); + expect(actions[1].body).toBe("Folded into the rolling weekly issue"); + }); + + it("closes a per-finding issue as clean on a clean run", () => { + const actions = planIssueActions( + [leg("chromium-1", [])], + [issue(593, `${legacyKey}\nold`)], + context, + ); + expect(actions).toEqual([ + { + kind: "close", + group: "legacy", + issue: 593, + body: "Clean at abc1234: https://example.test/run/1", + }, + ]); + }); + + it("leaves a dry-run per-finding issue alone", () => { + const old = issue(8, `${legacyKey}\nold`, ["dox-gate-dry-run", "dox-gate"]); + expect( + planIssueActions(failing, [old], context).map((a) => a.kind), + ).toEqual(["open"]); + }); + + describe("a dry run", () => { + const dry = { ...context, dryRun: true }; + + it("opens its own rolling issue under its own labels", () => { + const [a] = planIssueActions([leg("chromium-1", [])], [], dry) as any[]; + expect(a.kind).toBe("open"); + expect(a.title).toBe("[dry run] Dox gates: 1 failure in 1 group"); + expect(a.labels).toEqual(["dox-gate-dry-run", "dox-gate"]); + expect(a.body.split("\n")[0]).toBe(dryMarker); + expect(a.body).toContain("**Dry run.**"); + }); + + it("never touches the weekly issue, and edits its own the second time", () => { + const actions = planIssueActions( + [leg("chromium-1", [])], + [issue(9, `${dryMarker}\nold`, ["dox-gate-dry-run", "dox-gate"])], + dry, + ) as any[]; + expect(actions.map((a) => [a.kind, a.issue])).toEqual([ + ["edit", 9], + ["comment", 9], + ]); + }); + + it("does not edit a dry-run issue for a real finding, or the weekly one for the dry run", () => { + const open = [ + issue(5, `${weeklyMarker}\nold`), + issue(9, `${dryMarker}\nold`, ["dox-gate-dry-run", "dox-gate"]), + ]; + const actions = planIssueActions(failing, open, dry) as any[]; + expect(actions.map((a) => [a.kind, a.group, a.issue])).toEqual([ + ["edit", "weekly", 5], + ["comment", "weekly", 5], + ["edit", "dry-run", 9], + ["comment", "dry-run", 9], + ]); + expect(actions[0].body).not.toContain("Dry run"); + }); + + it("is never closed by a run, clean or not", () => { + const open = [ + issue(9, `${dryMarker}\nold`, ["dox-gate-dry-run", "dox-gate"]), + ]; + expect(planIssueActions([leg("chromium-1", [])], open, context)).toEqual( + [], + ); + }); + }); + it("does not file a FLAKY gate, and lists it", () => { const legs = [ leg("webkit-1", [ @@ -129,23 +285,23 @@ describe("planIssueActions", () => { ]); }); - it("files one issue for a key seen in two browsers, themes and widths", () => { - const actions = planIssueActions( - [ - leg("chromium-1", [ - failRow([finding(), finding({ width: 1440, theme: "light" })]), - ]), - leg("webkit-1", [failRow([finding({ browser: "webkit" })])]), - ], - [], - context, - ) as any[]; - expect(actions).toHaveLength(1); - expect(actions[0].body).toContain("| chromium-1 | chromium | 390 | dark |"); - expect(actions[0].body).toContain( - "| chromium-1 | chromium | 1440 | light |", + it("holds a key seen in two browsers, themes and widths in one section", () => { + const body = bodyOf( + planIssueActions( + [ + leg("chromium-1", [ + failRow([finding(), finding({ width: 1440, theme: "light" })]), + ]), + leg("webkit-1", [failRow([finding({ browser: "webkit" })])]), + ], + [], + context, + ) as any[], ); - expect(actions[0].body).toContain("| webkit-1 | webkit | 390 | dark |"); + expect(body.match(/^### /gm)).toHaveLength(1); + expect(body).toContain("| chromium-1 | chromium | 390 | dark |"); + expect(body).toContain("| chromium-1 | chromium | 1440 | light |"); + expect(body).toContain("| webkit-1 | webkit | 390 | dark |"); }); it("keys on the target and ignores the selector", () => { @@ -173,52 +329,43 @@ describe("planIssueActions", () => { ).toHaveLength(2); }); - it("escapes quotes and dashes of a selector in the marker so line 1 stays one comment", () => { - const line = marker('a:r:/:widget:x › button "Go"[2] > b -- c'); - expect(line.startsWith('')).toBe(true); - expect(line.slice(4, -3)).not.toContain("-->"); - expect(line.slice(4, -3)).not.toContain("--"); - }); - - it("files a leg with no summary as could-not-run", () => { - const [a] = planIssueActions( - [{ leg: "firefox-2", summary: null }], - [], - context, - ) as any[]; - expect(a.title).toBe("Dox weekly could not run the firefox-2 leg"); - expect(a.body.split("\n")[0]).toBe( - marker("dox-gate:could-not-run:firefox-2"), + it("has a section for a leg with no summary, as could-not-run", () => { + const body = bodyOf( + planIssueActions( + [{ leg: "firefox-2", summary: null }], + [], + context, + ) as any[], ); - expect(a.labels).toEqual(["dox-gate"]); - expect(a.body).toContain("did not say how the leg ended"); - expect(a.body).toContain("lost its upload"); + expect(body).toContain("### Dox weekly could not run the firefox-2 leg"); + expect(body).toContain("did not say how the leg ended"); + expect(body).toContain("lost its upload"); }); - it("files every leg that wrote a summary the report never got as one not-uploaded issue", () => { - const actions = planIssueActions( - [ - { leg: "chromium-1", summary: null, job: ranJob }, - { leg: "webkit-2", summary: null, job: ranJob }, - ], - [], - context, - ) as any[]; - expect(actions).toHaveLength(1); - const [a] = actions; - expect(a.kind).toBe("open"); - expect(a.title).toBe("Dox weekly: leg findings did not reach the report"); - expect(a.body.split("\n")[0]).toBe(marker(NOT_UPLOADED_KEY)); - expect(a.body).toContain(`\`${UPLOAD_STEP}\``); - expect(a.body).toContain(`\`${DOWNLOAD_STEP}\``); - expect(a.body).toContain("| chromium-1 | chromium |"); - expect(a.body).toContain("| webkit-2 | webkit |"); - expect(a.body).not.toContain("Reproduce"); - expect(a.body).not.toContain("could not run"); + it("has one not-uploaded section for every leg that wrote a summary the report never got", () => { + const body = bodyOf( + planIssueActions( + [ + { leg: "chromium-1", summary: null, job: ranJob }, + { leg: "webkit-2", summary: null, job: ranJob }, + ], + [], + context, + ) as any[], + ); + expect(body.match(/^### /gm)).toHaveLength(1); + expect(body).toContain( + "### Dox weekly: leg findings did not reach the report", + ); + expect(body).toContain(`\`${UPLOAD_STEP}\``); + expect(body).toContain(`\`${DOWNLOAD_STEP}\``); + expect(body).toContain("| chromium-1 | chromium |"); + expect(body).toContain("| webkit-2 | webkit |"); + expect(body).not.toContain("Reproduce"); + expect(body).not.toContain("could not run"); }); - it("does not flood when all twelve legs lost their upload", () => { + it("stays one action when all twelve legs lost their upload", () => { const legs = ["chromium", "webkit", "firefox"].flatMap((b) => [1, 2, 3, 4].map((i) => ({ leg: `${b}-${i}`, @@ -226,11 +373,10 @@ describe("planIssueActions", () => { job: ranJob, })), ); - const actions = planIssueActions(legs, [], context) as any[]; - expect(actions.map((a) => a.key)).toEqual([NOT_UPLOADED_KEY]); + expect(planIssueActions(legs, [], context)).toHaveLength(1); }); - it("files a leg whose runner wrote no summary as could-not-run, naming the first step that did not succeed", () => { + it("names the first step that did not succeed in a could-not-run section", () => { const crashed = job("failure", [ ["Install chromium", "success"], [GATES, "failure"], @@ -238,19 +384,18 @@ describe("planIssueActions", () => { [UPLOAD_STEP, "success"], ["Post Run actions/checkout@v7", "skipped"], ]); - const [a] = planIssueActions( - [{ leg: "chromium-1", summary: null, job: crashed }], - [], - context, - ) as any[]; - expect(a.body.split("\n")[0]).toBe( - marker("dox-gate:could-not-run:chromium-1"), + const body = bodyOf( + planIssueActions( + [{ leg: "chromium-1", summary: null, job: crashed }], + [], + context, + ) as any[], ); - expect(a.title).toBe("Dox weekly could not run the chromium-1 leg"); - expect(a.body).toContain("wrote no summary.json"); - expect(a.body).toContain("Its job ended `failure`"); - expect(a.body).toContain(`\`${GATES}\` (\`failure\`)`); - expect(a.body).not.toContain("lost its upload"); + expect(body).toContain("### Dox weekly could not run the chromium-1 leg"); + expect(body).toContain("wrote no summary.json"); + expect(body).toContain("Its job ended `failure`"); + expect(body).toContain(`\`${GATES}\` (\`failure\`)`); + expect(body).not.toContain("lost its upload"); }); it("names a cancelled gates step and an install that failed before the gates", () => { @@ -263,32 +408,34 @@ describe("planIssueActions", () => { [GATES, "skipped"], [SUMMARY_STEP, "failure"], ]); - const actions = planIssueActions( - [ - { leg: "firefox-1", summary: null, job: cancelled }, - { leg: "webkit-1", summary: null, job: install }, - ], - [], - context, - ) as any[]; - const body = (leg: string) => - actions.find((a) => a.key === `dox-gate:could-not-run:${leg}`).body; - expect(body("firefox-1")).toContain( + const body = bodyOf( + planIssueActions( + [ + { leg: "firefox-1", summary: null, job: cancelled }, + { leg: "webkit-1", summary: null, job: install }, + ], + [], + context, + ) as any[], + ); + expect(body).toContain( `Its job ended \`cancelled\`; the first step that did not succeed is \`${GATES}\` (\`cancelled\`)`, ); - expect(body("webkit-1")).toContain( + expect(body).toContain( "the first step that did not succeed is `Install webkit` (`failure`)", ); }); - it("files a job that never started a step as could-not-run", () => { - const [a] = planIssueActions( - [{ leg: "webkit-3", summary: null, job: job("cancelled", []) }], - [], - context, - ) as any[]; - expect(a.key).toBe("dox-gate:could-not-run:webkit-3"); - expect(a.body).toContain("Its job ended `cancelled`."); + it("has a could-not-run section for a job that never started a step", () => { + const body = bodyOf( + planIssueActions( + [{ leg: "webkit-3", summary: null, job: job("cancelled", []) }], + [], + context, + ) as any[], + ); + expect(body).toContain("### Dox weekly could not run the webkit-3 leg"); + expect(body).toContain("Its job ended `cancelled`."); }); it("ignores the job of a leg that has a summary", () => { @@ -302,7 +449,7 @@ describe("planIssueActions", () => { ).toEqual([]); }); - it("files a FAIL with no structured findings as unstructured, quoting the log tail", () => { + it("has an unstructured section for a FAIL with no findings, quoting the log tail", () => { const row = { id: "data-credits-check", status: "FAIL", @@ -310,21 +457,37 @@ describe("planIssueActions", () => { findings: [], logTail: ["boom", "at x"], }; - const [a] = planIssueActions( - [leg("chromium-2", [row])], - [], - context, - ) as any[]; - expect(a.body.split("\n")[0]).toBe( - marker("data-credits-check:unstructured:all:"), + const body = bodyOf( + planIssueActions([leg("chromium-2", [row])], [], context) as any[], ); - expect(a.body).toContain("timed out after 90m"); - expect(a.body).toContain("boom\nat x"); - expect(a.body).toContain( + expect(body).toContain( + "### Dox gate: unstructured on all (data-credits-check)", + ); + expect(body).toContain("timed out after 90m"); + expect(body).toContain("boom\nat x"); + expect(body).toContain( "pnpm --filter dox gates --only data-credits-check --browsers chromium", ); }); + it("titles a failing browser-tests row and reproduces it with the browser config", () => { + const row = { + id: BROWSER_TESTS_ROW, + status: "FAIL", + detail: "*.browser.test.ts in WebKit", + logTail: ["FAIL x.browser.test.ts > a thing"], + }; + const body = bodyOf( + planIssueActions([leg("webkit-1", [row])], [], context) as any[], + ); + expect(body).toContain("### Browser tests fail in WebKit"); + expect(body).toContain("FAIL x.browser.test.ts > a thing"); + expect(body).toContain( + "DOX_BROWSERS=webkit pnpm --filter dox exec vitest run --config vitest.browser.config.ts", + ); + expect(body).not.toContain("gates --only browser-tests"); + }); + describe("a leg that reached its deadline", () => { const outOfTime = (findings: unknown[] = []) => ({ leg: "webkit-2", @@ -353,103 +516,40 @@ describe("planIssueActions", () => { } as any, }); - it("files one out-of-time issue that tables every gate's minutes", () => { - const actions = planIssueActions([outOfTime()], [], context) as any[]; - expect(actions).toHaveLength(1); - const [a] = actions; - expect(a.title).toBe("Dox weekly: the webkit-2 leg ran out of time"); - expect(a.body.split("\n")[0]).toBe( - marker("dox-gate:out-of-time:webkit-2"), + it("has one out-of-time section that tables every gate's minutes", () => { + const body = bodyOf( + planIssueActions([outOfTime()], [], context) as any[], + ); + expect(body.match(/^### /gm)).toHaveLength(1); + expect(body).toContain( + "### Dox weekly: the webkit-2 leg ran out of time", ); - expect(a.body).toContain("its 80-minute deadline"); - expect(a.body).toContain("| data-credits-check | PASS | 60 | |"); - expect(a.body).toContain( + expect(body).toContain("its 80-minute deadline"); + expect(body).toContain("| data-credits-check | PASS | 60 | |"); + expect(body).toContain( "| rendered-links | FAIL | 6 | stopped at the 80m deadline |", ); - expect(a.body).toContain( + expect(body).toContain( "| a11y-axe | FAIL | - | not run: the 80m deadline had passed |", ); - expect(a.body).not.toContain("Reproduce:"); + expect(body).not.toContain("Reproduce:"); }); - it("still files the structured findings the stopped gate reached", () => { + it("still has the structured findings the stopped gate reached", () => { const f = finding({ gate: "rendered-links", rule: "missing-link" }); - const keys = ( - planIssueActions([outOfTime([f])], [], context) as any[] - ).map((a) => a.key); - expect(keys).toEqual(["dox-gate:out-of-time:webkit-2", keyOf(f)]); - }); - }); - - it("opens ten new issues and floods at eleven", () => { - const many = (n: number) => - leg("chromium-1", [ - failRow( - Array.from({ length: n }, (_, i) => finding({ page: `/p${i}/` })), - ), - ]); - expect( - planIssueActions([many(10)], [], context).every((a) => a.kind === "open"), - ).toBe(true); - expect(planIssueActions([many(10)], [], context)).toHaveLength(10); - - const flood = planIssueActions([many(11)], [], context) as any[]; - expect(flood).toHaveLength(1); - expect(flood[0].kind).toBe("open"); - expect(flood[0].body.split("\n")[0]).toBe(marker(FLOOD_KEY)); - expect(flood[0].body).toContain("a11y-axe:color-contrast:/p10/"); - expect(flood[0].body).toContain("/p0/"); - }); - - it("comments on the existing flood issue and still comments on matched findings", () => { - const rows = Array.from({ length: 12 }, (_, i) => - finding({ page: `/p${i}/` }), - ); - const known = `a11y-axe:color-contrast:/p0/:${TARGET}`; - const actions = planIssueActions( - [leg("chromium-1", [failRow(rows)])], - [issue(3, marker(FLOOD_KEY)), issue(4, marker(known))], - context, - ) as any[]; - expect(actions.map((a) => [a.kind, a.issue])).toEqual( - expect.arrayContaining([ - ["comment", 3], - ["comment", 4], - ]), - ); - expect(actions.filter((a) => a.kind === "open")).toHaveLength(0); - }); - - it("adds one synthetic dry-run finding under its own label", () => { - const [a] = planIssueActions([], [], { ...context, dryRun: true }) as any[]; - expect(a.kind).toBe("open"); - expect(a.title.startsWith("[dry run] ")).toBe(true); - expect(a.labels).toEqual(["dox-gate-dry-run", "dox-gate"]); - expect(a.labels).not.toContain("bug"); - expect(a.body.split("\n")[0]).toBe(marker(DRY_RUN_KEY)); - }); - - it("comments on the dry-run issue the second time", () => { - const [a] = planIssueActions([], [issue(9, marker(DRY_RUN_KEY))], { - ...context, - dryRun: true, - }) as any[]; - expect(a).toMatchObject({ kind: "comment", issue: 9 }); - }); - - it("does not count the dry-run finding towards the flood guard", () => { - const rows = Array.from({ length: 10 }, (_, i) => - finding({ page: `/p${i}/` }), - ); - const actions = planIssueActions([leg("chromium-1", [failRow(rows)])], [], { - ...context, - dryRun: true, + const body = bodyOf( + planIssueActions([outOfTime([f])], [], context) as any[], + ); + expect(body).toContain( + "### Dox weekly: the webkit-2 leg ran out of time", + ); + expect(body).toContain( + "### Dox gate: missing-link on /tools/foo/ (rendered-links)", + ); }); - expect(actions).toHaveLength(11); - expect(actions.every((a) => a.kind === "open")).toBe(true); }); - describe("the flood issue", () => { + describe("a sweep-wide failure", () => { /** 2,000 findings over 40 pages, 10 rules x 5 targets each, seen in three browsers. */ const synthetic = () => { const rows: unknown[] = []; @@ -475,26 +575,26 @@ describe("planIssueActions", () => { ); }; - it("is one action whose body and comment stay under the limit", () => { + it("stays one issue and one comment, each under the limit", () => { const legs = synthetic(); const ctx = { ...context, runId: "999" }; - const [a] = planIssueActions(legs, [], ctx) as any[]; - expect(planIssueActions(legs, [], ctx)).toHaveLength(1); - expect(a.body.split("\n")[0]).toBe(marker(FLOOD_KEY)); - expect(a.body.length).toBeLessThan(BODY_LIMIT); - const [c] = planIssueActions( + const actions = planIssueActions(legs, [], ctx) as any[]; + expect(actions).toHaveLength(1); + expect(actions[0].body.split("\n")[0]).toBe(weeklyMarker); + expect(actions[0].body.length).toBeLessThan(BODY_LIMIT); + const again = planIssueActions( legs, - [issue(5, marker(FLOOD_KEY))], + [issue(5, weeklyMarker)], ctx, ) as any[]; - expect(c.kind).toBe("comment"); - expect(c.body.length).toBeLessThan(BODY_LIMIT); + expect(again.map((a) => a.kind)).toEqual(["edit", "comment"]); + for (const a of again) expect(a.body.length).toBeLessThan(BODY_LIMIT); + expect(again[0].title).toBe("Dox gates: 2000 failures in 400 groups"); }); it("groups by gate, rule and page with counts, browsers, widths and three targets", () => { - const [a] = planIssueActions(synthetic(), [], context) as any[]; - expect(a.groups).toBe(400); - const row = a.body + const body = bodyOf(planIssueActions(synthetic(), [], context) as any[]); + const row = body .split("\n") .find((l: string) => l.includes("a11y-axe:rule-0:/tools/p0/")); expect(row).toBeDefined(); @@ -502,50 +602,59 @@ describe("planIssueActions", () => { expect(row).toContain("| 5 |"); expect(row).toContain("chromium, firefox, webkit"); expect(row).toContain("300, 301, 302"); - expect(row.match(/target 0 \d+/g)).toHaveLength(3); + expect(row!.match(/target 0 \d+/g)).toHaveLength(3); }); - it("sorts rows by count, largest first, and names the run's artifacts", () => { - const rows = [ - ...Array.from({ length: 3 }, (_, i) => - finding({ page: "/small/", target: `t${i}` }), - ), - ...Array.from({ length: 9 }, (_, i) => - finding({ page: "/big/", target: `t${i}` }), - ), - ]; - const [a] = planIssueActions( - [leg("chromium-1", [failRow(rows)]), leg("webkit-2", [])], - [], - { ...context, runId: "4242" }, - ) as any[]; - expect(a.body.indexOf("/big/")).toBeLessThan(a.body.indexOf("/small/")); - expect(a.body).toContain("dox-gates-chromium-1-4242"); - expect(a.body).toContain("dox-gates-webkit-2-4242"); - expect(a.body).toContain("14 days"); - expect(a.body).toContain(context.runUrl); - expect(a.body).toContain( - "Each run comments here until ten or fewer remain", + it("keeps the table whole and cuts the sections", () => { + const body = bodyOf(planIssueActions(synthetic(), [], context) as any[]); + const rows = body + .split("\n") + .filter((l: string) => l.startsWith("| `a11y-axe:rule-")); + expect(rows).toHaveLength(TABLE_ROWS); + expect(body).toContain("360 more groups"); + expect(body).toMatch( + /\n… \d+ more lines; full list in the run's artifacts\.$/, ); - expect(a.body).not.toContain("the next run files whichever still fail"); }); + }); - it("shows TABLE_ROWS rows and counts the groups it left out", () => { - const rows = Array.from({ length: 45 }, (_, i) => - finding({ page: `/g${i}/` }), - ); - const [a] = planIssueActions( - [leg("chromium-1", [failRow(rows)])], + it("sorts the table by count, largest first, and names the run's artifacts", () => { + const rows = [ + ...Array.from({ length: 3 }, (_, i) => + finding({ page: "/small/", target: `t${i}` }), + ), + ...Array.from({ length: 9 }, (_, i) => + finding({ page: "/big/", target: `t${i}` }), + ), + ]; + const body = bodyOf( + planIssueActions( + [leg("chromium-1", [failRow(rows)]), leg("webkit-2", [])], [], - context, - ) as any[]; - expect(a.groups).toBe(45); - const shown = a.body - .split("\n") - .filter((l: string) => l.includes("a11y-axe:color-contrast:/g")); - expect(shown).toHaveLength(TABLE_ROWS); - expect(a.body).toContain("5 more groups"); - }); + { ...context, runId: "4242" }, + ) as any[], + ); + expect(body.indexOf("/big/")).toBeLessThan(body.indexOf("/small/")); + expect(body).toContain("dox-gates-chromium-1-4242"); + expect(body).toContain("dox-gates-webkit-2-4242"); + expect(body).toContain("14 days"); + }); + + it("shows TABLE_ROWS rows and counts the groups it left out", () => { + const rows = Array.from({ length: 45 }, (_, i) => + finding({ page: `/g${i}/` }), + ); + const [a] = planIssueActions( + [leg("chromium-1", [failRow(rows)])], + [], + context, + ) as any[]; + expect(a.title).toBe("Dox gates: 45 failures in 45 groups"); + const shown = a.body + .split("\n") + .filter((l: string) => l.startsWith("| `a11y-axe:color-contrast:/g")); + expect(shown).toHaveLength(TABLE_ROWS); + expect(a.body).toContain("5 more groups"); }); }); diff --git a/apps/dox/scripts/gtfs-service-day-clock-holds.browser.test.ts b/apps/dox/scripts/gtfs-service-day-clock-holds.browser.test.ts index 39567760..e4557b0d 100644 --- a/apps/dox/scripts/gtfs-service-day-clock-holds.browser.test.ts +++ b/apps/dox/scripts/gtfs-service-day-clock-holds.browser.test.ts @@ -1,13 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserType, - type Page, -} from "@playwright/test"; +import { type Browser, type Page } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -25,10 +20,7 @@ import { serveStatic } from "./lib/static-server.mjs"; const dist = distDirOrSkip(); const EPSILON = 0.5; const WIDTHS = [300, 390, 1280, 1440]; -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); /** Two typed refusals, run after every preset. */ const REFUSALS: [string, string, string][] = [ diff --git a/apps/dox/scripts/gtfs-time-reader-holds.browser.test.ts b/apps/dox/scripts/gtfs-time-reader-holds.browser.test.ts index 59a244e9..0e6e8880 100644 --- a/apps/dox/scripts/gtfs-time-reader-holds.browser.test.ts +++ b/apps/dox/scripts/gtfs-time-reader-holds.browser.test.ts @@ -1,13 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserType, - type Page, -} from "@playwright/test"; +import { type Browser, type Page } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -26,10 +21,7 @@ import { serveStatic } from "./lib/static-server.mjs"; const dist = distDirOrSkip(); const EPSILON = 0.5; const WIDTHS = [300, 390, 1280, 1440]; -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); /** The boxes the reader must never see change: holds (call frames sit in them), strips. */ const GATES = [ "hold", diff --git a/apps/dox/scripts/gtfs-trip-board-holds.browser.test.ts b/apps/dox/scripts/gtfs-trip-board-holds.browser.test.ts index d24fed1d..d751a6ba 100644 --- a/apps/dox/scripts/gtfs-trip-board-holds.browser.test.ts +++ b/apps/dox/scripts/gtfs-trip-board-holds.browser.test.ts @@ -1,13 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserType, - type Page, -} from "@playwright/test"; +import { type Browser, type Page } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -24,10 +19,7 @@ import { serveStatic } from "./lib/static-server.mjs"; const dist = distDirOrSkip(); const EPSILON = 0.5; const WIDTHS = [300, 390, 1280, 1440]; -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); /** The widest zone name the IANA database holds: its readings are the widest a box ever shows. */ const WIDEST_ZONE = "America/Argentina/Buenos_Aires"; diff --git a/apps/dox/scripts/industry-tags-popover.browser.test.ts b/apps/dox/scripts/industry-tags-popover.browser.test.ts index 95eca399..2cf78f50 100644 --- a/apps/dox/scripts/industry-tags-popover.browser.test.ts +++ b/apps/dox/scripts/industry-tags-popover.browser.test.ts @@ -1,13 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserType, - type Page, -} from "@playwright/test"; +import { type Browser, type Page } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -21,10 +16,7 @@ const dist = distDirOrSkip(); const GUTTER = 16; const NARROW = 375; const WIDE = [1280, 1440, 1910]; -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); let server: Server | undefined; diff --git a/apps/dox/scripts/lib/browser-launch.mjs b/apps/dox/scripts/lib/browser-launch.mjs index bddbb379..d0f4ee2e 100644 --- a/apps/dox/scripts/lib/browser-launch.mjs +++ b/apps/dox/scripts/lib/browser-launch.mjs @@ -26,6 +26,42 @@ const ENGINES = { chromium, firefox, webkit }; */ export const tabKey = (name) => (name === "webkit" ? "Alt+Tab" : "Tab"); +/** + * The engines a `*.browser.test.ts` file runs in, from `DOX_BROWSERS` (comma-separated), or + * Chromium alone when it is unset or empty. Every PR runs Chromium (`ci.yml`); WebKit runs once a + * week (`dox-gates-weekly.yml`). + * + * @param {NodeJS.ProcessEnv} [env] + * @returns {["chromium" | "firefox" | "webkit", import("@playwright/test").BrowserType][]} + */ +export function testEngines(env = process.env) { + const names = (env.DOX_BROWSERS?.trim() || "chromium") + .split(",") + .map((name) => name.trim()) + .filter((name) => name !== ""); + return names.map((name) => { + if (!Object.hasOwn(ENGINES, name)) { + throw new Error( + `DOX_BROWSERS names "${name}": chromium, firefox and webkit run here.`, + ); + } + return [ + /** @type {"chromium" | "firefox" | "webkit"} */ (name), + ENGINES[/** @type {keyof typeof ENGINES} */ (name)], + ]; + }); +} + +/** + * Whether `DOX_BROWSERS` runs `name`, for a file only one engine can run: it skips on a leg that + * leaves that engine out, which has not installed it. + * + * @param {"chromium" | "firefox" | "webkit"} name + * @param {NodeJS.ProcessEnv} [env] + */ +export const testsRunIn = (name, env = process.env) => + testEngines(env).some(([engine]) => engine === name); + /** Playwright's `exposeNetwork` keyword for localhost, `*.localhost`, 127.0.0.1 and [::1]. */ const LOOPBACK = ""; diff --git a/apps/dox/scripts/lib/browser-launch.test.ts b/apps/dox/scripts/lib/browser-launch.test.ts index 192da941..790fe343 100644 --- a/apps/dox/scripts/lib/browser-launch.test.ts +++ b/apps/dox/scripts/lib/browser-launch.test.ts @@ -1,4 +1,10 @@ -import { firefoxEndpoint, launchBrowser, tabKey } from "./browser-launch.mjs"; +import { + firefoxEndpoint, + launchBrowser, + tabKey, + testEngines, + testsRunIn, +} from "./browser-launch.mjs"; const LOOPBACK = ""; @@ -134,3 +140,36 @@ describe("tabKey", () => { expect(tabKey("firefox")).toBe("Tab"); }); }); + +describe("testEngines", () => { + it("runs Chromium alone when DOX_BROWSERS is unset or empty", () => { + expect(testEngines({}).map(([name]) => name)).toEqual(["chromium"]); + expect(testEngines({ DOX_BROWSERS: " " }).map(([name]) => name)).toEqual([ + "chromium", + ]); + }); + + it("runs the engines DOX_BROWSERS names, in its order", () => { + const engines = testEngines({ DOX_BROWSERS: " webkit , chromium " }); + expect(engines.map(([name]) => name)).toEqual(["webkit", "chromium"]); + expect(engines.every(([, type]) => typeof type.launch === "function")).toBe( + true, + ); + }); + + it("throws on an unknown engine, naming the three", () => { + expect(() => testEngines({ DOX_BROWSERS: "safari" })).toThrow( + 'DOX_BROWSERS names "safari": chromium, firefox and webkit run here.', + ); + }); +}); + +describe("testsRunIn", () => { + it("is true for Chromium when DOX_BROWSERS is unset, and false once it names WebKit alone", () => { + expect(testsRunIn("chromium", {})).toBe(true); + expect(testsRunIn("chromium", { DOX_BROWSERS: "webkit" })).toBe(false); + expect(testsRunIn("webkit", { DOX_BROWSERS: "chromium,webkit" })).toBe( + true, + ); + }); +}); diff --git a/apps/dox/scripts/lib/element-identity.mjs b/apps/dox/scripts/lib/element-identity.mjs index 9f2b499e..8dadd9a0 100644 --- a/apps/dox/scripts/lib/element-identity.mjs +++ b/apps/dox/scripts/lib/element-identity.mjs @@ -5,7 +5,8 @@ * The key is `scope › role "name"`, plus `[n]` only on repeats. It reads what a reader or a * screen reader reads (the widget, the role, the accessible name), never an id, a class, an * `nth-*` position or a tag name outside the role table. So a sibling insert, a React `useId` - * change or a class rename does not move it, and the weekly sweep keeps one issue per finding. + * change or a class rename does not move it, and the weekly sweep's rolling issue keeps one + * section per finding. * * The name is an author-written one (`aria-label`, a label, a fieldset's legend, a table's * caption, a figure's figcaption, `alt`, `title`), or the text of a role that ARIA names from diff --git a/apps/dox/scripts/ptp-clock-converter-holds.browser.test.ts b/apps/dox/scripts/ptp-clock-converter-holds.browser.test.ts index 2f2eb863..9c25d850 100644 --- a/apps/dox/scripts/ptp-clock-converter-holds.browser.test.ts +++ b/apps/dox/scripts/ptp-clock-converter-holds.browser.test.ts @@ -1,13 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserType, - type Page, -} from "@playwright/test"; +import { type Browser, type Page } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { READ_PRESETS, WRITE_PRESETS } from "../src/lib/ptp-clock-presets"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -32,10 +27,7 @@ import { serveStatic } from "./lib/static-server.mjs"; const dist = distDirOrSkip(); const EPSILON = 0.5; const WIDTHS = [300, 390, 1280, 1440]; -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); /** The boxes the reader must never see change: holds (call frames sit in them), strips. */ const GATES = [ "hold", diff --git a/apps/dox/scripts/sound-peaks.browser.test.ts b/apps/dox/scripts/sound-peaks.browser.test.ts index a84930c7..5c08d651 100644 --- a/apps/dox/scripts/sound-peaks.browser.test.ts +++ b/apps/dox/scripts/sound-peaks.browser.test.ts @@ -1,6 +1,7 @@ import { resolve } from "node:path"; import { chromium, type Browser, type Page } from "@playwright/test"; import { build } from "esbuild"; +import { testsRunIn } from "./lib/browser-launch.mjs"; /** * Hearing safety for the press, zoom and arrival cues (DOX-G11). Each voice renders offline in @@ -49,7 +50,11 @@ const CASE_TIMEOUT_MS = 30_000; let browser: Browser; let page: Page; +/** Chromium renders these; a leg that runs only another engine skips them. */ +const inChromium = testsRunIn("chromium"); + beforeAll(async () => { + if (!inChromium) return; const { outputFiles } = await build({ stdin: { contents: ` @@ -90,22 +95,25 @@ afterAll(async () => { await browser?.close(); }); -describe("the ported cues play no louder than their audition sounds", () => { - it.each(CASES)( - "$cue at $rank, $sound, peaks at $peak or under", - async ({ cue, rank, peak }) => { - const loudest = await page.evaluate( - ([name, at, seeds]) => - ( - window as unknown as { - peakOf: (n: string, r: number, s: number) => Promise; - } - ).peakOf(name, at, seeds), - [cue, rank, SEEDS] as const, - ); - expect(loudest).toBeGreaterThan(0); - expect(loudest).toBeLessThanOrEqual(peak); - }, - CASE_TIMEOUT_MS, - ); -}); +describe.skipIf(!inChromium)( + "the ported cues play no louder than their audition sounds", + () => { + it.each(CASES)( + "$cue at $rank, $sound, peaks at $peak or under", + async ({ cue, rank, peak }) => { + const loudest = await page.evaluate( + ([name, at, seeds]) => + ( + window as unknown as { + peakOf: (n: string, r: number, s: number) => Promise; + } + ).peakOf(name, at, seeds), + [cue, rank, SEEDS] as const, + ); + expect(loudest).toBeGreaterThan(0); + expect(loudest).toBeLessThanOrEqual(peak); + }, + CASE_TIMEOUT_MS, + ); + }, +); diff --git a/apps/dox/scripts/sunshine-protection-act-holds.browser.test.ts b/apps/dox/scripts/sunshine-protection-act-holds.browser.test.ts index e53300b4..42c2741e 100644 --- a/apps/dox/scripts/sunshine-protection-act-holds.browser.test.ts +++ b/apps/dox/scripts/sunshine-protection-act-holds.browser.test.ts @@ -5,7 +5,7 @@ import { type Browser, type Page } from "@playwright/test"; import { STATES as STATES_DATA } from "../src/data/sunshine-protection-act-proposals"; import stateNames from "../src/lib/us-state-names.json"; import { computeSunshineActZones } from "../worker/sunshine-protection-act"; -import { launchBrowser } from "./lib/browser-launch.mjs"; +import { launchBrowser, testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -24,8 +24,7 @@ import { serveStatic } from "./lib/static-server.mjs"; const dist = distDirOrSkip(); const EPSILON = 0.5; const WIDTHS = [375, 1024, 1440]; -/** The engines the CI browser job installs; Firefox runs in the weekly sweep, not here. */ -const ENGINES: ["chromium" | "webkit"][] = [["chromium"], ["webkit"]]; +const ENGINES = testEngines(); /** What must hold: the section, the map's frame, the list card, the pin panel and its cells, the legend. */ const HELD = "[data-gate~='us-section'], [data-gate~='map-frame'], [data-gate~='pickcard'], [data-gate~='us-pin'], [data-gate~='us-pin-cell'], ul[aria-label='Map classes']"; @@ -699,6 +698,8 @@ describe.each(ENGINES)("Sunshine Protection Act holds in %s", (name) => { await settle(page); } await drawn(page); + // The drawing fades in on arrival: press its frames at rest, where they are measured. + await page.waitForFunction(() => document.getAnimations().length === 0); const frames = await page.evaluate(() => { const root = document.querySelector( "[data-widget='sunshine-protection-act']", diff --git a/apps/dox/scripts/swift-value-date-reader-holds.browser.test.ts b/apps/dox/scripts/swift-value-date-reader-holds.browser.test.ts index a3475a3a..9bc1eb88 100644 --- a/apps/dox/scripts/swift-value-date-reader-holds.browser.test.ts +++ b/apps/dox/scripts/swift-value-date-reader-holds.browser.test.ts @@ -1,13 +1,8 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserType, - type Page, -} from "@playwright/test"; +import { type Browser, type Page } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -26,10 +21,7 @@ import { serveStatic } from "./lib/static-server.mjs"; const dist = distDirOrSkip(); const EPSILON = 0.5; const WIDTHS = [300, 390, 1280, 1440]; -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); /** The boxes the reader must never see change: holds (call frames sit in them), strips, the band table. */ const GATES = ["hold", "plates", "write-plates", "grid", "chip"]; diff --git a/apps/dox/scripts/webmcp.browser.test.ts b/apps/dox/scripts/webmcp.browser.test.ts index 643bb9b5..3fef7bf6 100644 --- a/apps/dox/scripts/webmcp.browser.test.ts +++ b/apps/dox/scripts/webmcp.browser.test.ts @@ -2,14 +2,8 @@ import { readdirSync } from "node:fs"; import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import { join, resolve } from "node:path"; -import { - chromium, - webkit, - type Browser, - type BrowserContext, - type BrowserType, - type Page, -} from "@playwright/test"; +import { type Browser, type BrowserContext, type Page } from "@playwright/test"; +import { testEngines } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; import type { PageToolDef } from "../src/lib/webmcp/page-tool"; @@ -28,10 +22,7 @@ import type { PageToolDef } from "../src/lib/webmcp/page-tool"; */ const dist = distDirOrSkip(); -const ENGINES: [string, BrowserType][] = [ - ["chromium", chromium], - ["webkit", webkit], -]; +const ENGINES = testEngines(); /** The folders of `dist/gmt/tools`, minus none: the index page is a folder too and is skipped. */ const SLUGS = diff --git a/apps/dox/scripts/zone-map-forced-colors.browser.test.ts b/apps/dox/scripts/zone-map-forced-colors.browser.test.ts index 38a73396..0eb837b5 100644 --- a/apps/dox/scripts/zone-map-forced-colors.browser.test.ts +++ b/apps/dox/scripts/zone-map-forced-colors.browser.test.ts @@ -5,7 +5,7 @@ import { type Browser, type Page } from "@playwright/test"; import { handleCanadaClockChange } from "../worker/canada-clock-change"; import { handleMoroccoClockChange } from "../worker/morocco-clock-change"; import { handleSunshineProtectionAct } from "../worker/sunshine-protection-act"; -import { launchBrowser } from "./lib/browser-launch.mjs"; +import { launchBrowser, testsRunIn } from "./lib/browser-launch.mjs"; import { distDirOrSkip } from "./dist-dir"; import { serveStatic } from "./lib/static-server.mjs"; @@ -18,6 +18,7 @@ import { serveStatic } from "./lib/static-server.mjs"; */ const dist = distDirOrSkip(); +const inChromium = testsRunIn("chromium"); type Mark = | "solid" @@ -54,7 +55,7 @@ let server: Server | undefined; let browser: Browser | undefined; beforeAll(async () => { - if (dist === null) return; + if (dist === null || !inChromium) return; server = (await serveStatic(resolve(dist), 0)) as Server; browser = (await launchBrowser("chromium")) as Browser; }); @@ -285,59 +286,63 @@ function expectSwatch(swatch: Swatch) { } } -describe.each(SCHEMES)("Clock-change maps in forced colours, %s", (scheme) => { - it.each(PAGES)( - "%s: each shape wears its swatch's mark, in system colours only", - async (_name, path, view) => { - if (browser === undefined || server === undefined) return; - const base = `http://127.0.0.1:${(server.address() as AddressInfo).port}/gmt`; - const page = await browser.newPage({ - viewport: { width: 1440, height: 900 }, - forcedColors: "active", - colorScheme: scheme, - }); - try { - await answerChecks(page); - await page.goto(`${base}${path}`); - await drawn(page); - if (view !== null) { - await page.getByRole("radio", { name: view }).check(); +describe.skipIf(!inChromium).each(SCHEMES)( + "Clock-change maps in forced colours, %s", + (scheme) => { + it.each(PAGES)( + "%s: each shape wears its swatch's mark, in system colours only", + async (_name, path, view) => { + if (browser === undefined || server === undefined) return; + const base = `http://127.0.0.1:${(server.address() as AddressInfo).port}/gmt`; + const page = await browser.newPage({ + viewport: { width: 1440, height: 900 }, + forcedColors: "active", + colorScheme: scheme, + }); + try { + await answerChecks(page); + await page.goto(`${base}${path}`); await drawn(page); - await page.waitForFunction( - (selector) => - [...document.querySelectorAll(selector)].some( - (el) => - el.closest("[hidden]") === null && - (el as SVGElement).dataset["kind"] === "daylight-if-allowed", - ), - SHAPE, - ); - } - const { shapes, others, swatches } = await read(page); - expect(shapes.length).toBeGreaterThan(0); - expect(swatches.length).toBeGreaterThan(0); - for (const shape of shapes) expectShape(shape); - for (const mark of others) { - expect( - isSystem(mark.fill, mark.system), - `${mark.name} fill ${mark.fill}`, - ).toBe(true); - expect( - isSystem(mark.stroke, mark.system), - `${mark.name} stroke ${mark.stroke}`, - ).toBe(true); + if (view !== null) { + await page.getByRole("radio", { name: view }).check(); + await drawn(page); + await page.waitForFunction( + (selector) => + [...document.querySelectorAll(selector)].some( + (el) => + el.closest("[hidden]") === null && + (el as SVGElement).dataset["kind"] === + "daylight-if-allowed", + ), + SHAPE, + ); + } + const { shapes, others, swatches } = await read(page); + expect(shapes.length).toBeGreaterThan(0); + expect(swatches.length).toBeGreaterThan(0); + for (const shape of shapes) expectShape(shape); + for (const mark of others) { + expect( + isSystem(mark.fill, mark.system), + `${mark.name} fill ${mark.fill}`, + ).toBe(true); + expect( + isSystem(mark.stroke, mark.system), + `${mark.name} stroke ${mark.stroke}`, + ).toBe(true); + } + // Every class drawn on the map has a swatch, and each swatch matches its class. + const kinds = new Set(shapes.map((shape) => shape.kind)); + for (const swatch of swatches) { + kinds.delete(swatch.kind); + expectSwatch(swatch); + } + expect([...kinds], "classes on the map with no swatch").toEqual([]); + } finally { + await page.close(); } - // Every class drawn on the map has a swatch, and each swatch matches its class. - const kinds = new Set(shapes.map((shape) => shape.kind)); - for (const swatch of swatches) { - kinds.delete(swatch.kind); - expectSwatch(swatch); - } - expect([...kinds], "classes on the map with no swatch").toEqual([]); - } finally { - await page.close(); - } - }, - 60_000, - ); -}); + }, + 60_000, + ); + }, +); diff --git a/apps/dox/vitest.browser.config.ts b/apps/dox/vitest.browser.config.ts index 992549bf..e86a4cf8 100644 --- a/apps/dox/vitest.browser.config.ts +++ b/apps/dox/vitest.browser.config.ts @@ -4,8 +4,8 @@ import { BROWSER_TEST_GLOB } from "./src/test/isolation.ts"; /** * The tests that launch a real browser (`*.browser.test.ts`). The default run leaves them out: the - * Tests job installs no browser. The `dox-tables` check runs them in Chromium and WebKit, against - * the built site. + * Tests job installs no browser. The `dox-tables` check runs them in Chromium, against the built + * site; `DOX_BROWSERS` (`scripts/lib/browser-launch.mjs`) names other engines. */ export default defineConfig({ resolve: { diff --git a/context/dox/built/tier-2-runner-and-ci.md b/context/dox/built/tier-2-runner-and-ci.md index 8d6bb14c..3e8e46ac 100644 --- a/context/dox/built/tier-2-runner-and-ci.md +++ b/context/dox/built/tier-2-runner-and-ci.md @@ -16,6 +16,6 @@ Part of [built/index.md](index.md). The gates themselves: [tier-2-gates.md](tier - `dox-site` ("Dox site build") builds `@northguild/gmt` and the site once on Node 22 with `fetch-depth: 0` and uploads the `dox-site` artifact. It runs when `determine-affected` selects `dox-dist` or `dox-tables`, and on every PR reporting `dox_changed`. The artifact is one tar of `apps/dox/dist`, every gitignored generated file (`src/generated/`, reference, changelog and industry pages under `src/content/docs/`, `public/llms*.txt`) and every tracked file the build rewrote; `dist/` alone is not enough because gate selection reads `src/content/docs/**`. The pack step passes NUL-delimited names to `tar --null -T -`. It keeps 14 days with `overwrite: true` (`download-artifact` keeps the first of two same-named artifacts, #380). A failed `dox-site` skips every job that needs it. - `consistency` keeps only fast checks and builds nothing. -- `dox-browser` unpacks the artifact, builds `@northguild/gmt`, and runs `test:dist` (`DOX_DIST_REQUIRED=1`) and the browser tests (`*.browser.test.ts`, in Chromium and WebKit), on the `dox-dist` and `dox-tables` checks. Table and frame checks are unit or browser tests. +- `dox-browser` unpacks the artifact, builds `@northguild/gmt`, and runs `test:dist` (`DOX_DIST_REQUIRED=1`) and the browser tests (`*.browser.test.ts`, in Chromium; `DOX_BROWSERS` picks the engines and the weekly sweep's `webkit-1` leg runs them in WebKit, step `Browser tests, in WebKit`, where a test only Chromium can run skips through `testsRunIn`), on the `dox-dist` and `dox-tables` checks. Table and frame checks are unit or browser tests. - `dox-gates` ("Dox gates (Chromium)") runs on PRs reporting `dox_changed`, after `dox-site`, as one leg: `gates --browsers chromium --themes dark,light --no-build --deadline 13 --against origin/`, with a 15-minute step limit inside a 20-minute job limit. The runner exits 2 if `dist/gmt/index.html` is missing. `scripts/gates/ci-legs.test.ts` reads `ci.yml` and `dox-gates-weekly.yml` and fails when the PR job gains a matrix or an `--only`/`--skip`, when a `--deadline` is not inside its step or job limit, or when the weekly legs and the report's `LEGS` list disagree. The runner prints its screen at the end and appends it to `$GITHUB_STEP_SUMMARY` (`gates/step-summary.mjs`). Each gate logs to `.gates/`; a failed leg uploads `apps/dox/.gates/` (without `vite-cache/`) as `dox-gates-`. - The `dox-gates` jobs are advisory until the owner makes them required. A PR touching nothing under `apps/dox/` or `pnpm-lock.yaml` skips them; a lockfile change alone runs them (Playwright or axe-core may bump). diff --git a/context/dox/built/tier-2-webmcp.md b/context/dox/built/tier-2-webmcp.md index 1e10c065..acc4ce69 100644 --- a/context/dox/built/tier-2-webmcp.md +++ b/context/dox/built/tier-2-webmcp.md @@ -20,7 +20,7 @@ Every tool page registers one tool that an agent in the reader's browser can lis ## The gate -- `coverage.test.ts` (names, descriptions, swaps, one module per page), the `parity-.test.ts` files (the tool against the mounted page through `~/test/webmcp-parity`), `origin-trial.test.ts` (the parse, and the constant read from the variable), `head.dist.test.ts` (the built head: one marker per tool page, and the same origin-trial metas on every tool page and none elsewhere, with or without a token) and `scripts/webmcp.browser.test.ts` (every page in Chromium and WebKit, with a fake model context and with none). +- `coverage.test.ts` (names, descriptions, swaps, one module per page), the `parity-.test.ts` files (the tool against the mounted page through `~/test/webmcp-parity`), `origin-trial.test.ts` (the parse, and the constant read from the variable), `head.dist.test.ts` (the built head: one marker per tool page, and the same origin-trial metas on every tool page and none elsewhere, with or without a token) and `scripts/webmcp.browser.test.ts` (every page in Chromium on a PR and in WebKit weekly, with a fake model context and with none). - **The stylesheet guard judges the tool import only.** `head.dist.test.ts` walks a page's dynamic imports (through a hop) to the chunk that names the page and checks that import's own preload list against the sheets the page links. A mount's list is walked past: those sheets are the widget's business. It fails when it finds no tool import, so it cannot pass vacuously. ## Rules a new or edited page tool must still obey diff --git a/context/dox/built/tier-6-ops.md b/context/dox/built/tier-6-ops.md index 916490e3..ccf1b873 100644 --- a/context/dox/built/tier-6-ops.md +++ b/context/dox/built/tier-6-ops.md @@ -4,25 +4,25 @@ Part of [built/index.md](index.md). Dev server, gates, Firefox: [tier-6-runbooks ## The weekly gate sweep -`.github/workflows/dox-gates-weekly.yml` runs every page, three browsers, both themes, and files `dox-gate` issues. +`.github/workflows/dox-gates-weekly.yml` runs every page, three browsers, both themes, and files what fails in one rolling `dox-gate` issue. - Triggers: a Sunday cron (`41 4 * * 0`) and `workflow_dispatch` with `force_finding` (also files one `[dry run]` issue). It always runs; there is no skip rule. The workflow stays disabled until the owner says to enable it. Claude never enables it and dispatches a run only when asked. - Locally, `/dox-full-sweep` runs `pnpm --filter dox gates --all --browsers chromium,firefox,webkit --themes dark,light` on request. It prints a findings summary and files no issues. A gate with `fullBrowsers` gets every page in those browsers and the sample pages in the others; a gate whose `browsers` leave out an engine is dropped for it. - On every Dox story, `dox-tester` runs the same command without `--all` on the pages the branch changes, in three browsers, and quotes the result. The PR job checks those pages in Chromium only. -- Legs: `pnpm --filter dox gates --all --browsers --themes dark,light --retries 1 --shard i/n --deadline 40`, `timeout-minutes: 50`, `fail-fast: false`. `--shard` splits each gate's pages, so every leg of a browser runs every gate on its share, round-robin by name from the gate's place in the registry. `--deadline 40` leaves 10 minutes for the summary and the upload, so a leg that runs long files `out-of-time` instead of being killed with nothing. The upload carries the gate logs (`*.log`) beside `summary.json` and the findings. +- Legs: `pnpm --filter dox gates --all --browsers --themes dark,light --retries 1 --shard i/n --deadline 140`, `timeout-minutes: 150`, `fail-fast: false`. `--shard` splits each gate's pages, so every leg of a browser runs every gate on its share, round-robin by name from the gate's place in the registry. `--deadline 140` leaves 10 minutes for the summary and the upload, so a leg that runs long files `out-of-time` instead of being killed with nothing. The upload carries the gate logs (`*.log`) beside `summary.json` and the findings. - Under `--all`, Chromium gets every page of every gate. WebKit and Firefox get every page of `data-credits-check` and the six-page sample of `a11y-axe` (`fullBrowsers`); `rendered-links` is Chromium-only. - - Layout: chromium 4 legs, firefox 1, webkit 1 (6). Firefox and WebKit each run the whole of `data-credits-check` in one leg (shard `1/1`), so the one-page-per-gate offset matters only for the Chromium legs. A retry starts only when the time left exceeds the first attempt's duration (tier 2, The runner). -- Report: job `report` (`issues: write`) downloads the newest `dox-gates--` artifact of each leg (`summary.json`, `*.ndjson`) and runs `apps/dox/scripts/gates/file-issues.mjs --legs ` (`ci-legs.test.ts` checks the list against the matrix). + - Layout: one leg per browser (`chromium-1`, `firefox-1`, `webkit-1`, shard `1/1`). Chromium's `a11y-axe` on every page in both themes takes about 100 minutes; a weekly run has no one waiting, so it stays one leg. + - The WebKit leg also runs the `*.browser.test.ts` files (`DOX_BROWSERS=webkit`) against the site the gates built and adds a `browser-tests` row to its summary; PRs run them in Chromium only. A retry starts only when the time left exceeds the first attempt's duration (tier 2, The runner). +- Report: job `report` (`issues: write`) downloads the newest `dox-gates--` artifact of each leg (`summary.json`, `*.ndjson`) and runs `apps/dox/scripts/gates/file-issues.mjs --legs ` (`ci-legs.test.ts` checks the list against the matrix). - Only `FAIL` rows file; `FLAKY` is listed in the step summary. - - The key is `:::`. The target is the element's identity key (tier 2, "Element identity"), never a class or an `nth` position. Browsers, widths and themes are not in the key, so one issue tables every place a finding was seen. - - A leg with no readable `summary.json` is sorted by its job (`gh api .../runs//jobs`, read only then). If its `Check the summary was written` step passed, the upload or download lost the file and the leg joins the one `dox-gate:not-uploaded:all:` issue. Otherwise it files `dox-gate:could-not-run:` with how the job ended and the first step that did not succeed. A job list that cannot be read files could-not-run with the cause unknown. - - A leg whose runner reached its `--deadline` (a row with `outOfTime`) files `dox-gate:out-of-time:` with every gate's status and minutes; the findings it reached still file on their own keys. - - Any other `FAIL` with no structured finding files `:unstructured:all:` with its log tail. -- Issues: label `dox-gate` only (created when missing, with `dox-gate-dry-run`) and no issue type. The first body line is `` (`"`, `>` and `--` in a key are written as entities). An open `dox-gate` issue with the same marker gets a comment on the lowest-numbered match; otherwise a new issue opens. - - Flood guard: more than 10 new issues in one run opens none and files one `dox-gate:flood` issue (a comment if already open). Its body groups held-back findings by `gate:rule:page` (largest first, `TABLE_ROWS` 40 rows and a count of the rest) with the run URL and leg artifacts (kept 14 days). Each run comments there until ten or fewer remain, then each is filed on its own. - - `fitBody` cuts every other body and comment to 60,000 characters on a line boundary; `file-issues` exits 1 before any write when one still passes GitHub's 65,536. Comments on already-open findings still go out. - - Nothing is closed automatically: whoever fixes a finding closes its issue. -- Dry run: `node apps/dox/scripts/gates/file-issues.mjs --print --dry-run-finding ` plans against the live open-issue list (needs `gh` signed in), prints one line per action and files nothing. `--offline` makes no `gh` call and implies `--print`. Outside GitHub Actions it only plans; without `--print` it exits 2 ("run with --print locally; issues are filed by the weekly workflow"). An unreadable summary path (without `--legs`) or one with no leg folder also exits 2. Use a summary with no `FAIL` row, since a local `--all` summary plans as one flood issue. In CI, dispatch with `force_finding`: one `[dry run]` issue appears (key `dry-run:synthetic:/:body`, label `dox-gate-dry-run`); a second dispatch comments on it. + - One rolling issue, marker `` on line 1. A failing run opens it, or rewrites its title and body and comments `Still failing at `; a clean run closes it with `Clean at : `. The body is a table of the findings grouped by gate and rule, then one section per finding, cut to fit GitHub's body limit with the table kept whole. + - A finding's key is `:::`. The target is the element's identity key (tier 2, "Element identity"), never a class or an `nth` position. Browsers, widths and themes are not in the key, so one section tables every place a finding was seen. + - A `force_finding` dispatch keeps its own rolling `[dry run]` issue (label `dox-gate-dry-run`), never closed by a clean run. An open issue from the earlier one-per-finding filing (marker `key="…"`) is closed as folded into the rolling issue, or as clean. + - A leg with no readable `summary.json` is sorted by its job (`gh api .../runs//jobs`, read only then). If its `Check the summary was written` step passed, the upload or download lost the file and the leg is listed as `dox-gate:not-uploaded:all:`. Otherwise it is listed as `dox-gate:could-not-run:` with how the job ended and the first step that did not succeed. A job list that cannot be read lists could-not-run with the cause unknown. + - A leg whose runner reached its `--deadline` (a row with `outOfTime`) is listed as `dox-gate:out-of-time:` with every gate's status and minutes; the findings it reached are listed on their own keys. + - Any other `FAIL` with no structured finding is listed as `:unstructured:all:` with its log tail. +- Issues: label `dox-gate` (created when missing, with `dox-gate-dry-run`) and no issue type. The title is `Dox gates: failures in groups`. Every body and comment goes through `fitBody` (60,000 characters, cut on a line boundary, the grouped table kept whole); `file-issues` exits 1 before any write when one still passes GitHub's 65,536. +- Dry run: `node apps/dox/scripts/gates/file-issues.mjs --print --dry-run-finding ` plans against the live open-issue list (needs `gh` signed in), prints one line per action and files nothing. `--offline` makes no `gh` call and implies `--print`. Outside GitHub Actions it only plans; without `--print` it exits 2 ("run with --print locally; issues are filed by the weekly workflow"). An unreadable summary path (without `--legs`) or one with no leg folder also exits 2. In CI, dispatch with `force_finding`: one rolling `[dry run]` issue appears (label `dox-gate-dry-run`); a second dispatch rewrites it and comments. ## Local dev and chat @@ -49,7 +49,7 @@ Part of [built/index.md](index.md). Dev server, gates, Firefox: [tier-6-runbooks - The Firefox and WebKit legs of `data-credits-check` and `a11y-axe`, on a machine where Firefox launches. - The tier 3 keyboard-only, reduced-preference and Firefox/Safari pass. - The Dox PR jobs (`ci.yml`): `dox-site` uploads `dox-site`; the `dox-gates` job passes inside its limit with its build row `SKIP --no-build`; a PR touching nothing under `apps/dox/` or `pnpm-lock.yaml` shows the jobs skipped. -- The weekly sweep, once the file is on `main`: a `force_finding` dispatch finishes every leg, Firefox included, and files one `[dry run]` issue with the marker on line 1; a second dispatch comments on it; every leg finishes inside its 40-minute deadline, with no `out-of-time` issue. +- The weekly sweep, once the file is on `main`: a `force_finding` dispatch finishes every leg, Firefox included, and files one `[dry run]` rolling issue with the marker on line 1; a second dispatch rewrites it and comments; every leg finishes inside its 140-minute deadline, with no `out-of-time` entry. ## Not doing