Files
reverse-engineering-anything/scripts/ci/plan.mjs
T
morluto ff6d1d8142 ci: run only the affected portable tests on pull requests (#11346)
* ci: run only the affected portable tests on pull requests

Pull-request CI now runs static checks, the build and the portable tests a change affects, selected from test imports (through test-only helpers), same-stem and directory-scanning tests, leaf-owner boundary tests and tests that name a changed path. Shared boundaries, untraced inputs, empty selections and selections above 150 files fall back to the complete fast suite. Main pushes, schedules, releases and ci:full keep the complete suite. The portable report verifies the exact selected inventory and the CI required gate accepts a selected plan only for a fast pull request with code changes.

* ci: own leaf-adapter tests by name and keep subset summaries diagnostic
2026-11-16 03:37:15 +08:00

39 lines
1.3 KiB
JavaScript

import { appendFileSync } from "node:fs";
import { gitRepository, planChanges } from "./change-plan.mjs";
import { CI_FLAGS as flags } from "./scopes.mjs";
const plan = planChanges(
{
event: process.env.GITHUB_EVENT_NAME,
full: process.env.CI_FULL === "true",
skipFull: process.env.CI_SKIP_FULL === "true",
base: process.env.BASE_SHA,
head: process.env.HEAD_SHA,
baselineReason: process.env.BASELINE_REASON,
},
gitRepository(),
);
const { tier, matrix, reasons, testSelection, testShards } = plan;
const selected = Object.fromEntries(flags.map((flag) => [flag, plan[flag]]));
if (process.env.GITHUB_OUTPUT)
appendFileSync(
process.env.GITHUB_OUTPUT,
Object.entries({
...selected,
tier,
matrix: JSON.stringify(matrix),
test_selection: JSON.stringify(testSelection),
test_mode: testSelection.mode,
test_shards: JSON.stringify(testShards),
})
.map(([key, value]) => `${key}=${value}\n`)
.join(""),
);
if (process.env.GITHUB_STEP_SUMMARY)
appendFileSync(
process.env.GITHUB_STEP_SUMMARY,
`### Selected CI lanes (${tier})\n\n${flags.filter((flag) => selected[flag]).join(", ") || "Formatting only"}\n\n${reasons.join("\n\n")}\n\nPortable tests (${testSelection.mode}): ${testSelection.reason}\n`,
);
console.log(JSON.stringify(plan));