Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions .github/workflows/zephyr-board-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,28 @@ jobs:
fi
# Everything except this workflow's own runs and their check runs,
# matched by check suite rather than by name. For each other
# workflow only its newest run on this commit counts.
# workflow only its newest run on this commit counts, and only the
# check runs of that newest run: a run that was replaced, cancelled
# or re-run keeps its old check runs on the commit, though the pull
# request page no longer shows them. GitHub Actions check runs are
# known by their app, so one from a run missing from the list is
# still never taken for an outside check. Within one run, or one
# outside app, a re-run check counts once, newest first; the same
# name in different workflows or apps counts separately.
# Only the fields the wait uses are kept: c = check runs, r = runs.
jq -n --argjson own "$OWN" --slurpfile J "$CR_FILE" --slurpfile W "$WR_FILE" '
{c: [$J[0].check_runs[]?
| select(.check_suite.id as $s | $own | any(.[]; . == $s) | not)
| {name, status, conclusion}],
r: [$W[0].workflow_runs[]?
| select(.check_suite_id as $s | $own | any(.[]; . == $s) | not)]
| group_by(.workflow_id) | map(max_by(.id) | {name, status, conclusion})}' > "$CHK"
[$W[0].workflow_runs[]?] as $runs
| [$runs[].check_suite_id] as $all
| [$runs | group_by(.workflow_id)[] | max_by(.id) | .check_suite_id] as $newest
| {c: [$J[0].check_runs[]?
| .check_suite.id as $s
| select($own | any(.[]; . == $s) | not)
| ((.app.slug // "") == "github-actions" or ($all | any(.[]; . == $s))) as $gha
| select(($gha | not) or ($newest | any(.[]; . == $s)))
| .key = (if $gha then "run \($s)" else "app \(.app.id // $s)" end)]
| group_by([.key, .name]) | map(max_by(.id // 0) | {name, status, conclusion}),
r: [$runs[] | select(.check_suite_id as $s | $own | any(.[]; . == $s) | not)]
| group_by(.workflow_id) | map(max_by(.id) | {name, status, conclusion})}' > "$CHK"
TOTAL=$(jq '(.c | length) + (.r | length)' "$CHK")
# Check names can come from the pull request itself, so only plain
# characters of them go into the logs and the comment. A name with
Expand Down Expand Up @@ -1295,12 +1308,23 @@ jobs:
continue
fi
# Anything still waiting for someone to approve it, counted the same
# way as the gate does: other workflows' newest runs and check runs.
# way as the gate does: other workflows' newest runs, only the check
# runs of those newest runs, and outside apps' check runs; a re-run
# check counts once per run or app.
if ! waiting=$(jq -n --argjson me "$OWN_WF" --slurpfile R "$RUNS" --slurpfile C "$CHECKS" '
([$R[0].workflow_runs[] | select(.workflow_id != $me)] | group_by(.workflow_id) | map(max_by(.id))
| map(select(.status == "waiting" or .status == "action_required"
or .conclusion == "action_required")) | length)
+ ([$C[0].check_runs[] | select(.conclusion == "action_required")] | length)') \
[$R[0].workflow_runs[]] as $runs
| [$runs[].check_suite_id] as $all
| [$runs | group_by(.workflow_id)[] | max_by(.id) | .check_suite_id] as $newest
| ([$runs[] | select(.workflow_id != $me)] | group_by(.workflow_id) | map(max_by(.id))
| map(select(.status == "waiting" or .status == "action_required"
or .conclusion == "action_required")) | length)
+ ([$C[0].check_runs[]
| .check_suite.id as $s
| ((.app.slug // "") == "github-actions" or ($all | any(.[]; . == $s))) as $gha
| select(($gha | not) or ($newest | any(.[]; . == $s)))
| .key = (if $gha then "run \($s)" else "app \(.app.id // $s)" end)]
| group_by([.key, .name]) | map(max_by(.id // 0))
| map(select(.conclusion == "action_required")) | length)') \
|| [[ ! "$waiting" =~ ^[0-9]+$ ]]; then
echo "PR #$n: could not be read; trying again next time"
continue
Expand Down