Skip to content

Commit 35cf777

Browse files
committed
fix: print why a failed T1 press failed, not the command it sent (#3257)
`act()` already stored `firstLine(error)` on a failed row, but `renderSummary` preferred `row.command` whenever it was set, so the only line recording the failure said `gh pr merge …` and dropped the reason. A failed press also counts nothing as enqueued, so that line is the whole record of the round. A failed row now prints its reason. would-enqueue and enqueued still print the command, refused and moved still print theirs, byte for byte. Docs-not-needed: `.github/**` is not an owned path of any subsystem page.
1 parent dd7599d commit 35cf777

2 files changed

Lines changed: 75 additions & 1 deletion

File tree

‎.github/scripts/auto-queue-t1.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ export function renderSummary({ mode = 'report', rows = [], note = '' } = {}) {
154154
const verb = verbOf(row)
155155
const bucket = verb === 'would enqueue' ? 'would-enqueue' : verb
156156
counts[bucket] += 1
157-
const detail = row.command ? `\`${row.command}\`` : String(row.reason ?? '')
157+
// A failed press answers with the reason, never with the command it sent: the reader already knows
158+
// what was tried — the row says it failed — and the reason is the only text that explains why the
159+
// round is one enqueue short (#3257).
160+
const detail = row.action === 'failed' || !row.command ? String(row.reason ?? '') : `\`${row.command}\``
158161
lines.push(`- #${row.number} (${row.tier || 'tier unknown'}, ${short(row.sha)}): ${verb} — ${detail}`)
159162
}
160163
if (rows.length === 0) lines.push('- no open pull request this round')

‎.github/scripts/auto-queue-t1.test.mjs‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,74 @@ test('#3253: the round prints the summary to stdout, byte for byte what it write
466466
rmSync(dir, { recursive: true, force: true })
467467
}
468468
})
469+
470+
// A failed press (#3257)
471+
//
472+
// A press that fails leaves the round with nothing else to say: `enqueued=0`, so no dispatch follows,
473+
// and the summary is the only record. Until this section it printed the command it had just sent —
474+
// answering "why did this fail?" with "here is what I sent" — while the reason `act()` already held in
475+
// `row.reason` never reached the page. Slice B on `#3254` measured it as byte-identical on the base and
476+
// on the tip, so it is pinned here in both readers: the pure renderer and the CLI's real stdout.
477+
test('#3257: a failed row prints the reason even when it also carries the command', () => {
478+
const row = {
479+
number: 4001,
480+
tier: 'T1',
481+
sha: HEAD,
482+
action: 'failed',
483+
reason: 'HTTP 500: Internal Server Error',
484+
command: COMMAND,
485+
}
486+
const text = renderSummary({ mode: 'execute', rows: [row] })
487+
assert.match(text, /- #4001 \(T1, 4a1c2d3e\): failed — HTTP 500: Internal Server Error/)
488+
assert.doesNotMatch(
489+
text,
490+
/failed — `gh pr merge/,
491+
'a failed row that answers with the command it sent tells the reader nothing about the failure',
492+
)
493+
assert.match(text, /auto-queue-t1: mode=execute enqueued=0 refused=0 failed=1/)
494+
})
495+
496+
test('#3257: the other four row shapes keep their exact text', () => {
497+
const rows = [
498+
{ number: 4001, tier: 'T0', sha: HEAD, action: 'enqueue', command: COMMAND },
499+
{ number: 4002, tier: 'T2', sha: HEAD, action: 'refuse', reason: 'tier T2 is judged by a reviewer' },
500+
{
501+
number: 4003,
502+
tier: 'T0',
503+
sha: HEAD,
504+
action: 'moved',
505+
reason: 'the head moved to ffffffff after the decision; the next round decides again',
506+
},
507+
]
508+
const text = renderSummary({ mode: 'execute', rows })
509+
assert.ok(
510+
text.includes(`- #4001 (T0, 4a1c2d3e): enqueued — \`${COMMAND}\``),
511+
'an enqueued row still carries the command it ran',
512+
)
513+
assert.ok(text.includes('- #4002 (T2, 4a1c2d3e): refused — tier T2 is judged by a reviewer'))
514+
assert.ok(
515+
text.includes(
516+
'- #4003 (T0, 4a1c2d3e): moved — the head moved to ffffffff after the decision; the next round decides again',
517+
),
518+
)
519+
const report = renderSummary({ mode: 'report', rows })
520+
assert.ok(report.includes(`- #4001 (T0, 4a1c2d3e): would enqueue — \`${COMMAND}\``))
521+
})
522+
523+
test('#3257: a merge the API refused reaches stdout and the summary file with its reason', () => {
524+
const { run, dir, writes, summary, text } = roundWith({ mergeErr: 'HTTP 500: Internal Server Error' })
525+
try {
526+
assert.equal(run.status, 0, run.stderr)
527+
assert.deepEqual(
528+
writes(),
529+
[`pr merge 4001 --auto --squash --match-head-commit ${HEAD}`],
530+
'one attempt, and no dispatch: nothing was enqueued',
531+
)
532+
assert.match(text, /- #4001 \(T1, 4a1c2d3e\): failed — HTTP 500: Internal Server Error/)
533+
assert.doesNotMatch(text, /failed — `gh pr merge/, 'the log line is the reason, not the command it sent')
534+
assert.match(text, /auto-queue-t1: mode=execute enqueued=0 refused=0 failed=1/)
535+
assert.equal(readFileSync(summary, 'utf8'), text, 'the file a reader opens says the same thing as the log')
536+
} finally {
537+
rmSync(dir, { recursive: true, force: true })
538+
}
539+
})

0 commit comments

Comments
 (0)