Skip to content

Commit 446e60f

Browse files
Copilotwallstop
andauthored
fix(ci): distinguish stale wait outcomes in dependabot automerge
Agent-Logs-Url: https://github.com/wallstop/fortress-rollback/sessions/c3354c08-7ed6-4593-9d54-9d1ba779b96d Co-authored-by: wallstop <1045249+wallstop@users.noreply.github.com>
1 parent fc2d8f9 commit 446e60f

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

scripts/ci/enable-dependabot-automerge.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ wait_for_required_checks() {
6767
while ((elapsed <= REQUIRED_CHECKS_APPEAR_TIMEOUT_SECONDS)); do
6868
if is_stale_event; then
6969
echo "PR head moved while waiting for required checks; skipping stale auto-merge attempt."
70-
return 0
70+
return 2
7171
fi
7272

7373
required_count="$(required_checks_count)"
7474
if [[ "$required_count" =~ ^[0-9]+$ ]] && ((required_count > 0)); then
7575
if is_stale_event; then
7676
echo "PR head moved after required checks appeared; skipping stale auto-merge attempt."
77-
return 0
77+
return 2
7878
fi
7979
echo "Waiting for $required_count required checks to pass before enabling auto-merge."
8080
if ! gh pr checks "$PR_URL" --required --watch --fail-fast --interval "$REQUIRED_CHECKS_WATCH_INTERVAL_SECONDS"; then
@@ -136,7 +136,15 @@ if [[ "$allow_rebase_merge" == "true" || "$allow_merge_commit" == "true" ]]; the
136136
exit 1
137137
fi
138138

139-
if ! wait_for_required_checks; then
139+
if wait_for_required_checks; then
140+
wait_status=0
141+
else
142+
wait_status=$?
143+
fi
144+
if [[ "$wait_status" -eq 2 ]]; then
145+
exit 0
146+
fi
147+
if [[ "$wait_status" -ne 0 ]]; then
140148
exit 1
141149
fi
142150

scripts/tests/test_enable_dependabot_automerge.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ def test_skips_when_head_becomes_stale_while_waiting(tmp_path: Path) -> None:
282282
)
283283
assert result.returncode == 0
284284
assert "PR head moved while waiting for required checks" in result.stdout
285+
assert "after required checks completed" not in result.stdout
285286

286287
log_lines = (tmp_path / "gh.log").read_text(encoding="utf-8").splitlines()
287288
assert len(log_lines) == 1
@@ -303,6 +304,7 @@ def test_skips_when_head_becomes_stale_after_checks_appear(tmp_path: Path) -> No
303304
)
304305
assert result.returncode == 0
305306
assert "PR head moved after required checks appeared" in result.stdout
307+
assert "after required checks completed" not in result.stdout
306308

307309
log_lines = (tmp_path / "gh.log").read_text(encoding="utf-8").splitlines()
308310
assert len(log_lines) == 1

0 commit comments

Comments
 (0)