Skip to content

Commit 0ba6817

Browse files
authored
More reuse in github actions (#6975)
1 parent c677e23 commit 0ba6817

13 files changed

+358
-646
lines changed

.github/workflows/build-common.yml

Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
name: Reusable - Common
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
cache-read-only:
7+
type: boolean
8+
required: false
9+
no-build-cache:
10+
type: boolean
11+
required: false
12+
skip-windows-smoke-tests:
13+
type: boolean
14+
required: false
15+
secrets:
16+
GRADLE_ENTERPRISE_ACCESS_KEY:
17+
required: false
18+
GE_CACHE_USERNAME:
19+
required: false
20+
GE_CACHE_PASSWORD:
21+
required: false
22+
23+
jobs:
24+
spotless:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v3
28+
29+
- name: Set up JDK for running Gradle
30+
uses: actions/setup-java@v3
31+
with:
32+
distribution: temurin
33+
java-version: 17
34+
35+
- name: Spotless
36+
uses: gradle/gradle-build-action@v2
37+
env:
38+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
39+
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
40+
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
41+
with:
42+
arguments: spotlessCheck ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
43+
cache-read-only: ${{ inputs.cache-read-only }}
44+
# gradle enterprise is used for the build cache
45+
gradle-home-cache-excludes: caches/build-cache-1
46+
47+
license-check:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v3
51+
52+
- name: Set up JDK for running Gradle
53+
uses: actions/setup-java@v3
54+
with:
55+
distribution: temurin
56+
java-version: 17
57+
58+
- name: Generate license report
59+
uses: gradle/gradle-build-action@v2
60+
env:
61+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
62+
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
63+
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
64+
with:
65+
# currently ignoring inputs.no-build-cache and always running with --no-build-cache
66+
# see https://github.com/jk1/Gradle-License-Report/issues/231
67+
arguments: generateLicenseReport --no-build-cache
68+
cache-read-only: ${{ inputs.cache-read-only }}
69+
# gradle enterprise is used for the build cache
70+
gradle-home-cache-excludes: caches/build-cache-1
71+
72+
- name: Check licenses
73+
run: |
74+
# add any untracked folders that may have been added by generateLicenseReport
75+
git add licenses
76+
# there's always going to one line difference due to the timestamp included in the report
77+
if [[ $(git diff --cached --shortstat licenses) == " 1 file changed, 1 insertion(+), 1 deletion(-)" ]]
78+
then
79+
echo "Licenses are up-to-date."
80+
else
81+
echo "Licenses are not up-to-date, please run './gradlew generateLicenseReport' locally and commit."
82+
echo
83+
echo "$(git diff --cached --stat licenses)"
84+
echo
85+
echo "$(git diff --cached licenses)"
86+
exit 1
87+
fi
88+
89+
assemble:
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v3
93+
94+
- name: Set up JDK for running Gradle
95+
uses: actions/setup-java@v3
96+
with:
97+
distribution: temurin
98+
java-version: 17
99+
100+
- name: Assemble
101+
uses: gradle/gradle-build-action@v2
102+
env:
103+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
104+
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
105+
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
106+
with:
107+
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
108+
arguments: assemble -x javadoc ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
109+
cache-read-only: ${{ inputs.cache-read-only }}
110+
# gradle enterprise is used for the build cache
111+
gradle-home-cache-excludes: caches/build-cache-1
112+
113+
- name: Check for jApiCmp diffs
114+
run: |
115+
if git diff --quiet
116+
then
117+
echo "No diff detected."
118+
else
119+
echo "Diff detected - did you run './gradlew jApiCmp'?"
120+
echo $(git diff --name-only)
121+
echo $(git diff)
122+
exit 1
123+
fi
124+
125+
test:
126+
runs-on: ubuntu-latest
127+
strategy:
128+
matrix:
129+
test-java-version:
130+
- 8
131+
- 11
132+
- 17
133+
- 19
134+
vm:
135+
- hotspot
136+
- openj9
137+
exclude:
138+
- test-java-version: 19
139+
vm: openj9
140+
fail-fast: false
141+
steps:
142+
- uses: actions/checkout@v3
143+
144+
- id: setup-test-java
145+
name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
146+
uses: actions/setup-java@v3
147+
with:
148+
# using zulu because new releases get published quickly
149+
distribution: ${{ matrix.vm == 'hotspot' && 'zulu' || 'adopt-openj9'}}
150+
java-version: ${{ matrix.test-java-version }}
151+
152+
- name: Set up JDK for running Gradle
153+
uses: actions/setup-java@v3
154+
with:
155+
distribution: temurin
156+
java-version: 17
157+
158+
# vaadin tests use pnpm
159+
- name: Cache pnpm modules
160+
uses: actions/cache@v3
161+
with:
162+
path: ~/.pnpm-store
163+
key: ${{ runner.os }}-test-cache-pnpm-modules
164+
165+
- name: Start deadlock detector
166+
run: .github/scripts/deadlock-detector.sh
167+
168+
- name: Test
169+
env:
170+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
171+
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
172+
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
173+
uses: gradle/gradle-build-action@v2
174+
with:
175+
# spotless is checked separately since it's a common source of failure
176+
arguments: >
177+
check
178+
-x spotlessCheck
179+
-PtestJavaVersion=${{ matrix.test-java-version }}
180+
-PtestJavaVM=${{ matrix.vm }}
181+
-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}
182+
-Porg.gradle.java.installations.auto-download=false
183+
${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
184+
# only push cache for one matrix option since github action cache space is limited
185+
cache-read-only: ${{ inputs.cache-read-only || matrix.test-java-version != 11 || matrix.vm != 'hotspot' }}
186+
# gradle enterprise is used for the build cache
187+
gradle-home-cache-excludes: caches/build-cache-1
188+
189+
- name: Upload deadlock detector artifacts if any
190+
if: always()
191+
uses: actions/upload-artifact@v3
192+
with:
193+
name: deadlock-detector-test-${{ matrix.test-java-version }}-${{ matrix.vm }}
194+
path: /tmp/deadlock-detector-*
195+
if-no-files-found: ignore
196+
197+
- name: Upload jvm crash dump files if any
198+
if: always()
199+
uses: actions/upload-artifact@v3
200+
with:
201+
name: javacore-test-${{ matrix.test-java-version }}
202+
path: |
203+
**/hs_err_pid*.log
204+
**/javacore.*.txt
205+
**/Snap.*.trc
206+
**/core.*.dmp
207+
**/jitdump.*.dmp
208+
if-no-files-found: ignore
209+
210+
smoke-test:
211+
runs-on: ${{ matrix.os }}
212+
strategy:
213+
matrix:
214+
os:
215+
- windows-2019
216+
- ubuntu-latest
217+
smoke-test-suite:
218+
- jetty
219+
- liberty
220+
- payara
221+
- tomcat
222+
- tomee
223+
- websphere
224+
- wildfly
225+
- other
226+
exclude:
227+
- os: ${{ inputs.skip-windows-smoke-tests && 'windows-2019' || '' }}
228+
- os: windows-2019
229+
smoke-test-suite: websphere
230+
fail-fast: false
231+
steps:
232+
- name: Support long paths
233+
run: git config --system core.longpaths true
234+
if: matrix.os == 'windows-2019'
235+
236+
- uses: actions/checkout@v3
237+
238+
- name: Set up JDK for running Gradle
239+
uses: actions/setup-java@v3
240+
with:
241+
distribution: temurin
242+
java-version: 17
243+
244+
- name: Set up Gradle cache
245+
uses: gradle/gradle-build-action@v2
246+
with:
247+
# only push cache for one matrix option per OS since github action cache space is limited
248+
cache-read-only: ${{ inputs.cache-read-only || matrix.smoke-test-suite != 'tomcat' }}
249+
# gradle enterprise is used for the build cache
250+
gradle-home-cache-excludes: caches/build-cache-1
251+
252+
- name: Build
253+
env:
254+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
255+
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
256+
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
257+
# running suite "none" compiles everything needed by smoke tests without executing any tests
258+
run: ./gradlew :smoke-tests:test -PsmokeTestSuite=none --no-daemon ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
259+
260+
- name: Test
261+
env:
262+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
263+
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
264+
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
265+
run: ./gradlew :smoke-tests:test -PsmokeTestSuite=${{ matrix.smoke-test-suite }}${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
266+
267+
- name: Upload jvm crash dump files if any
268+
if: always()
269+
uses: actions/upload-artifact@v3
270+
with:
271+
name: javacore-smoke-test-${{ matrix.smoke-test-suite }}-${{ matrix.os }}
272+
# we expect crash dumps either in root director or in smoke-tests
273+
# not using **/ here because actions/upload-artifact fails with long paths https://github.com/actions/upload-artifact/issues/309
274+
path: |
275+
hs_err_pid*.log
276+
smoke-tests/hs_err_pid*.log
277+
javacore.*.txt
278+
smoke-tests/javacore.*.txt
279+
Snap.*.trc
280+
smoke-tests/Snap.*.trc
281+
core.*.dmp
282+
smoke-tests/core.*.dmp
283+
jitdump.*.dmp
284+
smoke-tests/jitdump.*.dmp
285+
if-no-files-found: ignore
286+
287+
gradle-plugins:
288+
runs-on: ubuntu-latest
289+
steps:
290+
- uses: actions/checkout@v3
291+
292+
- name: Set up JDK 11 for running Gradle
293+
uses: actions/setup-java@v3
294+
with:
295+
distribution: temurin
296+
java-version: 11
297+
298+
- name: Build
299+
uses: gradle/gradle-build-action@v2
300+
with:
301+
arguments: build ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
302+
build-root-directory: gradle-plugins
303+
cache-read-only: ${{ inputs.cache-read-only }}
304+
305+
examples:
306+
runs-on: ubuntu-latest
307+
steps:
308+
- uses: actions/checkout@v3
309+
310+
- name: Set up JDK for running Gradle
311+
uses: actions/setup-java@v3
312+
with:
313+
distribution: temurin
314+
java-version: 17
315+
316+
- name: Set up Gradle cache
317+
uses: gradle/gradle-build-action@v2
318+
with:
319+
cache-read-only: ${{ inputs.cache-read-only }}
320+
321+
- name: Local publish of artifacts
322+
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
323+
run: ./gradlew publishToMavenLocal -x javadoc
324+
325+
- name: Local publish of gradle plugins
326+
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
327+
run: ./gradlew publishToMavenLocal -x javadoc
328+
working-directory: gradle-plugins
329+
330+
- name: Build distro
331+
run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
332+
working-directory: examples/distro
333+
334+
- name: Build extension
335+
run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
336+
working-directory: examples/extension
337+
338+
- name: Run muzzle check against extension
339+
run: ./gradlew muzzle --init-script ../../.github/scripts/local.init.gradle.kts
340+
working-directory: examples/extension

0 commit comments

Comments
 (0)