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
3 changes: 2 additions & 1 deletion .github/workflows/benchmark-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ permissions:
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || inputs.pr }}
# Keep smoke runs separate from full reruns; unrelated label events get a no-op group.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || inputs.pr }}-${{ (github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'rerun-benchmark')) && 'full' || (github.event_name == 'pull_request' && github.event.action != 'labeled') && 'smoke' || 'noop' }}
cancel-in-progress: true

jobs:
Expand Down
25 changes: 25 additions & 0 deletions tests/test_workflow_concurrency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from pathlib import Path
import re


def test_benchmark_diff_separates_smoke_and_full_rerun_concurrency_groups():
workflow_path = Path(__file__).parents[1] / ".github/workflows/benchmark-diff.yml"
workflow = workflow_path.read_text(encoding="utf-8")
match = re.search(
r"(?ms)^concurrency:\n(?P<block>(?:^[ \t]+.*(?:\n|$)|^[ \t]*\n)*)",
workflow,
)
assert match is not None
concurrency = match.group("block")

group_match = re.search(r"(?m)^ group: (.+)$", concurrency)
assert group_match is not None

assert group_match.group(1) == (
"${{ github.workflow }}-${{ github.event.pull_request.number || inputs.pr }}-"
"${{ (github.event_name == 'workflow_dispatch' || "
"(github.event_name == 'pull_request' && github.event.action == 'labeled' && "
"github.event.label.name == 'rerun-benchmark')) && 'full' || "
"(github.event_name == 'pull_request' && github.event.action != 'labeled') && 'smoke' || 'noop' }}"
)
assert re.search(r"(?m)^ cancel-in-progress: true\s*$", concurrency)
Loading