Skip to content

Commit bbc0b9d

Browse files
committed
Skip build and test on OSes that have no changes
Many of the PRs on SWT are OS specific, this change only runs the build on OSes if there are changes that can affect that OS. This is going to be more important with #2714 because potentially a number of new jobs will be run per PR and avoiding some of the extra time waiting will be a benefit to all. The minor negative of skipping tests conditionally is that the **Test Results** summary comment will report less runs that base commit. Part of #2714
1 parent 3dddc86 commit bbc0b9d

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/maven.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,56 @@ jobs:
3434
name: Event File
3535
path: ${{ github.event_path }}
3636

37+
changes:
38+
name: Detect changed paths
39+
runs-on: ubuntu-latest
40+
outputs:
41+
# Lint warnings are expected in this block
42+
# https://github.com/dorny/paths-filter/issues/223#issuecomment-2463309889
43+
win32: ${{ steps.filter.outputs.win32 || 'false' }}
44+
gtk: ${{ steps.filter.outputs.gtk || 'false' }}
45+
cocoa: ${{ steps.filter.outputs.cocoa || 'false' }}
46+
md: ${{ steps.filter.outputs.md || 'false' }}
47+
other: ${{ steps.filter.outputs.other || 'false' }}
48+
steps:
49+
- uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0
50+
with:
51+
fetch-depth: 0 # so base/ref SHAs are diffable
52+
- name: Paths filter (PR/Push only)
53+
if: github.event.pull_request.base
54+
# dorney/paths-filter is out of date, so use this fork with
55+
# a specific fix for missing predicate-quantifier in action's
56+
# inputs
57+
# https://github.com/dorny/paths-filter/pull/226#issuecomment-2805358761
58+
uses: petermetz/paths-filter@5ee2f5d4cf5d7bdd998a314a42da307e2ae1639d
59+
id: filter
60+
with:
61+
predicate-quantifier: 'every'
62+
filters: |
63+
win32:
64+
- '**/win32/**'
65+
gtk:
66+
- '**/gtk/**'
67+
cocoa:
68+
- '**/cocoa/**'
69+
md:
70+
- '**/*.md'
71+
jenkins:
72+
- 'Jenkinsfile'
73+
# "other" = anything not matching the above buckets
74+
other:
75+
- '**'
76+
- '!**/win32/**'
77+
- '!**/gtk/**'
78+
- '!**/cocoa/**'
79+
- '!**/*.md'
80+
- '!Jenkinsfile'
81+
3782
build-linux:
3883
name: Build (Linux)
84+
needs: changes
85+
# push => always; PR => run if gtk changed OR "other" changed (run-everything case)
86+
if: ${{ github.event_name != 'pull_request' || needs.changes.outputs.gtk == 'true' || needs.changes.outputs.other == 'true' }}
3987
strategy:
4088
fail-fast: false
4189
matrix:
@@ -49,6 +97,9 @@ jobs:
4997

5098
build-windows:
5199
name: Build (Windows)
100+
needs: changes
101+
# push => always; PR => run if win32 changed OR "other" changed (run-everything case)
102+
if: ${{ github.event_name != 'pull_request' || needs.changes.outputs.win32 == 'true' || needs.changes.outputs.other == 'true' }}
52103
strategy:
53104
fail-fast: false
54105
matrix:
@@ -58,9 +109,13 @@ jobs:
58109
runner: windows-latest
59110
java: ${{ matrix.java }}
60111
native: win32.win32.x86_64
112+
performance: ${{ contains(github.event.pull_request.labels.*.name, 'performance') }}
61113

62114
build-macos:
63115
name: Build (macOS)
116+
needs: changes
117+
# push => always; PR => run if cocoa changed OR "other" changed (run-everything case)
118+
if: ${{ github.event_name != 'pull_request' || needs.changes.outputs.cocoa == 'true' || needs.changes.outputs.other == 'true' }}
64119
strategy:
65120
fail-fast: false
66121
matrix:

0 commit comments

Comments
 (0)