Skip to content

Commit 8f17594

Browse files
bm1549claude
andauthored
fix(ci): deduplicate check runs in all-green script to handle re-runs (#7719)
When a check is re-run (e.g. after adding a missing semver label), GitHub keeps the old failed check run alongside the new successful one. The all-green script was scanning all historical runs and failing on the stale failures. Fix by grouping runs by name and evaluating only the latest run for each check, making the summary table consistent with the pass/fail decision. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f89ed61 commit 8f17594

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

scripts/all-green.mjs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,34 @@ async function checkCompleted () {
6969
}
7070

7171
async function checkAllGreen () {
72-
let checkRuns
72+
let latestRuns
7373

7474
try {
7575
await checkCompleted()
7676
} finally {
77-
checkRuns = await octokit.paginate(
77+
const checkRuns = await octokit.paginate(
7878
'GET /repos/:owner/:repo/commits/:ref/check-runs',
7979
{
8080
...params,
8181
per_page: 100,
8282
}
8383
)
8484

85-
printSummary(checkRuns)
85+
// When a check is re-run, older runs remain with their original conclusions.
86+
// Deduplicate by name and evaluate only the latest run for each check.
87+
const latestByName = new Map()
88+
for (const run of checkRuns) {
89+
const existing = latestByName.get(run.name)
90+
if (!existing || new Date(run.started_at) >= new Date(existing.started_at)) {
91+
latestByName.set(run.name, run)
92+
}
93+
}
94+
latestRuns = [...latestByName.values()]
95+
96+
printSummary(latestRuns)
8697
}
8798

88-
const allGreen = !checkRuns.some(run => (
99+
const allGreen = !latestRuns.some(run => (
89100
run.conclusion === 'failure' || run.conclusion === 'timed_out'
90101
))
91102

0 commit comments

Comments
 (0)