fix(ci): extend main full package validation budget

This commit is contained in:
Minxi Hou
2026-11-02 05:53:11 -05:00
parent 55ccad495c
commit 365b27f255
3 changed files with 139 additions and 1 deletions

View File

@@ -1099,7 +1099,7 @@ async function main() {
id: "pack-artifact",
label: "Package artifact (npm pack policy)",
run: runPackArtifactGate,
timeout: 20 * 60 * 1000,
timeout: 40 * 60 * 1000,
});
}
// With --suites-from only the build lane is left for this slot.

View File

@@ -0,0 +1,88 @@
import test from "node:test";
import assert from "node:assert/strict";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runGateProcess } from "../../../scripts/quality/gate-process.mjs";
test(
"cancellation reaps or stops TERM-resistant same-group parent and child",
{
skip: process.platform !== "linux",
timeout: 15000,
},
async (t) => {
const directory = mkdtempSync(join(tmpdir(), "gate-cancel-cleanup-"));
const logPath = join(directory, "gate.log");
const program = join(directory, "worker.mjs");
const controller = new AbortController();
let pids = [];
const identities = new Map();
const processStartTime = (pid) => {
const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
// Fields after the final ')' begin at field 3; starttime is field 22.
return stat.slice(stat.lastIndexOf(") ") + 2).split(" ")[19];
};
t.after(() => {
controller.abort();
for (const pid of pids) {
try {
const originalStartTime = identities.get(pid);
if (originalStartTime && processStartTime(pid) === originalStartTime) {
process.kill(pid, "SIGKILL");
}
} catch (error) {
if (error.code !== "ESRCH" && error.code !== "ENOENT") throw error;
}
}
rmSync(directory, { recursive: true, force: true });
});
writeFileSync(
program,
`
import { spawn } from "node:child_process";
process.on("SIGTERM", () => {});
if (process.argv[2] === "child") {
console.log("child=" + process.pid);
} else {
console.log("parent=" + process.pid);
spawn(process.execPath, [process.argv[1], "child"], { stdio: ["ignore", "inherit", "inherit"] });
}
setInterval(() => {}, 1000);
`
);
const result = await runGateProcess(process.execPath, [program], {
cwd: directory,
env: {},
logPath,
timeout: 10000,
killGraceMs: 100,
heartbeatMs: 20,
signal: controller.signal,
onHeartbeat() {
const output = readFileSync(logPath, "utf8");
pids = [...output.matchAll(/(?:parent|child)=(\d+)/g)].map((match) => Number(match[1]));
for (const pid of pids) {
if (!identities.has(pid)) identities.set(pid, processStartTime(pid));
}
if (pids.length === 2) controller.abort();
},
});
assert.equal(pids.length, 2, "cancel only after both TERM handlers are installed");
assert.equal(result.code, 1);
assert.equal(result.receipt.outcome, "CANCELLED");
assert.equal(result.receipt.signal, "SIGKILL");
assert.match(result.out, /child=/);
const receipt = JSON.parse(readFileSync(result.receiptPath, "utf8"));
assert.equal(receipt.outcome, "CANCELLED");
assert.equal(receipt.cleanupError, null);
for (const pid of pids) {
try {
const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
assert.equal(stat.slice(stat.lastIndexOf(") ") + 2)[0], "Z", `PID ${pid} must not run`);
} catch (error) {
assert.equal(error.code, "ENOENT");
}
}
}
);

View File

@@ -0,0 +1,50 @@
import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
const source = readFileSync(
new URL("../../../scripts/quality/validate-release-green.mjs", import.meta.url),
"utf8"
);
// Wiring regressions, not evidence that a real build finishes within this budget.
test("the full package lane receives the 40 minute shared deadline", () => {
const lane = source.slice(source.indexOf('id: "pack-artifact"'));
const laneEnd = lane.indexOf("\n });");
assert.ok(laneEnd > 0, "the package lane must have a bounded declaration");
assert.match(lane.slice(0, laneEnd), /run: runPackArtifactGate,[\s\S]*timeout: 40 \* 60 \* 1000/);
assert.match(source, /g\.run\(g\.timeout\)/);
const runner = source.slice(
source.indexOf("async function runPackArtifactGate"),
source.indexOf("async function runUnitShards")
);
assert.match(runner, /const deadline = Date\.now\(\) \+ timeoutMs/);
assert.match(runner, /const remaining = deadline - Date\.now\(\)/);
assert.match(runner, /if \(remaining <= 0\) return classifyRunError/);
assert.match(runner, /timeout: remaining/);
assert.match(runner, /if \(result\.code !== 0\) return/);
});
test("the nightly full sweep selects the full package lane, not the quick path", () => {
const workflow = readFileSync(
new URL("../../../.github/workflows/nightly-release-green.yml", import.meta.url),
"utf8"
);
assert.match(workflow, /MODE="--with-build --full-ci --suites-from suite-results"/);
assert.match(workflow, /MODE="--with-build --full-ci"/);
assert.match(
source,
/const lanes = SUITES_FROM \? slow\.filter\(\(g\) => g\.id === "pack-artifact"\) : slow/
);
});
test("full-mode tarball boot keeps its independent 15 minute ceiling and package dependency", () => {
const boot = source.slice(source.indexOf("const packArtifactIndex"));
assert.match(boot, /packArtifactResult\.code !== 0/);
assert.match(boot, /\["run", "check:pack-boot"\], \{\s*timeout: 15 \* 60 \* 1000/);
});
// Quick mode is a separate preflight contract, not the full nightly budget.
test("quick build keeps its existing 20 minute budget", () => {
assert.match(source, /await runPackArtifactGate\(20 \* 60 \* 1000\)/);
});