Files
rea/scripts/ci/darwin-gate-candidates.mjs
T
morluto 3280b1a669 ci(apple): run the macOS lane when a pull request changes a macOS-gated test
Pull requests ran the macOS lane only for its listed paths, so a change
to a test gated to macOS never ran it before main's full sweep. The CI
planner runs before dependencies are installed and cannot load the
parser, so a dependency-free candidate test now admits every module
that could gate a test to macOS: one that names a "darwin" or "linux"
literal and has a skipIf/runIf gate or a case list chosen by a
conditional on that literal. The planner selects the lane when a changed
test at head is a candidate, and the exact discovery parses only
candidates, so the two cannot disagree about a gated module. The test
over-selects modules that are not gated; a deleted test selects nothing.
2026-11-25 11:39:33 -05:00

17 lines
903 B
JavaScript

// The CI planning job runs before dependencies are installed, so it cannot
// load the parser that darwin-gated-tests.mjs uses to decide a gate exactly.
// This dependency-free test admits a superset of that decision, and the
// exact discovery parses only the modules it admits, so the two cannot
// disagree about a gated module. A gate can tell macOS from Linux only by
// comparing process.platform with a "darwin" or "linux" literal. It is a
// skipIf/runIf call, or a case list chosen by a conditional on that literal.
// The test may admit modules that are not gated.
const PLATFORM_LITERAL = /["'`](?:darwin|linux)["'`]/u;
const GATE_SHAPE =
/\.(?:skipIf|runIf)\s*\(|["'`](?:darwin|linux)["'`]\s*\)?\s*\?\s*\(?\s*\[/u;
/** Whether a test module's text could gate a test to macOS. */
export const mayGateTestToDarwin = (source) =>
PLATFORM_LITERAL.test(source) && GATE_SHAPE.test(source);