Skip to content

Commit 1ff60dd

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 950dce4 commit 1ff60dd

3 files changed

Lines changed: 85 additions & 70 deletions

File tree

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

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,32 @@ on:
66
- opened
77
- synchronize
88
- reopened
9-
# called from rebuild-pull-request-on-label.yml
10-
workflow_call:
9+
- labeled
1110

1211
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
1712
group: build-pull-request-${{ github.event.pull_request.number }}
1813
cancel-in-progress: true
1914

2015
permissions:
2116
contents: read
2217

2318
jobs:
24-
common:
25-
uses: ./.github/workflows/build-common.yml
19+
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'
28+
uses: ./.github/workflows/reusable-pr-build.yml
2629
with:
27-
# it's rare for only the openj9 tests, openj9 smoke variants, or the windows smoke tests to break
30+
# it's rare for only the openj9 tests, openj9 smoke variants, the windows
31+
# smoke tests, or the native tests to break, so they are gated by labels.
32+
# `test native` is applied automatically by .github/labeler.yml when the
33+
# PR diff touches native-relevant paths; `test openj9` and `test windows`
34+
# are applied manually.
35+
skip-native-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test native') }}
2836
skip-openj9-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test openj9') }}
2937
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-
needs:
59-
- common
60-
- test-latest-deps
61-
- muzzle
62-
- markdown-lint-check
63-
runs-on: ubuntu-latest
64-
if: always()
65-
steps:
66-
- if: |
67-
needs.common.result != 'success' ||
68-
needs.test-latest-deps.result != 'success' ||
69-
needs.muzzle.result != 'success' ||
70-
needs.markdown-lint-check.result != 'success'
71-
run: exit 1 # fail

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

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Reusable PR build
2+
3+
# Always invoked from build-pull-request.yml (the dispatcher).
4+
# All gating decisions are made by the dispatcher and passed in as inputs.
5+
on:
6+
workflow_call:
7+
inputs:
8+
skip-native-tests:
9+
type: boolean
10+
default: false
11+
skip-openj9-tests:
12+
type: boolean
13+
default: false
14+
skip-windows-smoke-tests:
15+
type: boolean
16+
default: false
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
common:
23+
uses: ./.github/workflows/build-common.yml
24+
with:
25+
skip-openj9-tests: ${{ inputs.skip-openj9-tests }}
26+
skip-windows-smoke-tests: ${{ inputs.skip-windows-smoke-tests }}
27+
cache-read-only: true
28+
29+
test-latest-deps:
30+
uses: ./.github/workflows/reusable-test-latest-deps.yml
31+
with:
32+
cache-read-only: true
33+
34+
test-native:
35+
uses: ./.github/workflows/reusable-native-tests.yml
36+
with:
37+
skip-native-tests: ${{ inputs.skip-native-tests }}
38+
39+
muzzle:
40+
uses: ./.github/workflows/reusable-muzzle.yml
41+
with:
42+
cache-read-only: true
43+
44+
# this is not a required check to avoid blocking pull requests if external links break
45+
markdown-check:
46+
# release branches are excluded because the README.md javaagent download link has to be updated
47+
# on release branches before the release download has been published
48+
if: "!startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/')"
49+
uses: ./.github/workflows/reusable-link-check.yml
50+
51+
markdown-lint-check:
52+
uses: ./.github/workflows/reusable-markdown-lint-check.yml
53+
54+
required-status-check:
55+
needs:
56+
- common
57+
- test-latest-deps
58+
- muzzle
59+
- markdown-lint-check
60+
runs-on: ubuntu-latest
61+
if: ${{ always() }}
62+
steps:
63+
- if: |
64+
needs.common.result != 'success' ||
65+
needs.test-latest-deps.result != 'success' ||
66+
needs.muzzle.result != 'success' ||
67+
needs.markdown-lint-check.result != 'success'
68+
run: exit 1 # fail

0 commit comments

Comments
 (0)