Skip to content

Commit 30ad56a

Browse files
committed
fix(release): allow ANSI in focused evidence logs
1 parent 23382e7 commit 30ad56a

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎scripts/validate-authorized-beta-focused-evidence.mts‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,35 @@ function requireJob(params: {
301301
}
302302
}
303303

304+
function jobLogArgs(jobId: string, allowEscapeSequences = true) {
305+
const args = ["api", `repos/${REPOSITORY}/actions/jobs/${jobId}/logs`];
306+
if (allowEscapeSequences) {
307+
args.push("--allow-escape-sequences");
308+
}
309+
return args;
310+
}
311+
312+
function isUnknownAllowEscapeSequencesFlag(error: unknown) {
313+
if (typeof error !== "object" || error === null || !("stderr" in error)) {
314+
return false;
315+
}
316+
const stderr = error.stderr;
317+
return (
318+
typeof stderr === "string" &&
319+
stderr.replace(/\r\n?/gu, "\n").split("\n").includes("unknown flag: --allow-escape-sequences")
320+
);
321+
}
322+
304323
function requireJobLogTarget(jobId: string, targetSha: string) {
305-
const log = gh(["api", `repos/${REPOSITORY}/actions/jobs/${jobId}/logs`]);
324+
let log: string;
325+
try {
326+
log = gh(jobLogArgs(jobId));
327+
} catch (error) {
328+
if (!isUnknownAllowEscapeSequencesFlag(error)) {
329+
throw error;
330+
}
331+
log = gh(jobLogArgs(jobId, false));
332+
}
306333
if (!log.includes(targetSha)) {
307334
fail(`job ${jobId} log does not bind target ${targetSha}`);
308335
}

‎test/scripts/authorized-beta-focused-evidence.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,14 @@ describe("authorized beta focused evidence", () => {
520520
expect(result.stderr).not.toContain("historical execution plan child run id");
521521
});
522522

523+
it("allows ANSI-bearing Actions logs with legacy gh fallback", () => {
524+
const source = readFileSync("scripts/validate-authorized-beta-focused-evidence.mts", "utf8");
525+
526+
expect(source).toContain('args.push("--allow-escape-sequences")');
527+
expect(source).toContain('includes("unknown flag: --allow-escape-sequences")');
528+
expect(source).toContain("log = gh(jobLogArgs(jobId, false))");
529+
});
530+
523531
it("binds the direct-child tree, exact diff, and unchanged published projection", () => {
524532
const { policy, root } = fixturePolicy();
525533
const changedPath = policy.changedPaths[0];

0 commit comments

Comments
 (0)