Skip to content

Commit 52e5a6c

Browse files
committed
Don't let irrelevant label-adds cancel the in-progress PR build
GitHub evaluates a workflow's `concurrency:` group BEFORE its job-level `if:` filter. When a non-build-affecting label is added to a PR (e.g. `automated code review` from code-review-sweep, any auto-label from .github/labeler.yml, or any human/bot label-add), the resulting `pull_request labeled` run enters the shared per-PR group with cancel-in-progress, cancels the real in-progress build, and only then evaluates the `if:` and skips — leaving the PR with no build and a failing required-status-check (see PR #18441). Route those irrelevant-label runs to a unique, per-run-id throwaway concurrency group so they neither cancel nor are cancelled by anything; the job's `if:` then skips them in ~1s. Build-affecting labels (`test native`, `test openj9`, `test windows`) and all other event types keep the shared per-PR group, preserving the existing cancel-and-rerun semantics. The fix is at the build workflow level, so it applies uniformly to every label-add source (humans, the labeler workflow, otelbot, dependabot, etc.).
1 parent f0833f0 commit 52e5a6c

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

.github/workflows/build-pull-request.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,29 @@ on:
88
- reopened
99
- labeled
1010

11+
# When a `labeled` event adds a label that doesn't affect the build (see
12+
# the `if:` on the build job below), route it to a unique, throwaway
13+
# concurrency group so it neither cancels nor is cancelled by anything.
14+
# Otherwise it would enter the shared per-PR group, cancel the real
15+
# in-progress build (because concurrency is evaluated before the job-level
16+
# `if:`), and then skip — leaving the PR with no build. This affects any
17+
# label-add source: humans, the `labeler.yml` auto-labeler, the
18+
# code-review-sweep otelbot app token, dependabot, etc.
19+
#
20+
# Build-affecting labels (`test native` / `test openj9` / `test windows`)
21+
# and all other event types keep the shared per-PR group with
22+
# cancel-in-progress, so a new push or a new test-label still cancels and
23+
# supersedes any in-progress build.
1124
concurrency:
12-
group: build-pull-request-${{ github.event.pull_request.number }}
25+
group: >-
26+
${{
27+
(github.event.action == 'labeled' &&
28+
github.event.label.name != 'test native' &&
29+
github.event.label.name != 'test openj9' &&
30+
github.event.label.name != 'test windows')
31+
&& format('build-pull-request-noop-{0}', github.run_id)
32+
|| format('build-pull-request-{0}', github.event.pull_request.number)
33+
}}
1334
cancel-in-progress: true
1435

1536
permissions:

0 commit comments

Comments
 (0)