diff --git a/.github/workflows/current-head-run-coalescer.yml b/.github/workflows/current-head-run-coalescer.yml index 23575204de..bf160f452d 100644 --- a/.github/workflows/current-head-run-coalescer.yml +++ b/.github/workflows/current-head-run-coalescer.yml @@ -6,10 +6,15 @@ on: concurrency: group: current-head-run-coalescer-${{ github.repository }}-${{ github.event.pull_request.number }} - # Do not restore cancel-in-progress: true here. This job is the control-plane - # worker that retires redundant runs; cancelling it during a push burst lets - # the redundant runs survive and worsens the 60-job ceiling. + # The active worker must finish because it retires redundant runs that consume + # the shared Actions ceiling. A later synchronize event must not kill it. cancel-in-progress: false + # Keep exactly one pending successor. GitHub replaces that pending run when a + # newer event enters the group, so the retained successor always represents + # the latest head instead of accumulating up to 100 stale-head invocations. + # The script still verifies the event-bound expected head against the live PR + # before any mutation and fails closed if the head moved again. + queue: single permissions: actions: write diff --git a/tests/test_current_head_coalescer_self_cancellation.py b/tests/test_current_head_coalescer_self_cancellation.py index 82eb9c4d71..eb84cd1306 100644 --- a/tests/test_current_head_coalescer_self_cancellation.py +++ b/tests/test_current_head_coalescer_self_cancellation.py @@ -1,4 +1,4 @@ -"""Regression contract for the run-coalescer worker's own concurrency policy.""" +"""Regression contracts for the run-coalescer worker's concurrency policy.""" from pathlib import Path @@ -7,8 +7,8 @@ WORKFLOW_PATH = REPOSITORY_ROOT / ".github" / "workflows" / "current-head-run-coalescer.yml" -def test_current_head_coalescer_cannot_cancel_its_active_cleanup_worker() -> None: - """Push bursts must queue the next cleanup instead of killing the active cleanup.""" +def test_current_head_coalescer_preserves_active_worker_and_latest_pending_event() -> None: + """Push bursts must keep the active cleanup plus the latest pending trigger.""" workflow_text = WORKFLOW_PATH.read_text(encoding="utf-8") concurrency_block = workflow_text.split("concurrency:", 1)[1].split("\npermissions:", 1)[0] active_lines = [ @@ -19,3 +19,5 @@ def test_current_head_coalescer_cannot_cancel_its_active_cleanup_worker() -> Non assert "cancel-in-progress: false" in active_lines assert "cancel-in-progress: true" not in active_lines + assert "queue: single" in active_lines + assert "queue: max" not in active_lines