Repository navigation
feat: implement issue #469 — pr-review: mention-triggered runs silently lost to ci-pending skip (self-referential check runs) #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0dce084
9761135
76b22b0
b87f198
3f7e954
6932d10
c17345a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/usr/bin/env bash | ||
| # ci-status.sh — compute CI gate status from a statusCheckRollup JSON array, | ||
| # filtering out the PR Review Agent's own check runs so the cascade never | ||
| # blocks on itself (issue #469). | ||
| # | ||
| # Usage: source this file, then call compute_ci_status with the rollup array. | ||
|
|
||
| # compute_ci_status <rollup_json> | ||
| # | ||
| # Inputs: | ||
| # $1 — JSON array (the .statusCheckRollup field from `gh pr view`) | ||
| # | ||
| # Outputs (stdout): one of "passing", "pending", "failing" | ||
| # | ||
| # Classification rules (after filtering own checks): | ||
| # passing — empty rollup, or every item is SUCCESS/SKIPPED/NEUTRAL/SUCCESS state | ||
| # pending — any item is IN_PROGRESS/QUEUED/WAITING/PENDING/EXPECTED or | ||
| # COMPLETED with null/empty conclusion | ||
| # failing — anything else (FAILURE, ACTION_REQUIRED, TIMED_OUT, etc.) | ||
| # | ||
| # Own-check filter — excludes entries belonging to the PR Review cascade. | ||
| # `gh pr view --json statusCheckRollup` exposes the check/job *name* but not | ||
| # the workflow name (gh/cli#9091), so the PR Review Agent's single job appears | ||
| # with its bare job name in the rollup: "review". | ||
| # This is matched explicitly to prevent the cascade from blocking on its own | ||
| # pending check run. Compound "workflow / job" forms are also matched for | ||
| # reusable-workflow callers where that format does appear. | ||
| # Dev-Lead bare checks ("dispatch", "ci-relay") are NOT filtered because | ||
| # Dev-Lead can commit back to the PR branch; filtering them could cause a review | ||
| # to race an in-progress branch-mutating run. | ||
| # Matched: | ||
| # • Bare job name: "review" | ||
| # • "PR Review Agent / *" | ||
| # • "PR Review Reusable / *" | ||
| # • "PR Review — Mention Trigger / *" | ||
| compute_ci_status() { | ||
| local rollup_json="${1:-[]}" | ||
| jq -r ' | ||
| def is_pending: | ||
| .status == "IN_PROGRESS" or .status == "QUEUED" or .status == "WAITING" or | ||
| .state == "PENDING" or .state == "EXPECTED" or | ||
| (.status == "COMPLETED" and (.conclusion == null or .conclusion == "")); | ||
| def is_success: | ||
| .conclusion == "SUCCESS" or .conclusion == "SKIPPED" or .conclusion == "NEUTRAL" or | ||
| .state == "SUCCESS"; | ||
| def is_own_check: | ||
| (.name // .context // "") as $n | | ||
| ($n == "review") or | ||
| ($n | test("^PR Review (Agent|Reusable) /")) or | ||
| ($n | test("^PR Review — Mention Trigger /")); | ||
|
Comment on lines
+47
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For mention-triggered reviews, this repo's caller workflow has a PR check job named Useful? React with 👍 / 👎. |
||
| if (. == null or (type != "array")) then "passing" | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| else | ||
| (map(select(is_own_check | not))) as $ext | | ||
| if ($ext | length) == 0 then "passing" | ||
| elif ([$ext[] | select(is_pending)] | length) > 0 then "pending" | ||
| elif ([$ext[] | select(is_success)] | length) == ($ext | length) then "passing" | ||
| else "failing" | ||
| end | ||
| end | ||
| ' <<< "$rollup_json" 2>/dev/null || echo "passing" | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this derives
$nfrom.contextas well as.name, any legacy commit status context calledreview(or matching one of the PR Review prefixes) is filtered even though the PR Review Agent's own run is a GitHub Actions check run, not a commit status. In a target repo with a required external status context namedreview, a pending or failing status would be removed from$ext, causingcompute_ci_statusto reportpassingand let the cascade review before that real gate is green.Useful? React with 👍 / 👎.