Skip to content

Commit ba135f1

Browse files
coygeekfactory-droid[bot]
authored andcommitted
fix: match required check terminal conclusions
Treat GitHub skipped and neutral required-check conclusions as passing terminal states, and classify startup failures as failed so queue evaluation matches GitHub. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent 563aa7e commit ba135f1

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎src/agent_merge_queue/cli.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@
9797
"ERROR",
9898
"FAILURE",
9999
"STALE",
100+
"STARTUP_FAILURE",
100101
"TIMED_OUT",
101102
}
103+
PASSED_CHECK_STATES = {"NEUTRAL", "SKIPPED", "SUCCESS"}
102104
MERGEABILITY_RETRIES = 6
103105
REVIEW_THREADS_QUERY = """
104106
query($owner: String!, $name: String!, $number: Int!) {
@@ -166,7 +168,7 @@ def check_states(checks: Iterable[dict[str, Any]]) -> dict[str, str]:
166168
state = normalize_check_state(check)
167169
# A newly queued run may not have a timestamp yet. Fail closed instead
168170
# of letting an older success hide that pending rerun.
169-
order = "\uffff" if not timestamp and state != "SUCCESS" else timestamp
171+
order = "\uffff" if not timestamp and state not in PASSED_CHECK_STATES else timestamp
170172
candidate = (order, index, state)
171173
if name not in grouped or candidate[:2] > grouped[name][:2]:
172174
grouped[name] = candidate
@@ -176,7 +178,7 @@ def check_states(checks: Iterable[dict[str, Any]]) -> dict[str, str]:
176178
state = value[2]
177179
if state in FAILED_CHECK_STATES:
178180
result[name] = "failed"
179-
elif state == "SUCCESS":
181+
elif state in PASSED_CHECK_STATES:
180182
result[name] = "passed"
181183
else:
182184
result[name] = "pending"

‎tests/test_cli.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,14 +1574,23 @@ def test_integration_snapshot_uses_exact_commit_check_fallback(self) -> None:
15741574
self.assertEqual(value.checks["CI"], "passed")
15751575
client.commit_check_runs.assert_called_once_with(head_sha)
15761576

1577-
def test_required_checks_do_not_accept_skipped(self) -> None:
1577+
def test_required_checks_accept_passing_terminal_conclusions(self) -> None:
15781578
states = check_states(
15791579
[
15801580
{"name": "CI", "conclusion": "SUCCESS"},
15811581
{"name": "Review", "conclusion": "SKIPPED"},
1582+
{"name": "Lint", "conclusion": "NEUTRAL"},
15821583
]
15831584
)
1584-
self.assertEqual(states, {"CI": "passed", "Review": "pending"})
1585+
self.assertEqual(
1586+
states,
1587+
{"CI": "passed", "Review": "passed", "Lint": "passed"},
1588+
)
1589+
1590+
def test_required_checks_treat_startup_failure_as_failed(self) -> None:
1591+
states = check_states([{"name": "CI", "conclusion": "STARTUP_FAILURE"}])
1592+
1593+
self.assertEqual(states, {"CI": "failed"})
15851594

15861595
def test_latest_check_rerun_wins(self) -> None:
15871596
states = check_states(

0 commit comments

Comments
 (0)