From 9f1a77ec0d6dcf6aaeb0640a8f39828981d7fee5 Mon Sep 17 00:00:00 2001 From: dxnnystyles Date: Sat, 24 Oct 2026 17:55:27 -0700 Subject: [PATCH 1/2] fix: separate benchmark smoke and rerun concurrency --- .github/workflows/benchmark-diff.yml | 3 ++- tests/test_workflow_concurrency.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/test_workflow_concurrency.py diff --git a/.github/workflows/benchmark-diff.yml b/.github/workflows/benchmark-diff.yml index 3adb7a9f..ff907c7c 100644 --- a/.github/workflows/benchmark-diff.yml +++ b/.github/workflows/benchmark-diff.yml @@ -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: diff --git a/tests/test_workflow_concurrency.py b/tests/test_workflow_concurrency.py new file mode 100644 index 00000000..b3786ee4 --- /dev/null +++ b/tests/test_workflow_concurrency.py @@ -0,0 +1,20 @@ +from pathlib import Path + +import yaml + + +def test_benchmark_diff_separates_smoke_and_full_rerun_concurrency_groups(): + workflow_path = Path(__file__).parents[1] / ".github/workflows/benchmark-diff.yml" + workflow = yaml.safe_load(workflow_path.read_text(encoding="utf-8")) + + concurrency = workflow["concurrency"] + group = concurrency["group"] + + assert concurrency["cancel-in-progress"] is True + assert 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' }}" + ) From 3789052296231c12262e450ae59d3b6deaa3e28c Mon Sep 17 00:00:00 2001 From: dxnnystyles Date: Sat, 24 Oct 2026 18:00:59 -0700 Subject: [PATCH 2/2] test: avoid optional YAML dependency in workflow regression --- tests/test_workflow_concurrency.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/test_workflow_concurrency.py b/tests/test_workflow_concurrency.py index b3786ee4..acabb414 100644 --- a/tests/test_workflow_concurrency.py +++ b/tests/test_workflow_concurrency.py @@ -1,20 +1,25 @@ from pathlib import Path - -import yaml +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 = yaml.safe_load(workflow_path.read_text(encoding="utf-8")) + workflow = workflow_path.read_text(encoding="utf-8") + match = re.search( + r"(?ms)^concurrency:\n(?P(?:^[ \t]+.*(?:\n|$)|^[ \t]*\n)*)", + workflow, + ) + assert match is not None + concurrency = match.group("block") - concurrency = workflow["concurrency"] - group = concurrency["group"] + group_match = re.search(r"(?m)^ group: (.+)$", concurrency) + assert group_match is not None - assert concurrency["cancel-in-progress"] is True - assert group == ( + 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)