|
1 | 1 | name: Build pull request |
2 | 2 |
|
| 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. |
3 | 17 | on: |
4 | 18 | pull_request: |
5 | 19 | types: |
6 | 20 | - opened |
7 | 21 | - synchronize |
8 | 22 | - reopened |
9 | | - # called from rebuild-pull-request-on-label.yml |
10 | | - workflow_call: |
| 23 | + - labeled |
11 | 24 |
|
12 | 25 | 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 |
17 | 26 | group: build-pull-request-${{ github.event.pull_request.number }} |
18 | 27 | cancel-in-progress: true |
19 | 28 |
|
20 | 29 | permissions: |
21 | 30 | contents: read |
22 | 31 |
|
23 | 32 | 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 |
26 | 43 | 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') }} |
28 | 50 | skip-openj9-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test openj9') }} |
29 | 51 | 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 |
0 commit comments