Skip to content

Commit 91b184e

Browse files
authored
ci: fix race condition in all-green job causing invalid summary (#7836)
* fix race condition in all-green script causing invalid output * add console logging of the summary
1 parent 031533a commit 91b184e

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

scripts/all-green.mjs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@ async function hasCompleted () {
5555
}
5656

5757
async function checkCompleted () {
58-
if (RETRIES && retries > RETRIES) {
59-
throw new Error(`State is still pending after ${RETRIES} retries.`)
60-
}
61-
6258
if (!await hasCompleted()) {
59+
retries++
60+
61+
if (RETRIES && retries > RETRIES) {
62+
throw new Error(`State is still pending after ${RETRIES} retries.`)
63+
}
64+
6365
console.log(`Status is still pending, waiting for ${POLLING_INTERVAL} minutes before retrying.`)
6466
await setTimeout(POLLING_INTERVAL * 60_000)
6567
console.log('Retrying.')
66-
retries++
6768
await checkCompleted()
6869
}
6970
}
@@ -108,6 +109,18 @@ async function checkAllGreen () {
108109
}
109110

110111
async function printSummary (checkRuns) {
112+
const runs = checkRuns.map(run => ({
113+
name: run.name,
114+
status: run.status,
115+
conclusion: run.conclusion
116+
? `${run.conclusion} ${checkConclusionEmojis[run.conclusion]}`
117+
: ' ',
118+
started_at: run.started_at,
119+
completed_at: run.completed_at ?? ' ',
120+
}))
121+
122+
console.table(runs)
123+
111124
const header = [
112125
{ data: 'name', header: true },
113126
{ data: 'status', header: true },
@@ -116,12 +129,12 @@ async function printSummary (checkRuns) {
116129
{ data: 'completed_at', header: true },
117130
]
118131

119-
const body = checkRuns.map(run => [
132+
const body = runs.map(run => [
120133
run.name,
121134
run.status,
122-
run.conclusion ? `${run.conclusion} ${checkConclusionEmojis[run.conclusion]}` : ' ',
135+
run.conclusion,
123136
run.started_at,
124-
run.completed_at ?? ' ',
137+
run.completed_at,
125138
])
126139

127140
await summary

0 commit comments

Comments
 (0)