Skip to content

Commit 31e51b0

Browse files
committed
Run the tests on JDK 25, 26 and 27 as well
The formatter parses with the javac of the JDK it runs on, so a change can pass on 21 and break on a newer JDK. A new `jdk` job runs the tests of `build` on 25, 26 and 27, in parallel with the other jobs; nothing waits for it. -PjavaRuntime sets baseline's javaVersions.runtime, which moves only the test JVMs: the code is still compiled for Java 21 by JDK 21. The IntelliJ plugin's tests keep the runtime of the IDE they start. `build` keeps JDK 21 and its name, which the ruleset on main requires.
1 parent a2c8970 commit 31e51b0

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,49 @@ jobs:
3737
annotate_only: true
3838
job_summary: true
3939

40+
# The tests of `build` on the newer JDKs, in parallel with everything else: nothing waits for these
41+
# jobs and nothing they build is kept. The code is still compiled for Java 21 by JDK 21, as in the
42+
# release; -PjavaRuntime moves only the test JVMs, and with them the javac whose internals the
43+
# formatter parses with. The IntelliJ plugin's tests stay on the runtime of the IDE they start.
44+
# JDK 21 itself is `build`, the check the main branch requires.
45+
jdk:
46+
name: build (JDK ${{ matrix.jdk }})
47+
runs-on: ubuntu-latest
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
jdk: [25, 26, 27]
52+
steps:
53+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
54+
55+
- name: Install JDK ${{ matrix.jdk }} for the tests
56+
id: test-jdk
57+
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
58+
with:
59+
distribution: temurin
60+
java-version: ${{ matrix.jdk }}
61+
62+
# Installed last, so that it is the JAVA_HOME Gradle runs and compiles on.
63+
- name: Install JDK 21
64+
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
65+
with:
66+
distribution: temurin
67+
java-version: '21'
68+
69+
# Gradle does not look into the runner's tool cache, so it is told where the test JDK is.
70+
- name: Build
71+
run: >-
72+
./gradlew test -PjavaRuntime=${{ matrix.jdk }}
73+
-Porg.gradle.java.installations.paths=${{ steps.test-jdk.outputs.path }}
74+
75+
- name: Publish Test Report
76+
uses: mikepenz/action-junit-report@a9170d5795813c01ab4901ffb045b52bab4ab09d # v6.5.0
77+
if: ${{ !cancelled() }}
78+
with:
79+
report_paths: '**/build/test-results/test/*.xml'
80+
annotate_only: true
81+
job_summary: true
82+
4083
# One explicit job per target, so every binary we ship is traceable to a named run.
4184
native:
4285
name: native (${{ matrix.platform }})

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ mise trust && mise install
119119
./gradlew test # what the CI build job runs
120120
```
121121

122+
`-PjavaRuntime=25` runs the same tests on JDK 25, as CI's `jdk` jobs do for 25, 26 and 27. The code
123+
is compiled for Java 21 either way. Gradle has to find that JDK: installed with mise, or named with
124+
`-Porg.gradle.java.installations.paths=/path/to/jdk`.
125+
122126
Nothing inside the build downloads a JDK. `gradle.properties` turns toolchain auto-download off and
123127
reads the installations from `JDK21_HOME` and `GRAALVM_HOME`, so a missing JDK is an error you can
124128
read rather than a silent download.

‎build.gradle‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,7 @@ subprojects {
129129

130130
javaVersions {
131131
libraryTarget = 21
132-
runtime = 21
132+
// The JDK the tests run on, and with it the javac whose internals the formatter parses with. The code is
133+
// compiled for 21 whatever this says. CI's `jdk` jobs pass -PjavaRuntime=25 and so on.
134+
runtime = providers.gradleProperty('javaRuntime').getOrElse('21')
133135
}

0 commit comments

Comments
 (0)