fix(ci): harden test gating under load

This commit is contained in:
Vincent Koc
2026-03-19 11:01:16 -07:00
parent 51519b4086
commit feb9a3b5b2
11 changed files with 103 additions and 17 deletions

View File

@@ -1,9 +1,10 @@
const DEFAULT_OUTPUT_CAPTURE_LIMIT = 200_000;
const fatalOutputPatterns = [
/FATAL ERROR:.*heap out of memory/i,
/Allocation failed - JavaScript heap out of memory/i,
/FATAL ERROR:/i,
/JavaScript heap out of memory/i,
/node::OOMErrorHandler/i,
/ERR_WORKER_OUT_OF_MEMORY/i,
];
export function appendCapturedOutput(current, chunk, limit = DEFAULT_OUTPUT_CAPTURE_LIMIT) {
@@ -21,14 +22,17 @@ export function hasFatalTestRunOutput(output) {
return fatalOutputPatterns.some((pattern) => pattern.test(output));
}
export function resolveTestRunExitCode({ code, signal, output }) {
export function resolveTestRunExitCode({ code, signal, output, fatalSeen = false, childError }) {
if (typeof code === "number" && code !== 0) {
return code;
}
if (childError) {
return 1;
}
if (signal) {
return 1;
}
if (hasFatalTestRunOutput(output)) {
if (fatalSeen || hasFatalTestRunOutput(output)) {
return 1;
}
return code ?? 0;