Skip to content

Commit bab64fd

Browse files
committed
Move label-triggered PR builds to a separate workflow file
GitHub's PR Checks UI summarizes one row per workflow file using the latest check_suite. When the main build-pull-request.yml workflow handled both 'opened' and 'labeled' events, adding any label after the build started would create a newer (skipped) check_suite that hid the in-progress real build from the PR Checks tab. A simpler conditional concurrency-group fix prevented the cancellation but couldn't fix this UI shadowing — the latest check_suite per workflow file still won. Move 'labeled' events to a new build-pull-request-on-label.yml so they live in a separate workflow file (and thus a separate check_suite). The main workflow's row in the PR Checks UI is now always populated by the real build. Build-affecting labels ('test native', 'test openj9', 'test windows') share the main per-PR concurrency group, so they still cancel and supersede an in-progress build (equivalent UX to pushing a new commit). Non-build-affecting labels go to a unique throwaway concurrency group; the build job's 'if:' skips them instantly without affecting the main workflow.
1 parent f0833f0 commit bab64fd

2 files changed

Lines changed: 55 additions & 10 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build pull request (on label)
2+
3+
# This workflow handles `labeled` pull_request events as a separate workflow
4+
# (and thus a separate check_suite) so that label-triggered runs don't shadow
5+
# the main `Build pull request` workflow's check_suite in the PR Checks UI.
6+
# GitHub's PR Checks tab summarizes per workflow file using the latest
7+
# check_suite, so when a `labeled` event ran in the same workflow file as
8+
# the main build, the (skipped) labeled check_suite hid the in-progress
9+
# real build from the PR UI.
10+
#
11+
# Adding a non-build-affecting label (e.g. `automated code review`,
12+
# anything from `.github/labeler.yml`) routes here, hits the job's `if:`
13+
# filter, and is skipped instantly. Adding a build-affecting label
14+
# (`test native`, `test openj9`, `test windows`) cancels any in-progress
15+
# main build (via the shared per-PR concurrency group) and re-runs the
16+
# full build with the corresponding skip flag flipped — equivalent UX to
17+
# pushing a new commit.
18+
on:
19+
pull_request:
20+
types:
21+
- labeled
22+
23+
concurrency:
24+
# Build-affecting labels share the main `build-pull-request.yml`
25+
# concurrency group, so they cancel and supersede any in-progress
26+
# build. Other labels go to a unique throwaway group so they neither
27+
# cancel nor are cancelled by anything.
28+
group: >-
29+
${{
30+
(github.event.label.name == 'test native' ||
31+
github.event.label.name == 'test openj9' ||
32+
github.event.label.name == 'test windows')
33+
&& format('build-pull-request-{0}', github.event.pull_request.number)
34+
|| format('build-pull-request-on-label-noop-{0}', github.run_id)
35+
}}
36+
cancel-in-progress: true
37+
38+
permissions:
39+
contents: read
40+
41+
jobs:
42+
build:
43+
if: |
44+
github.event.label.name == 'test native' ||
45+
github.event.label.name == 'test openj9' ||
46+
github.event.label.name == 'test windows'
47+
uses: ./.github/workflows/reusable-pr-build.yml
48+
with:
49+
skip-native-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test native') }}
50+
skip-openj9-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test openj9') }}
51+
skip-windows-smoke-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test windows') }}

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
- opened
77
- synchronize
88
- reopened
9-
- labeled
109

1110
concurrency:
1211
group: build-pull-request-${{ github.event.pull_request.number }}
@@ -17,21 +16,16 @@ permissions:
1716

1817
jobs:
1918
build:
20-
# On `labeled` events, only proceed when the added label affects what we
21-
# build. All other event types (opened, synchronize, reopened) always
22-
# proceed.
23-
if: |
24-
github.event.action != 'labeled' ||
25-
github.event.label.name == 'test native' ||
26-
github.event.label.name == 'test openj9' ||
27-
github.event.label.name == 'test windows'
2819
uses: ./.github/workflows/reusable-pr-build.yml
2920
with:
3021
# it's rare for only the openj9 tests, openj9 smoke variants, the windows
3122
# smoke tests, or the native tests to break, so they are gated by labels.
3223
# `test native` is applied automatically by .github/labeler.yml when the
3324
# PR diff touches native-relevant paths; `test openj9` and `test windows`
34-
# are applied manually.
25+
# are applied manually. Adding any of these labels to a PR is handled
26+
# by the separate `build-pull-request-on-label.yml` workflow, which
27+
# cancels this run and re-runs the build with the corresponding skip
28+
# flag flipped.
3529
skip-native-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test native') }}
3630
skip-openj9-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test openj9') }}
3731
skip-windows-smoke-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test windows') }}

0 commit comments

Comments
 (0)