Skip to content

Commit 30a083d

Browse files
committed
run tests on different JDKs using Gradle toolchains, but build only on 17
1 parent bbee7ae commit 30a083d

File tree

3 files changed

+71
-29
lines changed

3 files changed

+71
-29
lines changed

.github/workflows/gradle-build.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,43 @@ env:
1111

1212
jobs:
1313
gradle:
14-
strategy:
15-
matrix:
16-
java: [17, 21, 23, 24]
1714
runs-on: ubuntu-latest
1815
steps:
1916
- uses: actions/checkout@v4
2017

21-
- name: Setup Java
18+
- name: Install JDK 24
2219
uses: actions/setup-java@v4
2320
with:
24-
distribution: temurin
25-
java-version: ${{ matrix.java }}
21+
distribution: 'temurin'
22+
java-version: 24
23+
24+
- name: Install JDK 23
25+
uses: actions/setup-java@v4
26+
with:
27+
distribution: 'temurin'
28+
java-version: 23
29+
30+
- name: Install JDK 21
31+
uses: actions/setup-java@v4
32+
with:
33+
distribution: 'temurin'
34+
java-version: 21
35+
36+
- name: Setup the default JDK 17
37+
uses: actions/setup-java@v4
38+
with:
39+
distribution: 'temurin'
40+
java-version: 17
2641
cache: gradle
2742

2843
- name: Setup Gradle
2944
uses: gradle/actions/setup-gradle@v4
3045
with:
3146
add-job-summary-as-pr-comment: on-failure
3247

48+
- name: Gradle toolchains info
49+
run: ./gradlew -q javaToolchains
50+
3351
- name: Gradle build environment info
3452
run: ./gradlew -q buildEnvironment
3553

.github/workflows/publish-test-results.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Download Test Report
16-
uses: dawidd6/action-download-artifact@6
16+
uses: dawidd6/action-download-artifact@9
1717
with:
1818
name: junit-test-results
1919
workflow: ${{ github.event.workflow.id }}

buildSrc/src/main/kotlin/framefork.java.gradle.kts

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,6 @@ idea {
6363
}
6464
}
6565

66-
tasks.withType<JavaCompile>() {
67-
doLast {
68-
javaCompiler.getOrNull()?.also {
69-
println("Used JDK: ${it.metadata.javaRuntimeVersion} ${it.metadata.vendor}")
70-
}
71-
}
72-
}
73-
74-
tasks.withType<Test> {
75-
useJUnitPlatform()
76-
77-
testlogger {
78-
showExceptions = true
79-
showStackTraces = true
80-
showFullStackTraces = true
81-
showCauses = true
82-
showPassedStandardStreams = false
83-
showSkippedStandardStreams = false
84-
showFailedStandardStreams = true
85-
}
86-
}
87-
8866
nullaway {
8967
annotatedPackages.add("org.framefork")
9068
}
@@ -181,6 +159,12 @@ tasks.withType<JavaCompile> {
181159
"com.github.rvesse.airline.annotations.Option"
182160
))
183161
}
162+
163+
doLast {
164+
javaCompiler.getOrNull()?.also {
165+
println("Used JDK: ${it.metadata.javaRuntimeVersion} ${it.metadata.vendor}")
166+
}
167+
}
184168
}
185169

186170
tasks.withType<Javadoc> {
@@ -189,7 +173,47 @@ tasks.withType<Javadoc> {
189173
}
190174

191175
tasks.named("test") {
176+
description = "Runs the unit tests against the default JDK"
177+
}
178+
179+
for (javaVersion in listOf(21, 23, 24)) {
180+
val testTask = tasks.register<Test>("test-jdk${javaVersion}") {
181+
group = "Verification"
182+
description = "Runs the unit tests against JDK $javaVersion"
183+
184+
javaLauncher.set(javaToolchains.launcherFor {
185+
languageVersion.set(JavaLanguageVersion.of(javaVersion))
186+
})
187+
188+
testClassesDirs = sourceSets.test.get().output.classesDirs
189+
classpath = sourceSets.test.get().runtimeClasspath
190+
}
191+
192+
tasks.named("check") {
193+
dependsOn(testTask)
194+
}
195+
}
196+
197+
tasks.withType<Test>() {
192198
outputs.upToDateWhen { false }
199+
200+
useJUnitPlatform()
201+
202+
testlogger {
203+
showExceptions = true
204+
showStackTraces = true
205+
showFullStackTraces = true
206+
showCauses = true
207+
showPassedStandardStreams = false
208+
showSkippedStandardStreams = false
209+
showFailedStandardStreams = true
210+
}
211+
212+
doFirst {
213+
javaLauncher.getOrNull()?.also {
214+
println("Using JDK: ${it.metadata.javaRuntimeVersion} ${it.metadata.vendor}")
215+
}
216+
}
193217
}
194218

195219
configurations.all {

0 commit comments

Comments
 (0)