mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 19:23:24 +00:00
* refactor(ci): plan change scopes through an injectable Git owner ciChangeScope.test.ts spent about five processes per case (copy the seed repository, git add, commit and rev-parse, then node plan.mjs with its own merge-base and diff) to ask which lanes a path selects. Move the planner into change-plan.mjs as planChanges(request, repository), keep plan.mjs as the workflow entrypoint over gitRepository(), and answer the path and package-script tables from an in-memory commit. History, renames, deletions, push baselines, malformed metadata and GITHUB_OUTPUT keep the Git fixture or the spawned entrypoint. 378 tests: 30.6 s elapsed and 32.6 s CPU before, 4.0 s and 4.0 s after. * test(ci): cover workflow environment wiring through the plan entrypoint
37 lines
1.1 KiB
JavaScript
37 lines
1.1 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 } = 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),
|
|
})
|
|
.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`,
|
|
);
|
|
console.log(JSON.stringify(plan));
|