From 2dcdacce922ddafd85d0b2a9e78dbfa3ad8fa8ad Mon Sep 17 00:00:00 2001 From: gensokyo-dev Date: Sat, 28 Nov 2026 15:05:35 +0000 Subject: [PATCH] fix(ci): accept a skipped selection the macOS lane runs A selection whose every module is gated to macOS, such as a change to only tests/acceptance/applications/nativePlistNesting.test.ts, can only report skipped modules on Linux, and the portable report then failed with 'Every portable test module was skipped' although the macOS lane ran the tests. The report now accepts an entirely skipped selection when the plan selected the macOS lane and every reported module is gated to macOS by the same isDarwinGatedTestSource rule that the macOS lane uses to discover its tests. The summary says so. Any other entirely skipped selection, and an entirely skipped complete suite, still fail. Fixes #14596 Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> --- .github/workflows/ci.yml | 1 + scripts/ci/test-report.mjs | 24 ++++++++- .../boundary/filesystem/ciTestReports.test.ts | 49 +++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8af505f78..250749a6af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -748,6 +748,7 @@ jobs: CI_VERIFY_TEST_INVENTORY: "true" CI_COMPARE_TEST_SHADOW: ${{ steps.shadow-download.outcome == 'success' }} CI_TEST_SELECTION: ${{ needs.changes.outputs.test_selection }} + CI_APPLE_SELECTED: ${{ needs.changes.outputs.apple }} CI_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: node scripts/ci/test-report.mjs - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 diff --git a/scripts/ci/test-report.mjs b/scripts/ci/test-report.mjs index d519e91720..4b9814e5fb 100644 --- a/scripts/ci/test-report.mjs +++ b/scripts/ci/test-report.mjs @@ -4,6 +4,7 @@ import { isAbsolute, join, relative, resolve, sep } from "node:path"; import { z } from "zod"; +import { isDarwinGatedTestSource } from "./darwin-gated-tests.mjs"; import { compareSelectionShadow } from "./selection-shadow.mjs"; import { parseTestSelection } from "./test-selection.mjs"; @@ -84,6 +85,7 @@ const expected = !verifyInventory }) .split("\0") .filter((path) => path.endsWith(".test.ts")); +let macosOnlySelection = false; if (passed && verifyInventory) { const actual = files.map(({ name }) => name); if (actual.length === 0) @@ -96,8 +98,21 @@ if (passed && verifyInventory) { throw new Error( `Incomplete ${selected ? "selected" : "portable"} test inventory: ${JSON.stringify({ missing, unexpected, duplicateFiles: actual.length - actualSet.size })}`, ); - if (files.every(({ state }) => state === "skipped")) - throw new Error("Every portable test module was skipped"); + if (files.every(({ state }) => state === "skipped")) { + // The macOS lane runs every module gated to macOS, so a selection of only + // such modules is covered there when the plan selected that lane. + const gated = await Promise.all( + files.map(async ({ name }) => + isDarwinGatedTestSource(await readFile(join(root, name), "utf8")), + ), + ); + macosOnlySelection = + selected && + process.env.CI_APPLE_SELECTED === "true" && + gated.every(Boolean); + if (!macosOnlySelection) + throw new Error("Every portable test module was skipped"); + } } // A selected subset is not a timing baseline for the complete suite. const publishesHistory = passed && !selected; @@ -179,6 +194,11 @@ const summary = [ : []), ...shadowNotes, `Skipped test modules: ${skippedFiles.length}. Their skip reasons and required coverage are not established by this report.`, + ...(macosOnlySelection + ? [ + "Every selected module is gated to macOS; the selected macOS lane runs them.", + ] + : []), ...(skippedFiles.length ? [""] : []), ...skippedFiles.map(({ name }) => `- ${name.replaceAll("|", "\\|")}`), "", diff --git a/tests/boundary/filesystem/ciTestReports.test.ts b/tests/boundary/filesystem/ciTestReports.test.ts index 8095f425ef..a9a31ee621 100644 --- a/tests/boundary/filesystem/ciTestReports.test.ts +++ b/tests/boundary/filesystem/ciTestReports.test.ts @@ -34,6 +34,7 @@ const executeTimingReport = async ( SOURCE_RESULT: "", CI_VERIFY_TEST_INVENTORY: "false", CI_TEST_SELECTION: "", + CI_APPLE_SELECTED: "", CI_COMPARE_TEST_SHADOW: "false", ...environment, GITHUB_STEP_SUMMARY: summary, @@ -110,6 +111,9 @@ it("merges available failed-shard diagnostics and skips unavailable shard report expect(summary?.env?.CI_TEST_SELECTION).toBe( "${{ needs.changes.outputs.test_selection }}", ); + expect(summary?.env?.CI_APPLE_SELECTED).toBe( + "${{ needs.changes.outputs.apple }}", + ); const command = steps[gate]?.run; if (command === undefined) throw new Error("Missing shard result gate"); for (const tier of ["fast", "full"]) { @@ -408,6 +412,51 @@ it("reports skipped modules without treating an entirely skipped suite as succes ).rejects.toMatchObject({ code: "ENOENT" }); }); +it("accepts an entirely skipped selection only when the macOS lane runs every module", async () => { + const root = await createTestTempDirectory("rea-ci-report-macos-only-"); + await workflowGit(root, ["init"]); + await mkdir(join(root, "tests")); + await writeFile( + join(root, "tests/macos.test.ts"), + 'describe.skipIf(process.platform !== "darwin")("macOS", () => {});\n', + ); + await writeFile(join(root, "tests/portable.test.ts"), "// fixture\n"); + await workflowGit(root, ["add", "tests"]); + const run = async (names: readonly string[], apple: string) => { + await writeFile( + join(root, "test-timings.json"), + JSON.stringify({ + version: 1, + success: true, + files: names.map((name) => ({ name, durationMs: 1, state: "skipped" })), + }), + ); + return executeTimingReport(root, { + CI_VERIFY_TEST_INVENTORY: "true", + CI_APPLE_SELECTED: apple, + CI_TEST_SELECTION: JSON.stringify({ + version: 3, + mode: "selected", + reason: "Affected tests: 1 changed", + files: names, + shards: 1, + }), + }); + }; + + const covered = await run(["tests/macos.test.ts"], "true"); + expect(covered.summary).toContain( + "Every selected module is gated to macOS; the selected macOS lane runs them.", + ); + for (const [names, apple] of [ + [["tests/macos.test.ts"], "false"], + [["tests/macos.test.ts", "tests/portable.test.ts"], "true"], + ] as const) + await expect(run(names, apple)).rejects.toMatchObject({ + stderr: expect.stringContaining("Every portable test module was skipped"), + }); +}); + it("runs the existing onboarding and Python producer guards from their selected CI owners", async () => { const jobs = await workflow(); const scripts = z