@biffo/cli 0.272.6 → 0.272.8
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/branch-health.sh +44 -6
package/package.json
CHANGED
package/scripts/branch-health.sh
CHANGED
|
@@ -145,12 +145,12 @@ label=${REPO:-$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")}
|
|
|
145
145
|
# an older run because an API changed its sort is the same class of defect as the
|
|
146
146
|
# truncated list this replaces. Ask for the newest explicitly.
|
|
147
147
|
summary=$(gh_run list --branch "$BRANCH" --limit 200 \
|
|
148
|
-
--json workflowName,status,conclusion,headSha,createdAt,url \
|
|
148
|
+
--json workflowName,status,conclusion,headSha,createdAt,url,event \
|
|
149
149
|
--jq 'group_by(.workflowName)
|
|
150
150
|
| map(max_by(.createdAt))
|
|
151
151
|
| .[]
|
|
152
152
|
| [ (if .status == "completed" then (.conclusion // "unknown") else .status end),
|
|
153
|
-
.workflowName, .headSha[0:8], .createdAt[0:16], .url ]
|
|
153
|
+
.workflowName, .headSha[0:8], .createdAt[0:16], .url, .event ]
|
|
154
154
|
| @tsv' 2>/dev/null)
|
|
155
155
|
|
|
156
156
|
if [ -z "$summary" ]; then
|
|
@@ -165,12 +165,12 @@ cancelled=""
|
|
|
165
165
|
skipped=""
|
|
166
166
|
ok=""
|
|
167
167
|
|
|
168
|
-
while IFS="$TAB" read -r state name sha when url; do
|
|
168
|
+
while IFS="$TAB" read -r state name sha when url event; do
|
|
169
169
|
[ -n "$name" ] || continue
|
|
170
170
|
case "$state" in
|
|
171
171
|
success) ok="${ok}${name}\n" ;;
|
|
172
172
|
failure | timed_out | startup_failure)
|
|
173
|
-
failed="${failed}${state}\t${name}\t${sha}\t${when}\t${url}\n"
|
|
173
|
+
failed="${failed}${state}\t${name}\t${sha}\t${when}\t${url}\t${event}\n"
|
|
174
174
|
;;
|
|
175
175
|
cancelled) cancelled="${cancelled}${name}\n" ;;
|
|
176
176
|
skipped) skipped="${skipped}${name}\n" ;;
|
|
@@ -210,7 +210,14 @@ if [ -z "$failed" ]; then
|
|
|
210
210
|
fi
|
|
211
211
|
|
|
212
212
|
echo
|
|
213
|
-
printf '%b' "$failed" | awk -F'\t' -v r="$RED" -v o="$OFF"
|
|
213
|
+
printf '%b' "$failed" | awk -F'\t' -v r="$RED" -v o="$OFF" -v y="$YELLOW" \
|
|
214
|
+
'NF{
|
|
215
|
+
line = sprintf(" %s%s%s %s at %s %s", r, $1, o, $2, $3, $5)
|
|
216
|
+
if ($6 == "workflow_run") {
|
|
217
|
+
line = line sprintf(" %s(workflow_run trigger: this sha is not reliably the commit evaluated)%s", y, o)
|
|
218
|
+
}
|
|
219
|
+
print line
|
|
220
|
+
}'
|
|
214
221
|
|
|
215
222
|
# --- Who actually broke it ----------------------------------------------------
|
|
216
223
|
#
|
|
@@ -218,11 +225,42 @@ printf '%b' "$failed" | awk -F'\t' -v r="$RED" -v o="$OFF" 'NF{printf " %s%s%s
|
|
|
218
225
|
# branch backwards from the newest failure through consecutive failures, and
|
|
219
226
|
# report the OLDEST one in that unbroken streak. That run's commit is where the
|
|
220
227
|
# breakage started, which is very often not the person now reading this.
|
|
228
|
+
#
|
|
229
|
+
# `workflow_run`-triggered workflows are excluded from that confident
|
|
230
|
+
# attribution (#1463). A `workflow_run` run's own `headSha` (what `gh run
|
|
231
|
+
# list --json headSha` reports, and what every query in this file uses) is
|
|
232
|
+
# this run's ambient checkout ref — for this template's own
|
|
233
|
+
# error-branch-coverage-gate.yml that happens to be the default branch's HEAD
|
|
234
|
+
# at trigger time, not necessarily the commit the run's logic actually
|
|
235
|
+
# evaluated. The commit actually under test only exists in the ORIGINAL
|
|
236
|
+
# webhook payload (`github.event.workflow_run.head_sha`, which a workflow can
|
|
237
|
+
# read live and post as a commit status), and the Runs API does not expose
|
|
238
|
+
# that payload after the fact for an arbitrary workflow — confirmed against
|
|
239
|
+
# this repo's own history: `gh api .../actions/runs/<id>` for a
|
|
240
|
+
# `workflow_run`-triggered run carries no such field, only the ambient
|
|
241
|
+
# `head_sha`, which repeatedly disagreed with the SHA the run's job logs
|
|
242
|
+
# showed it actually reported a status against (e.g. run 31411324650 here:
|
|
243
|
+
# reported headSha f0d697e1 — commit "fix(deploy): package plugins that
|
|
244
|
+
# declare only admin_ingress (#1466)" — while its own job log named the
|
|
245
|
+
# evaluated commit as 0c077cf0, an unrelated `feat(cli)` commit by a
|
|
246
|
+
# different author). Naming the wrong commit with the same confidence as a
|
|
247
|
+
# push-triggered failure is worse than naming none, per the tool's own
|
|
248
|
+
# "cannot tell is never a pass" posture (see file header) — so this reports
|
|
249
|
+
# "cannot attribute" instead of guessing.
|
|
221
250
|
|
|
222
251
|
echo
|
|
223
|
-
printf '%b' "$failed" | while IFS="$TAB" read -r state name sha when url; do
|
|
252
|
+
printf '%b' "$failed" | while IFS="$TAB" read -r state name sha when url event; do
|
|
224
253
|
[ -n "$name" ] || continue
|
|
225
254
|
|
|
255
|
+
if [ "$event" = "workflow_run" ]; then
|
|
256
|
+
echo " ${RED}$name${OFF} is failing (latest observed sha ${YELLOW}$sha${OFF}, $when)"
|
|
257
|
+
echo " ${DIM}This workflow is workflow_run-triggered — its headSha is this run's own"
|
|
258
|
+
echo " ambient checkout ref, not necessarily the commit it evaluated. Cannot"
|
|
259
|
+
echo " attribute which commit broke it from run metadata alone; read the commit"
|
|
260
|
+
echo " status this workflow posts (or its job log) against the real commit.${OFF}"
|
|
261
|
+
continue
|
|
262
|
+
fi
|
|
263
|
+
|
|
226
264
|
# Sort newest-first ourselves, cut the list at the most recent SUCCESS, and
|
|
227
265
|
# take the oldest failure still inside that streak. Anything before a green run
|
|
228
266
|
# is a different, already-fixed breakage and must not be blamed for this one.
|