Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions src/agent_merge_queue/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@
"ERROR",
"FAILURE",
"STALE",
"STARTUP_FAILURE",
"TIMED_OUT",
}
PASSED_CHECK_STATES = {"NEUTRAL", "SKIPPED", "SUCCESS"}
MERGEABILITY_RETRIES = 6
REVIEW_THREADS_QUERY = """
query($owner: String!, $name: String!, $number: Int!) {
Expand Down Expand Up @@ -166,7 +168,7 @@ def check_states(checks: Iterable[dict[str, Any]]) -> dict[str, str]:
state = normalize_check_state(check)
# A newly queued run may not have a timestamp yet. Fail closed instead
# of letting an older success hide that pending rerun.
order = "\uffff" if not timestamp and state != "SUCCESS" else timestamp
order = "\uffff" if not timestamp and state not in PASSED_CHECK_STATES else timestamp
candidate = (order, index, state)
if name not in grouped or candidate[:2] > grouped[name][:2]:
grouped[name] = candidate
Expand All @@ -176,7 +178,7 @@ def check_states(checks: Iterable[dict[str, Any]]) -> dict[str, str]:
state = value[2]
if state in FAILED_CHECK_STATES:
result[name] = "failed"
elif state == "SUCCESS":
elif state in PASSED_CHECK_STATES:
result[name] = "passed"
else:
result[name] = "pending"
Expand Down
13 changes: 11 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,14 +1574,23 @@ def test_integration_snapshot_uses_exact_commit_check_fallback(self) -> None:
self.assertEqual(value.checks["CI"], "passed")
client.commit_check_runs.assert_called_once_with(head_sha)

def test_required_checks_do_not_accept_skipped(self) -> None:
def test_required_checks_accept_passing_terminal_conclusions(self) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replacement test conflicts with the newer tests on current main. Please rebase and preserve both sets of coverage. While resolving the shared reducer with #22, make sure SKIPPED and NEUTRAL remain passing for every retained check identity.

states = check_states(
[
{"name": "CI", "conclusion": "SUCCESS"},
{"name": "Review", "conclusion": "SKIPPED"},
{"name": "Lint", "conclusion": "NEUTRAL"},
]
)
self.assertEqual(states, {"CI": "passed", "Review": "pending"})
self.assertEqual(
states,
{"CI": "passed", "Review": "passed", "Lint": "passed"},
)

def test_required_checks_treat_startup_failure_as_failed(self) -> None:
states = check_states([{"name": "CI", "conclusion": "STARTUP_FAILURE"}])

self.assertEqual(states, {"CI": "failed"})

def test_latest_check_rerun_wins(self) -> None:
states = check_states(
Expand Down