Skip to content
Draft
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
5 changes: 3 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ concurrency:
# First-attempt PR validations share a generation key so a newer event
# supersedes only another first attempt. Manual reruns add their stable
# run_id and therefore cannot cancel, or be cancelled by, a newer PR event.
# Tag publication is unique per run and cancel-in-progress remains false.
group: docker-publish-${{ github.repository }}-${{ github.event.pull_request.number || github.ref }}-${{ github.event_name == 'pull_request' && github.run_attempt == 1 && 'first-attempt' || github.run_id }}
# Releases share the GHCR/AKS destination and retain up to 100 pending runs.
group: docker-publish-${{ github.repository }}-${{ github.event_name == 'pull_request' && format('{0}-{1}', github.event.pull_request.number, github.run_attempt == 1 && 'first-attempt' || github.run_id) || 'release-ghcr-aks' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
queue: ${{ github.event_name == 'pull_request' && 'single' || 'max' }}

env:
REGISTRY: ghcr.io
Expand Down
21 changes: 18 additions & 3 deletions backend/tests/test_docker_workflow_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@

from pathlib import Path

import yaml


REPO_ROOT = Path(__file__).resolve().parents[2]


def test_docker_releases_keep_pending_runs_in_a_shared_destination() -> None:
"""Do not silently restore the single-pending default for release writers."""
workflow = yaml.safe_load(
(REPO_ROOT / ".github/workflows/docker-publish.yml").read_text(encoding="utf-8")
)
concurrency = workflow["concurrency"]
assert concurrency.get("queue") == (
"${{ github.event_name == 'pull_request' && 'single' || 'max' }}"
)
assert "|| 'release-ghcr-aks' }}" in concurrency["group"]
assert concurrency["cancel-in-progress"] == "${{ github.event_name == 'pull_request' }}"


def test_docker_pr_concurrency_isolates_reruns_from_first_attempts() -> None:
"""Keep manual reruns out of the first-attempt PR cancellation group."""
workflow = (REPO_ROOT / ".github/workflows/docker-publish.yml").read_text(
Expand All @@ -14,9 +29,9 @@ def test_docker_pr_concurrency_isolates_reruns_from_first_attempts() -> None:
header = workflow.split("jobs:", 1)[0]
expected_group = (
"group: docker-publish-${{ github.repository }}-"
"${{ github.event.pull_request.number || github.ref }}-"
"${{ github.event_name == 'pull_request' && github.run_attempt == 1 "
"&& 'first-attempt' || github.run_id }}"
"${{ github.event_name == 'pull_request' && format('{0}-{1}', "
"github.event.pull_request.number, github.run_attempt == 1 "
"&& 'first-attempt' || github.run_id) || 'release-ghcr-aks' }}"
)
bare_group = (
"group: docker-publish-${{ github.repository }}-"
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/test_release_governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ def test_docker_publish_validates_pr_images_and_publishes_semver_images_only_on_
)
assert "concurrency:" in workflow
assert (
"docker-publish-${{ github.repository }}-${{ github.event.pull_request.number || github.ref }}"
"docker-publish-${{ github.repository }}-${{ github.event_name == 'pull_request' && format('{0}-{1}', github.event.pull_request.number,"
in workflow
)
assert (
Expand Down