Skip to content

Commit 4f64f15

Browse files
committed
Unify PR build into a single workflow with a dispatcher
- Introduce reusable-pr-build.yml that owns all build orchestration (common, test-latest-deps, test-native, muzzle, markdown checks, and the required-status-check aggregator). - Convert build-pull-request.yml into a thin dispatcher: it listens to pull_request events (including 'labeled' for 'test native', 'test openj9', 'test windows') and calls reusable-pr-build.yml with the appropriate skip flags. - Delete rebuild-pull-request-on-label.yml; the dispatcher absorbs its role via the 'labeled' trigger and the shared concurrency group. Branch protection must be updated to require 'build / required-status-check' instead of 'required-status-check'.
1 parent 4d87435 commit 4f64f15

3 files changed

Lines changed: 127 additions & 82 deletions

File tree

Lines changed: 31 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,51 @@
11
name: Build pull request
22

3+
# Dispatcher entry point for PR builds.
4+
#
5+
# Build orchestration is delegated to reusable-pr-build.yml via
6+
# `workflow_call`; that workflow has no `pull_request` trigger and is never
7+
# invoked directly. This file owns label parsing and event filtering.
8+
#
9+
# Listening to `labeled` here means a maintainer adding `test openj9`,
10+
# `test windows`, or `test native` re-triggers this dispatcher. The shared
11+
# concurrency group cancels the in-flight run.
12+
#
13+
# Branch protection requires the `build / required-status-check` check-run
14+
# (defined inside reusable-pr-build.yml). Cancelled runs report it as
15+
# skipped (via `!cancelled()` on the inner job), and the rebuild produces
16+
# a same-named green check that branch protection resolves.
317
on:
418
pull_request:
519
types:
620
- opened
721
- synchronize
822
- reopened
9-
# called from rebuild-pull-request-on-label.yml
10-
workflow_call:
23+
- labeled
1124

1225
concurrency:
13-
# fixed group name (not github.workflow) so that runs triggered by pull_request
14-
# and runs triggered via workflow_call from rebuild-pull-request-on-label.yml
15-
# share the group, otherwise the PR build would run twice in parallel whenever
16-
# a "test *" label is added
1726
group: build-pull-request-${{ github.event.pull_request.number }}
1827
cancel-in-progress: true
1928

2029
permissions:
2130
contents: read
2231

2332
jobs:
24-
common:
25-
uses: ./.github/workflows/build-common.yml
33+
build:
34+
# On `labeled` events, only proceed when the added label affects what we
35+
# build. All other event types (opened, synchronize, reopened) always
36+
# proceed.
37+
if: |
38+
github.event.action != 'labeled' ||
39+
github.event.label.name == 'test native' ||
40+
github.event.label.name == 'test openj9' ||
41+
github.event.label.name == 'test windows'
42+
uses: ./.github/workflows/reusable-pr-build.yml
2643
with:
27-
# it's rare for only the openj9 tests, openj9 smoke variants, or the windows smoke tests to break
44+
# it's rare for only the openj9 tests, openj9 smoke variants, the windows
45+
# smoke tests, or the native tests to break, so they are gated by labels.
46+
# `test native` is applied automatically by .github/labeler.yml when the
47+
# PR diff touches native-relevant paths; `test openj9` and `test windows`
48+
# are applied manually.
49+
skip-native-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test native') }}
2850
skip-openj9-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test openj9') }}
2951
skip-windows-smoke-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test windows') }}
30-
cache-read-only: true
31-
32-
test-latest-deps:
33-
uses: ./.github/workflows/reusable-test-latest-deps.yml
34-
with:
35-
cache-read-only: true
36-
37-
test-native:
38-
uses: ./.github/workflows/reusable-native-tests.yml
39-
with:
40-
skip-native-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test native') }}
41-
42-
muzzle:
43-
uses: ./.github/workflows/reusable-muzzle.yml
44-
with:
45-
cache-read-only: true
46-
47-
# this is not a required check to avoid blocking pull requests if external links break
48-
markdown-check:
49-
# release branches are excluded because the README.md javaagent download link has to be updated
50-
# on release branches before the release download has been published
51-
if: "!startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/')"
52-
uses: ./.github/workflows/reusable-link-check.yml
53-
54-
markdown-lint-check:
55-
uses: ./.github/workflows/reusable-markdown-lint-check.yml
56-
57-
required-status-check:
58-
# test-latest-deps is not included in the required status checks
59-
# because any time a new library version is released to maven central
60-
# it can fail due to test code incompatibility with the new library version,
61-
# or due to slight changes in emitted telemetry
62-
# (muzzle can also fail when a new library version is released to maven central
63-
# but that happens much less often)
64-
#
65-
# only the "common" checks are required for release branch PRs in order to avoid any unnecessary
66-
# release branch maintenance (especially for patches)
67-
needs:
68-
- common
69-
- muzzle
70-
- markdown-lint-check
71-
runs-on: ubuntu-latest
72-
if: always()
73-
steps:
74-
- if: |
75-
needs.common.result != 'success' ||
76-
(
77-
!startsWith(github.base_ref, 'release/') &&
78-
(
79-
needs.muzzle.result != 'success' ||
80-
needs.markdown-lint-check.result != 'success'
81-
)
82-
)
83-
run: exit 1 # fail

