test(ci): consolidate required lane gate coverage (#13515)

This commit is contained in:
morluto authored and GitHub committed 2026-11-22 17:30:48 +00:00
1 parent 321387c431
commit 77c5e6bf82
1 file changed
+46 -74
@@ -753,66 +753,47 @@ it("keeps fast feedback separate from complete qualification and release proof",
});
it.each([
["true", "success", true],
["true", "failure", false],
["true", "cancelled", false],
["true", "skipped", false],
["true", "missing", false],
["false", "skipped", true],
["false", "failure", false],
["false", "cancelled", false],
] as const)(
"enforces mapped required scopes for selected=%s and result=%s",
"enforces the gate for selected=%s and result=%s",
async (selected, result, passes) => {
const workflow = await requiredNeeds();
for (const [scope, lane] of [
["sqlite", "sqlite-runtime"],
["workflows", "static"],
["ghidra_bridge", "ghidra_bridge"],
["agentenv", "agentenv"],
["python", "python"],
["packet_capture", "packet_capture"],
["signal_recording", "signal_recording"],
] as const) {
// GitHub exposes only direct dependencies in the required job's needs context.
const needs: Record<
string,
{ result: string; outputs?: Record<string, string> }
> = Object.fromEntries(
workflow.needs.map((name) => [name, { result: "success" }]),
);
needs.changes = {
result: "success",
outputs: {
...Object.fromEntries(
(await scopeFlags()).map((flag) => [flag, "false"]),
),
tier: "fast",
test_mode: "full",
code: "true",
[scope]: selected,
},
};
if (result === "missing") delete needs[lane];
else needs[lane] = { result };
const execution = executeWorkflowFixture(
process.execPath,
[
fileURLToPath(
new URL("../../../scripts/ci/required.mjs", import.meta.url),
),
],
{ env: { ...process.env, CI_JOBS: JSON.stringify(needs) } },
);
// Static checks remain required even without workflow edits.
const expected = passes && !(lane === "static" && result !== "success");
if (expected)
await expect(execution).resolves.toMatchObject({ stderr: "" });
else
await expect(execution).rejects.toMatchObject({
code: 1,
stderr: expect.stringContaining(lane),
});
}
const lane = "sqlite-runtime";
const { needs } = await requiredNeeds();
const jobs: Record<
string,
{ result: string; outputs?: Record<string, string> }
> = Object.fromEntries(needs.map((name) => [name, { result: "success" }]));
jobs.changes = {
result: "success",
outputs: {
...Object.fromEntries(
(await scopeFlags()).map((flag) => [flag, "false"]),
),
tier: "fast",
test_mode: "full",
sqlite: selected,
},
};
if (result === "missing") delete jobs[lane];
else jobs[lane] = { result };
const execution = executeWorkflowFixture(
process.execPath,
[
fileURLToPath(
new URL("../../../scripts/ci/required.mjs", import.meta.url),
),
],
{ env: { ...process.env, CI_JOBS: JSON.stringify(jobs) } },
);
if (passes) await expect(execution).resolves.toMatchObject({ stderr: "" });
else
await expect(execution).rejects.toMatchObject({
code: 1,
stderr: expect.stringContaining(`CI lanes did not pass: ${lane}`),
});
},
);
@@ -848,14 +829,7 @@ it("rejects incomplete or malformed classification even when available jobs succ
await expect(
run({ ...valid, qualification_run_id: "true" }),
).resolves.toMatchObject({ stderr: "" });
for (const outputs of [
undefined,
null,
{},
{ ...valid, tier: undefined },
{ ...valid, tier: "" },
{ ...valid, tier: "unknown" },
]) {
for (const outputs of [undefined, { ...valid, tier: "unknown" }]) {
await expect(run(outputs)).rejects.toMatchObject({
code: 1,
stderr: expect.stringContaining("valid tier"),
@@ -867,7 +841,7 @@ it("rejects incomplete or malformed classification even when available jobs succ
stderr: expect.stringContaining(`scope outputs: ${flag}`),
});
}
for (const value of ["", "TRUE", "yes", true, false, 0, null, [], {}]) {
for (const value of ["", "TRUE", true, null]) {
await expect(run({ ...valid, sqlite: value })).rejects.toMatchObject({
code: 1,
stderr: expect.stringContaining("scope outputs: sqlite"),
@@ -891,7 +865,7 @@ it("fails fast only for ordinary PR matrices and rejects partial portable feedba
});
expect(jobs["package-e2e"]?.strategy).toMatchObject({ "fail-fast": false });
const flags = await scopeFlags();
for (const result of ["failure", "cancelled", "skipped", "missing"]) {
for (const result of ["skipped", "missing"]) {
// Even an incorrectly successful report merge cannot hide matrix failure.
const needs: Record<string, unknown> = {
changes: {
@@ -999,15 +973,13 @@ it("runs a selected PR subset in planner-owned groups and still gates it", async
const ran = { build: "success", "test-shard": "success" };
// A selected subset skips the separate source job.
await expect(gate({}, ran)).resolves.toMatchObject({ stderr: "" });
for (const [name, result] of [
["test-shard", "skipped"],
["test-shard", "failure"],
["build", "cancelled"],
] as const)
await expect(gate({}, { ...ran, [name]: result })).rejects.toMatchObject({
code: 1,
stderr: expect.stringContaining(name),
});
for (const name of ["test-shard", "build"])
await expect(gate({}, { ...ran, [name]: "skipped" })).rejects.toMatchObject(
{
code: 1,
stderr: expect.stringContaining(name),
},
);
// The complete fast suite still requires its source job.
await expect(gate({ test_mode: "full" }, ran)).rejects.toMatchObject({
stderr: expect.stringContaining("test-source"),