You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2026/10/08 03:16:51 UTC

(spark-kubernetes-operator) branch main updated: [SPARK-60068] Run unit tests on each matrix JDK and skip linters in `build-test` CI

This is an automated email from the ASF dual-hosted git repository.

dongjoon-hyun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 1e909c26 [SPARK-60068] Run unit tests on each matrix JDK and skip linters in `build-test` CI
1e909c26 is described below

commit 1e909c26da9978b8ef4f1fa474321724bb1074fc
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Wed Oct 7 20:16:44 2026 -0700

    [SPARK-60068] Run unit tests on each matrix JDK and skip linters in `build-test` CI
    
    ### What changes were proposed in this pull request?
    
    This PR aims to run the `build-test` CI unit tests on each matrix JDK (21 / 25 / 26 / 27) instead of repeating the full build in every leg.
    
    - Add an opt-in Gradle property, `-PtestJavaVersion=<N>`, to run the `test` tasks on JDK `<N>`. Compilation still uses the JDK 27 toolchain.
    - Run `./gradlew test -PtestJavaVersion=${{ matrix.java-version }}` instead of `./gradlew build` in the `build-test` matrix. The linters keep running once in the `lint` job.
    
    ### Why are the changes needed?
    
    Currently, all matrix legs run the unit tests on the auto-provisioned JDK 27 toolchain, so Java 21, 25, and 26 are never tested. Also, every leg repeats the linters, which already run in the `lint` job.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No. The default behavior is unchanged without the new property.
    
    ### How was this patch tested?
    
    Pass the CIs. I also verified locally that all unit tests pass on JDK 21, 25, and 26 with the new property.
    
    ```
    $ ./gradlew test -PtestJavaVersion=21
    ```
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Opus 5.5
    
    Closes #956 from dongjoon-hyun/SPARK-60068.
    
    Authored-by: Dongjoon Hyun <do...@apache.org>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 .github/workflows/build_and_test.yml | 4 ++--
 AGENTS.md                            | 6 ++++--
 build.gradle                         | 7 +++++++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml
index a65a3edf..1d9d7679 100644
--- a/.github/workflows/build_and_test.yml
+++ b/.github/workflows/build_and_test.yml
@@ -46,12 +46,12 @@ jobs:
         uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb
         with:
           cache-provider: basic
-      - name: Build with Gradle
+      - name: Run unit tests
         run: |
           if [[ "${{ matrix.java-version }}" == "25" || "${{ matrix.java-version }}" == "26" ]]; then
             export JDK_JAVA_OPTIONS="-XX:+UseCompactObjectHeaders"
           fi
-          ./gradlew build
+          ./gradlew test -PtestJavaVersion=${{ matrix.java-version }}
   build-image:
     name: "Build Operator Image CI"
     runs-on: ubuntu-26.04
diff --git a/AGENTS.md b/AGENTS.md
index 4992f41a..10c450cf 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -40,7 +40,7 @@ there, never inline in a module.
 **Requirements**
 
 - **JDK 21 or newer** — the Gradle toolchain auto-provisions JDK 27 and targets Java 21 bytecode;
-  CI builds on Java 21 / 25 / 26 / 27.
+  CI runs unit tests on Java 21 / 25 / 26 / 27.
 - **Docker** — required for `./gradlew buildDockerImage`.
 - **Kubernetes cluster** (e.g. minikube), **Helm 3**, and **kubectl** — to deploy and run the
   operator.
@@ -76,6 +76,7 @@ toolchain provisions JDK 27, so a JDK 21+ is required.
 ./gradlew build                  # Full build: compile, linters, and all unit tests
 ./gradlew :spark-operator:test   # Run a single module's tests
 ./gradlew :spark-operator:test --tests "org.apache.spark.k8s.operator.SparkOperatorTest"  # one class
+./gradlew test -PtestJavaVersion=21  # Run unit tests on JDK 21 (compilation still uses JDK 27)
 ./gradlew spotlessApply          # Auto-format sources (run before committing)
 ./gradlew spotlessCheck          # Verify formatting only
 ./gradlew javadoc                # Generate Javadoc (CI gate)
@@ -112,7 +113,8 @@ chainsaw test --test-dir ./tests/e2e/state-transition --parallel 1
 ```
 
 `./gradlew build` runs the full quality gate locally — Checkstyle, PMD, SpotBugs, Spotless, and
-JaCoCo. Run it before pushing; CI runs the same matrix on Java 21 / 25 / 26 / 27 (x86 and arm).
+JaCoCo. Run it before pushing; CI runs the quality gate once and the unit tests on
+Java 21 / 25 / 26 / 27 (x86 and arm) via `-PtestJavaVersion`.
 
 ## Code Style
 
diff --git a/build.gradle b/build.gradle
index c417e373..fd5efa83 100644
--- a/build.gradle
+++ b/build.gradle
@@ -171,6 +171,13 @@ subprojects {
 
   test {
     useJUnitPlatform()
+    // Run unit tests on another JDK than the toolchain, e.g. `-PtestJavaVersion=21`
+    def testJavaVersion = providers.gradleProperty("testJavaVersion")
+    if (testJavaVersion.present) {
+      javaLauncher = javaToolchains.launcherFor {
+        languageVersion = JavaLanguageVersion.of(testJavaVersion.get())
+      }
+    }
   }
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org