.github/workflows/rebuild-pull-request-on-label.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Reusable PR build
2+
3+
# Build orchestration for PRs. Always invoked from build-pull-request.yml
4+
# (the dispatcher); never triggered directly. All gating decisions are made
5+
# by the dispatcher and passed in as inputs.
6+
#
7+
# Branch protection requires the `build / required-status-check` check-run
8+
# from this workflow. test-latest-deps, test-native, and markdown-check are
9+
# allowed to fail the workflow's overall conclusion without blocking merges
10+
# because branch protection only watches required-status-check, which has
11+
# its own aggregator logic.
12+
on:
13+
workflow_call:
14+
inputs:
15+
skip-native-tests:
16+
type: boolean
17+
default: false
18+
skip-openj9-tests:
19+
type: boolean
20+
default: false
21+
skip-windows-smoke-tests:
22+
type: boolean
23+
default: false
24+
25+
permissions:
26+
contents: read
27+
28+
jobs:
29+
common:
30+
uses: ./.github/workflows/build-common.yml
31+
with:
32+
skip-openj9-tests: ${{ inputs.skip-openj9-tests }}
33+
skip-windows-smoke-tests: ${{ inputs.skip-windows-smoke-tests }}
34+
cache-read-only: true
35+
36+
# not required: a new library version on maven central can break tests
37+
# due to test code incompatibility or slight telemetry changes
38+
test-latest-deps:
39+
uses: ./.github/workflows/reusable-test-latest-deps.yml
40+
with:
41+
cache-read-only: true
42+
43+
test-native:
44+
uses: ./.github/workflows/reusable-native-tests.yml
45+
with:
46+
skip-native-tests: ${{ inputs.skip-native-tests }}
47+
48+
muzzle:
49+
uses: ./.github/workflows/reusable-muzzle.yml
50+
with:
51+
cache-read-only: true
52+
53+
# not required: avoids blocking PRs if external links break.
54+
# release branches are excluded because the README.md javaagent download
55+
# link has to be updated on release branches before the release download
56+
# has been published.
57+
markdown-check:
58+
if: "!startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/')"
59+
uses: ./.github/workflows/reusable-link-check.yml
60+
61+
markdown-lint-check:
62+
uses: ./.github/workflows/reusable-markdown-lint-check.yml
63+
64+
required-status-check:
65+
# The required check-run watched by branch protection
66+
# (`build / required-status-check`).
67+
#
68+
# test-latest-deps and markdown-check are intentionally not required:
69+
# any time a new library version is released to maven central it can
70+
# fail due to test code incompatibility with the new library version
71+
# or slight changes in emitted telemetry; markdown-check can fail due
72+
# to transient external link breakage. (muzzle can also fail on new
73+
# library releases, but much less often, so it is required.)
74+
#
75+
# Only "common" is required for release branch PRs to avoid unnecessary
76+
# release branch maintenance (especially for patches).
77+
needs:
78+
- common
79+
- muzzle
80+
- markdown-lint-check
81+
runs-on: ubuntu-latest
82+
# Skipped (not failed) when this run is cancelled by concurrency
83+
# (e.g. a label-triggered rebuild superseding it). Branch protection
84+
# then accepts the same-named check from the rebuild.
85+
if: ${{ !cancelled() }}
86+
steps:
87+
- if: |
88+
needs.common.result != 'success' ||
89+
(
90+
!startsWith(github.base_ref, 'release/') &&
91+
(
92+
needs.muzzle.result != 'success' ||
93+
needs.markdown-lint-check.result != 'success'
94+
)
95+
)
96+
run: exit 1 # fail

0 commit comments

Comments
 (0)