diff --git a/.github/scripts/auto_update_pr.py b/.github/scripts/auto_update_pr.py index a23c187..8dbbcd9 100644 --- a/.github/scripts/auto_update_pr.py +++ b/.github/scripts/auto_update_pr.py @@ -150,7 +150,7 @@ def step(self, event: str, now: datetime) -> int | None: log("auto_update.release", pr=p.number, failed=ci_failed(p)) self.set_label(p.number, False) p.labels.discard(self.label) - elif event == "push" and ci_running(p, now, self.max_age): + elif event == "push" and ci_running(p, now, self.max_age) and self.merge_state(p.number)[1] == "BEHIND": log("auto_update.restart", pr=p.number, reason="base moved while its CI ran") self.cancel_runs(p) self.update(p) diff --git a/.github/scripts/test_auto_update_pr.py b/.github/scripts/test_auto_update_pr.py index f1b5490..90ee69a 100644 --- a/.github/scripts/test_auto_update_pr.py +++ b/.github/scripts/test_auto_update_pr.py @@ -108,6 +108,14 @@ def test_push_restarts_labelled_pr_with_running_ci(self) -> None: self.assertEqual(fake.cancelled(), ["repos/o/r/actions/runs/7/cancel"]) self.assertEqual(fake.updated(), ["1"]) + def test_push_leaves_up_to_date_labelled_pr_running(self) -> None: + runs = [{"id": 7, "status": "in_progress"}] + fake = FakeGh([pr(1, labels=("auto-update",), checks=[RUNNING]), pr(2)], + states={1: ("MERGEABLE", "BLOCKED")}, runs=runs) + self.assertIsNone(updater(fake).step("push", NOW)) + self.assertEqual(fake.cancelled(), []) + self.assertEqual(fake.updated(), []) + def test_schedule_waits_for_labelled_pr_with_running_ci(self) -> None: fake = FakeGh([pr(1, labels=("auto-update",), checks=[RUNNING]), pr(2)]) self.assertIsNone(updater(fake).step("schedule", NOW))