merge: PR #30을 합친 검사 브랜치에 넣는다

This commit is contained in:
DongHyeonka
2026-11-13 07:16:02 +09:00
3 changed files with 147 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
/**
* 1112/08-13. What a failed `ci:gate` prints to stderr: the gate, the command
* that failed (or that none did), the log with the whole output, and the end
* of that output, where the cause usually is.
*/
export function formatGateFailure(input: Readonly<{
gateId: string;
gateName: string;
logPath: string;
failedCommand?: string | undefined;
output: readonly string[];
tailLines?: number;
}>): string {
const tail = input.output
.flatMap((chunk) => chunk.split(/\r?\n/u))
.filter((line) => line.trim() !== "")
.slice(-(input.tailLines ?? 20));
return [
`${input.gateId} ${input.gateName}: FAIL`,
` failed command: ${input.failedCommand ?? "none (a check outside the commands)"}`,
` log: ${input.logPath}`,
" last lines of the log:",
...tail.map((line) => ` ${line}`),
].join("\n");
}
+12 -1
View File
@@ -11,6 +11,7 @@ import {
import { classifyGateStepResult } from "./lib/ci-step-result.ts";
import { withCiGatePreflight } from "./contracts/ci-gates.ts";
import { validateCiArtifact } from "./lib/ci-artifact-validator.ts";
import { formatGateFailure } from "./lib/ci-gate-failure.ts";
import { writeCiGateLogAtomic } from "./lib/ci-gate-log.ts";
const requestedGateId = process.argv
@@ -111,6 +112,7 @@ for (const variable of gate.requiresEnvironment ?? []) {
}
}
let failedCommand: string | undefined;
if (passed) {
for (const commandId of gate.commandIds) {
const step = contractIndex.commands.get(commandId);
@@ -174,6 +176,7 @@ if (passed) {
});
if (!appendOutput(`classification: ${classification.kind}`)) passed = false;
if (!classification.expectationMet) {
failedCommand = commandLine;
appendOutput(
`expectation failed: expected ${step.expect}, exit=${result.status}, signal=${result.signal ?? "none"}`,
...(step.expect === "fail"
@@ -241,7 +244,15 @@ if (passed) {
}
if (!passed) {
process.stderr.write(`${gateId} ${gate.name}: FAIL\n`);
process.stderr.write(
`${formatGateFailure({
gateId,
gateName: gate.name,
logPath: logArtifact.path,
failedCommand,
output,
})}\n`,
);
process.exit(1);
}
process.stdout.write(