fix(prs): treat every unfinished CheckRun status as pending CI
GitHub's CheckStatusState has six values: REQUESTED, QUEUED, IN_PROGRESS,
COMPLETED, WAITING and PENDING. Only COMPLETED carries a conclusion.
_parse_ci matched IN_PROGRESS and QUEUED alone, so a WAITING run (a job
held by a deployment protection rule), a REQUESTED run or a PENDING run
read as NONE on its own, and any sibling check that had already passed
masked it as SUCCESS. A PR still waiting on a gated job was then sorted as
ready instead of pending.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 38442f16ff)
This commit is contained in:
1 parent
171617dc1b
commit
db8b04a331
2 files changed
+31
-1
No files matched your search
+9
-1
@@ -186,6 +186,14 @@ def _detect_default_branch(repo: str | None = None) -> str:
|
||||
|
||||
_CI_FAILURE_CONCLUSIONS = frozenset({"FAILURE", "CANCELLED", "TIMED_OUT", "ACTION_REQUIRED", "STARTUP_FAILURE"})
|
||||
|
||||
# CheckStatusState has six values: REQUESTED, QUEUED, IN_PROGRESS, COMPLETED,
|
||||
# WAITING and PENDING. Every one but COMPLETED means the run has not finished,
|
||||
# so it carries no conclusion yet and nothing else in the rollup speaks for it.
|
||||
# Matching only IN_PROGRESS/QUEUED left WAITING (a job held by a deployment
|
||||
# protection rule), REQUESTED and PENDING runs invisible — NONE on their own,
|
||||
# and masked as SUCCESS by any sibling check that had already passed.
|
||||
_CI_PENDING_STATUSES = frozenset({"REQUESTED", "QUEUED", "IN_PROGRESS", "WAITING", "PENDING"})
|
||||
|
||||
|
||||
def _parse_ci(rollup: list) -> str:
|
||||
if not rollup:
|
||||
@@ -198,7 +206,7 @@ def _parse_ci(rollup: list) -> str:
|
||||
if conclusions & (_CI_FAILURE_CONCLUSIONS | {"ERROR"}):
|
||||
return "FAILURE"
|
||||
statuses = {r.get("status") for r in rollup}
|
||||
if "IN_PROGRESS" in statuses or "QUEUED" in statuses or conclusions & {"PENDING", "EXPECTED"}:
|
||||
if statuses & _CI_PENDING_STATUSES or conclusions & {"PENDING", "EXPECTED"}:
|
||||
return "PENDING"
|
||||
if "SUCCESS" in conclusions:
|
||||
return "SUCCESS"
|
||||
|
||||
@@ -133,6 +133,28 @@ class TestParseCi:
|
||||
]
|
||||
assert _parse_ci(rollup) == "FAILURE"
|
||||
|
||||
def test_unfinished_check_run_statuses_are_pending(self):
|
||||
"""GitHub's CheckStatusState has six values — REQUESTED, QUEUED,
|
||||
IN_PROGRESS, COMPLETED, WAITING, PENDING — and every one but COMPLETED
|
||||
means the run has no conclusion yet. Reading only IN_PROGRESS/QUEUED
|
||||
made a WAITING run (a job held by a deployment protection rule),
|
||||
a REQUESTED one and a PENDING one invisible: NONE on their own."""
|
||||
for status in ("REQUESTED", "QUEUED", "IN_PROGRESS", "WAITING", "PENDING"):
|
||||
rollup = [{"__typename": "CheckRun", "name": "deploy",
|
||||
"status": status, "conclusion": ""}]
|
||||
assert _parse_ci(rollup) == "PENDING", status
|
||||
|
||||
def test_unfinished_check_run_beside_passing_one_is_pending(self):
|
||||
"""...and worse, masked by a sibling that did pass, so a PR still
|
||||
waiting on a gated job was classified READY/APPROVED, not PENDING."""
|
||||
for status in ("REQUESTED", "WAITING", "PENDING"):
|
||||
rollup = [
|
||||
{"__typename": "CheckRun", "name": "test",
|
||||
"status": "COMPLETED", "conclusion": "SUCCESS"},
|
||||
{"__typename": "CheckRun", "name": "deploy",
|
||||
"status": status, "conclusion": ""},
|
||||
]
|
||||
assert _parse_ci(rollup) == "PENDING", status
|
||||
|
||||
def test_status_context_failure_is_failure(self):
|
||||
"""A commit status from external CI (StatusContext) carries only `state`,
|
||||
|
||||
Reference in new issue
Block a user