@biffo/cli 0.279.1 → 0.279.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/wait-for-checks.sh +42 -4
package/package.json
CHANGED
|
@@ -218,17 +218,49 @@ while :; do
|
|
|
218
218
|
exit 2
|
|
219
219
|
fi
|
|
220
220
|
|
|
221
|
+
# Two things this filter has to get right, and the second one bit us (#1552).
|
|
222
|
+
#
|
|
223
|
+
# 1. `when` must not be keyed on `.completedAt` alone. A check run that is
|
|
224
|
+
# STILL RUNNING carries `completedAt: "0001-01-01T00:00:00Z"` — GitHub sends
|
|
225
|
+
# the zero-value timestamp rather than omitting the field or sending null.
|
|
226
|
+
# `//` only falls through on null/false, so a plain
|
|
227
|
+
# `.completedAt // .startedAt` returns that zero date and the FRESHEST run
|
|
228
|
+
# sorts as the oldest value there is. `max_by(.when)` then discarded the
|
|
229
|
+
# running run in favour of the superseded one, and this script reported
|
|
230
|
+
# "All checks concluded, none failed" while `Release Guards` was mid-flight
|
|
231
|
+
# on PR #1548 — GitHub had the PR BLOCKED and was right. So the candidate
|
|
232
|
+
# timestamps are filtered before the first non-empty one is taken.
|
|
233
|
+
#
|
|
234
|
+
# 2. Recency must not be the thing that decides it. Even with the timestamp
|
|
235
|
+
# fixed, "newest wins" answers a proxy question; the real one is "is ANY run
|
|
236
|
+
# for this context still in flight?". So an unfinished entry outranks every
|
|
237
|
+
# concluded one for the same name explicitly, and only a group with nothing
|
|
238
|
+
# unfinished falls back to newest-wins (which is what #1333 needs, so a
|
|
239
|
+
# re-run's SUCCESS supersedes the earlier FAILURE).
|
|
240
|
+
#
|
|
241
|
+
# `seen` carries the pre-collapse count per context so the report can state its
|
|
242
|
+
# denominator instead of implying one (#1363).
|
|
221
243
|
rollup=$(gh_pr view "$PR" --json statusCheckRollup --jq '
|
|
222
244
|
[ .statusCheckRollup[]?
|
|
223
245
|
| { name: (.name // .context),
|
|
224
246
|
state: (.conclusion // .state // (if .status == "COMPLETED" then "" else null end)),
|
|
225
|
-
when: (.completedAt
|
|
247
|
+
when: ([ .completedAt, .startedAt, .updatedAt, .createdAt ]
|
|
248
|
+
| map(select(. != null and . != "" and . != "0001-01-01T00:00:00Z"))
|
|
249
|
+
| first // "")
|
|
226
250
|
}
|
|
227
251
|
]
|
|
228
252
|
| group_by(.name)
|
|
229
|
-
| map(
|
|
253
|
+
| map(
|
|
254
|
+
([ .[] | select(.state == null or .state == "" or .state == "PENDING"
|
|
255
|
+
or .state == "IN_PROGRESS" or .state == "QUEUED"
|
|
256
|
+
or .state == "WAITING") ]) as $unfinished
|
|
257
|
+
| (if ($unfinished | length) > 0
|
|
258
|
+
then ($unfinished | max_by(.when))
|
|
259
|
+
else max_by(.when) end)
|
|
260
|
+
+ { seen: length }
|
|
261
|
+
)
|
|
230
262
|
| .[]
|
|
231
|
-
| "\(.name)\t\(.state // "")"') || rollup=""
|
|
263
|
+
| "\(.name)\t\(.state // "")\t\(.seen)"') || rollup=""
|
|
232
264
|
|
|
233
265
|
count=0
|
|
234
266
|
[ -n "$rollup" ] && count=$(printf '%s\n' "$rollup" | grep -c .)
|
|
@@ -305,5 +337,11 @@ fi
|
|
|
305
337
|
|
|
306
338
|
[ -n "$cancelled" ] && exit 1
|
|
307
339
|
|
|
308
|
-
|
|
340
|
+
# State the denominator rather than implying one (#1363). A green that does not
|
|
341
|
+
# say what it looked at cannot be told apart from a green that looked at less
|
|
342
|
+
# than it should have — and this script spent months collapsing a running run out
|
|
343
|
+
# of its own input without ever mentioning that it had collapsed anything.
|
|
344
|
+
runs_seen=$(printf '%s\n' "$rollup" | awk -F'\t' 'NF { s += ($3 == "" ? 1 : $3) } END { print s + 0 }')
|
|
345
|
+
echo "${GREEN}All checks concluded, none failed.${OFF} ${DIM}($count context(s), $runs_seen run(s)).${OFF}"
|
|
346
|
+
printf '%s\n' "$rollup" | awk -F'\t' 'NF && $3 > 1 { print " " $1 ": " $3 " runs, newest used" }'
|
|
309
347
|
exit 0
|