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

zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new e3a07bc609e Optimizing CI/CD with Multi-Level Isolated Caching (#38204)
e3a07bc609e is described below

commit e3a07bc609efb4a72ae0cd1ee8b659763e34fd10
Author: Hongsheng Zhong <[email protected]>
AuthorDate: Thu Feb 26 14:44:14 2026 +0800

    Optimizing CI/CD with Multi-Level Isolated Caching (#38204)
    
    * Refactor GitHub Actions cache strategy to improve cache efficiency
    
    * Refactor nightly-check.yml to use setup-java cache instead of 
actions/cache
    
    * Refactor nightly-e2e-sql.yml and nightly-e2e-agent.yml to use setup-java 
cache
    
    * Refactor remaining workflows to use setup-java cache instead of 
actions/cache
    
    * Optimize setup-build-environment with default cache-prefix
    
    * Add cache-suffix support for build scope optimization
    
    * Refine E2E cache-suffix to module-specific values
    
    * Remove duplicate actions/setup-java in e2e-operation.yml
    
    * Refactor GitHub Actions cache strategy
    
    * Add default value for cache-prefix parameter
    
    * Fix cache-prefix usage in workflows
    
    * Add GraalVM support to setup-build-environment
    
    * Fix github-token parameter passing for GraalVM setup
---
 .github/workflows/ci.yml                           |  20 +---
 .github/workflows/e2e-agent.yml                    |  27 +-----
 .github/workflows/e2e-operation.yml                |  12 +--
 .github/workflows/e2e-sql.yml                      |  27 +-----
 .github/workflows/graalvm.yml                      |  14 +--
 .github/workflows/nightly-build.yml                | 102 ++++-----------------
 .github/workflows/nightly-check.yml                |  65 ++-----------
 .github/workflows/nightly-ci.yml                   |  31 ++-----
 .github/workflows/nightly-e2e-agent.yml            |  27 +-----
 .github/workflows/nightly-e2e-operation.yml        |  12 +--
 .github/workflows/nightly-e2e-sql.yml              |  27 ++----
 .github/workflows/nightly-sql-parser.yml           |  15 +--
 .../actions/setup-build-environment/action.yml     |  94 +++++++++++++++++++
 .github/workflows/schedule-report.yml              |  34 +------
 14 files changed, 165 insertions(+), 342 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 13570502a41..7a9e7534616 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -54,26 +54,8 @@ jobs:
     timeout-minutes: 30
     steps:
       - uses: actions/[email protected]
-      - name: Setup JDK for Build
-        uses: actions/[email protected]
-        with:
-          distribution: 'temurin'
-          java-version: 17
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: apache-shardingsphere-maven-third-party-${{ 
hashFiles('**/pom.xml') }}
-          restore-keys: |
-            apache-shardingsphere-maven-third-party-
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
       - name: Build Project with Maven
         run: ./mvnw clean install -B -ntp -DskipTests -T1C
-      - name: Setup JDK for Test
-        uses: actions/[email protected]
-        with:
-          distribution: 'temurin'
-          java-version: 17
       - name: Run Tests
         run: ./mvnw install -T1C -B -ntp -fae
diff --git a/.github/workflows/e2e-agent.yml b/.github/workflows/e2e-agent.yml
index 2a7aafc7e8d..ef2db07ea2b 100644
--- a/.github/workflows/e2e-agent.yml
+++ b/.github/workflows/e2e-agent.yml
@@ -54,24 +54,14 @@ jobs:
     timeout-minutes: 20
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
           java-version: 21
+          cache-suffix: 'e2e-agent'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
           set-host: true
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: apache-shardingsphere-maven-third-party-e2e-cache-${{ 
github.sha }}
-          restore-keys: |
-            apache-shardingsphere-maven-third-party-e2e-cache-
-            apache-shardingsphere-maven-third-party-
       - name: Build Project
         run: ./mvnw -B clean install -DskipTests -Prelease,default-dep
       - name: Build Proxy E2E Image
@@ -130,23 +120,14 @@ jobs:
             plugin: zipkin
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
           java-version: 21
+          cache-suffix: 'e2e-agent'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
           set-host: true
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: apache-shardingsphere-maven-third-party-${{ 
hashFiles('**/pom.xml') }}
-          restore-keys: |
-            apache-shardingsphere-maven-third-party-
       - name: Download Proxy E2E Image
         if: matrix.adapter == 'proxy'
         uses: actions/download-artifact@v4
diff --git a/.github/workflows/e2e-operation.yml 
b/.github/workflows/e2e-operation.yml
index b8a62beef2e..7becf906a78 100644
--- a/.github/workflows/e2e-operation.yml
+++ b/.github/workflows/e2e-operation.yml
@@ -57,11 +57,9 @@ jobs:
     timeout-minutes: 40
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
-          cache: 'maven'
+          cache-suffix: 'e2e-operation'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
@@ -105,11 +103,9 @@ jobs:
     steps:
       - name: Checkout Project
         uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
-          cache: 'maven'
+          cache-suffix: 'e2e-operation'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
diff --git a/.github/workflows/e2e-sql.yml b/.github/workflows/e2e-sql.yml
index b1d3f897011..679efc21f0c 100644
--- a/.github/workflows/e2e-sql.yml
+++ b/.github/workflows/e2e-sql.yml
@@ -58,24 +58,13 @@ jobs:
     timeout-minutes: 40
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
+          cache-suffix: 'e2e-sql'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
           set-host: true
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: apache-shardingsphere-maven-third-party-e2e-cache-${{ 
github.sha }}
-          restore-keys: |
-            apache-shardingsphere-maven-third-party-e2e-cache-
-            apache-shardingsphere-maven-third-party-
       - name: Build E2E Image
         run: ./mvnw -B clean install -am -pl test/e2e/sql -Pe2e.env.docker 
-DskipTests -Dspotless.apply.skip=true
       - name: Save E2E Image
@@ -122,17 +111,9 @@ jobs:
             scenario: passthrough
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: apache-shardingsphere-maven-third-party-e2e-cache-${{ 
github.sha }}
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
+          cache-suffix: 'e2e-sql'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
diff --git a/.github/workflows/graalvm.yml b/.github/workflows/graalvm.yml
index 90c8bad055d..090a121f6cd 100644
--- a/.github/workflows/graalvm.yml
+++ b/.github/workflows/graalvm.yml
@@ -58,19 +58,13 @@ jobs:
         run: |
           ./test/native/src/test/resources/test-native/ps1/config-rdctl.ps1
           "PATH=$env:PATH" >> $env:GITHUB_ENV
-      - uses: graalvm/setup-graalvm@v1
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
           java-version: ${{ matrix.java-version }}
-          distribution: 'graalvm-community'
+          distribution: 'graalvm'
           github-token: ${{ secrets.GITHUB_TOKEN }}
-          native-image-job-reports: 'true'
-      - uses: actions/[email protected]
-        with:
-          path: ~/.m2/repository
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-${{ github.sha }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
+          cache-suffix: 'native-test'
       # TODO Remove this workaround after. The graalvm native image built with 
windows server is missing some GRMs for testcontainers
       - name: Run test with GraalVM CE
         if: matrix.os == 'windows-latest'
diff --git a/.github/workflows/nightly-build.yml 
b/.github/workflows/nightly-build.yml
index 0e0a7c7c9fa..b1341bb948c 100644
--- a/.github/workflows/nightly-build.yml
+++ b/.github/workflows/nightly-build.yml
@@ -46,28 +46,17 @@ jobs:
     runs-on: ubuntu-latest
     timeout-minutes: 60
     steps:
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-${{ github.sha }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - name: Build Project
         run: |
           ./mvnw -B clean install -Prelease,default-dep
       - name: Upload Proxy Tarball Artifact
         uses: actions/upload-artifact@v4
         with:
-          name: proxy-tarball-${{ github.sha }}
+          name: proxy-tarball-${{ github.run_id }}
           path: distribution/proxy/target/apache-shardingsphere-*.tar.gz
           if-no-files-found: error
           retention-days: 7
@@ -85,20 +74,9 @@ jobs:
       - uses: actions/[email protected]
         with:
           ref: ${{ inputs.commit-id }}
-      - uses: actions/[email protected]
-        with:
-          distribution: 'temurin'
-          java-version: 17
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-${{ github.sha }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - name: Login Container Registry
         uses: docker/login-action@v3
         with:
@@ -108,7 +86,7 @@ jobs:
       - uses: docker/setup-qemu-action@v3
       - uses: docker/setup-buildx-action@v3
       - name: Push Docker Image
-        run: ./mvnw -am -pl distribution/proxy -B 
-Prelease,default-dep,docker.buildx.push -DskipTests 
-Dproxy.image.repository=${{ env.PROXY }} -Dproxy.image.tag=${{ github.sha }} 
clean install
+        run: ./mvnw -am -pl distribution/proxy -B 
-Prelease,default-dep,docker.buildx.push -DskipTests 
-Dproxy.image.repository=${{ env.PROXY }} -Dproxy.image.tag=${{ github.run_id 
}} clean install
   
   build-proxy-native-image:
     if: github.repository == 'apache/shardingsphere'
@@ -126,36 +104,25 @@ jobs:
       - uses: actions/[email protected]
         with:
           ref: ${{ inputs.commit-id }}
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - uses: docker/login-action@v3
         with:
           registry: ${{ env.HUB }}
           username: ${{ github.actor }}
           password: ${{ secrets.GITHUB_TOKEN }}
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-${{ github.sha }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
       - name: Push dynamic linked Docker Image by x64 or arm64
         run: |
-          ./mvnw -am -pl distribution/proxy-native -T1C 
"-Pdocker.push.native.linux" -Dproxy.native.image.repository=${{ 
env.PROXY_NATIVE }} -Dproxy.native.image.tag=${{ github.sha }} "-DskipTests" 
clean package
+          ./mvnw -am -pl distribution/proxy-native -T1C 
"-Pdocker.push.native.linux" -Dproxy.native.image.repository=${{ 
env.PROXY_NATIVE }} -Dproxy.native.image.tag=${{ github.run_id }} "-DskipTests" 
clean package
       - name: Push mostly static linked Docker Image by x64
         if: matrix.os == 'ubuntu-latest'
         run: |
-          ./mvnw -am -pl distribution/proxy-native -T1C 
"-Pdocker.push.native.linux" -Dproxy.native.image.repository=${{ 
env.PROXY_NATIVE }} -Dproxy.native.image.tag=${{ github.sha }}-mostly 
"-Dproxy.native.dockerfile=Dockerfile-linux-mostly" "-DskipTests" clean package
+          ./mvnw -am -pl distribution/proxy-native -T1C 
"-Pdocker.push.native.linux" -Dproxy.native.image.repository=${{ 
env.PROXY_NATIVE }} -Dproxy.native.image.tag=${{ github.run_id }}-mostly 
"-Dproxy.native.dockerfile=Dockerfile-linux-mostly" "-DskipTests" clean package
       - name: Push fully static linked Docker Image by x64
         if: matrix.os == 'ubuntu-latest'
         run: |
-          ./mvnw -am -pl distribution/proxy-native -T1C 
"-Pdocker.push.native.linux" -Dproxy.native.image.repository=${{ 
env.PROXY_NATIVE }} -Dproxy.native.image.tag=${{ github.sha }}-static 
"-Dproxy.native.dockerfile=Dockerfile-linux-static" "-DskipTests" clean package
+          ./mvnw -am -pl distribution/proxy-native -T1C 
"-Pdocker.push.native.linux" -Dproxy.native.image.repository=${{ 
env.PROXY_NATIVE }} -Dproxy.native.image.tag=${{ github.run_id }}-static 
"-Dproxy.native.dockerfile=Dockerfile-linux-static" "-DskipTests" clean package
 
   build-agent-image:
     if: github.repository == 'apache/shardingsphere'
@@ -170,28 +137,17 @@ jobs:
       - uses: actions/[email protected]
         with:
           ref: ${{ inputs.commit-id }}
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - uses: docker/login-action@v3
         with:
           registry: ${{ env.HUB }}
           username: ${{ github.actor }}
           password: ${{ secrets.GITHUB_TOKEN }}
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-${{ github.sha }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
       - name: Push Docker Image
         run: |
-          ./mvnw -am -pl distribution/agent 
-Prelease,default-dep,docker.buildx.push -B -T1C -DskipTests 
-Dagent.image.repository=${{ env.AGENT }} -Dagent.image.tag=${{ github.sha }} 
clean package
+          ./mvnw -am -pl distribution/agent 
-Prelease,default-dep,docker.buildx.push -B -T1C -DskipTests 
-Dagent.image.repository=${{ env.AGENT }} -Dagent.image.tag=${{ github.run_id 
}} clean package
   
   build-cache:
     if: github.repository == 'apache/shardingsphere'
@@ -201,19 +157,9 @@ jobs:
     timeout-minutes: 15
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
-        with:
-          distribution: 'temurin'
-          java-version: 17
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-${{ hashFiles('**/pom.xml') }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - name: Build with Maven
         run: ./mvnw clean install -B -ntp -T1C -DskipTests
   
@@ -265,23 +211,13 @@ jobs:
         options: --health-cmd="echo ruok | nc localhost 2181" 
--health-interval=10s --health-timeout=5s --health-retries=3
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
           set-host: true
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-${{ hashFiles('**/pom.xml') }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
       - name: Build with Maven
         run: ./mvnw -B -T1C -ntp clean install -DskipITs -DskipTests
       - name: Generate Examples
@@ -305,7 +241,7 @@ jobs:
       - name: Upload Generated Example Artifact
         uses: actions/upload-artifact@v4
         with:
-          name: example-${{ matrix.feature }}--${{ matrix.framework }}--${{ 
matrix.mode }}--${{ matrix.transaction }}--${{ github.sha }}
+          name: example-${{ matrix.feature }}--${{ matrix.framework }}--${{ 
matrix.mode }}--${{ matrix.transaction }}--${{ github.run_id }}
           path: 
examples/shardingsphere-jdbc-example-generator/target/generated-sources/shardingsphere-jdbc-sample/${{
 matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ 
matrix.transaction }}.tar.gz
           if-no-files-found: error
           retention-days: 7
diff --git a/.github/workflows/nightly-check.yml 
b/.github/workflows/nightly-check.yml
index e0f3801e99e..3e746c54262 100644
--- a/.github/workflows/nightly-check.yml
+++ b/.github/workflows/nightly-check.yml
@@ -38,15 +38,9 @@ jobs:
     timeout-minutes: 60
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-${{ hashFiles('**/pom.xml') }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - name: Run SpotBugs
         run: ./mvnw clean install spotbugs:check -Pcheck -T1C
   
@@ -91,23 +85,13 @@ jobs:
       security-events: write
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - name: Initialize CodeQL
         uses: github/codeql-action/init@v3
         with:
           languages: java
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-${{ hashFiles('**/pom.xml') }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
       - name: Install Project
         run: |
           ./mvnw clean install -DskipTests -B -ntp -T1C
@@ -147,15 +131,9 @@ jobs:
     timeout-minutes: 60
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-${{ hashFiles('**/pom.xml') }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - name: Run Dependency Convergence Check
         run: |
           sed -i '/<requireMavenVersion>/i \                                   
 <dependencyConvergence/>' pom.xml
@@ -169,15 +147,9 @@ jobs:
     timeout-minutes: 40
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-${{ hashFiles('**/pom.xml') }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - name: Run OWASP Check
         # https://nvd.nist.gov/developers/request-an-api-key
         run: ./mvnw clean dependency-check:aggregate -DnvdApiKey=${{ 
secrets.NIST_NVD_API_KEY }}
@@ -196,28 +168,9 @@ jobs:
     timeout-minutes: 80
     steps:
       - uses: actions/[email protected]
-      - name: Setup JDK
-        uses: actions/[email protected]
-        with:
-          distribution: temurin
-          java-version: 17
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: shardingsphere-maven-third-party-e2e-cache-${{ github.sha }}
-          restore-keys: |
-            shardingsphere-maven-third-party-e2e-cache-
-            shardingsphere-maven-third-party-
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
       - name: Install Project
         run: ./mvnw clean install -DskipTests -T1C
-      - name: Set up JDK for Jacoco
-        uses: actions/[email protected]
-        with:
-          distribution: temurin
-          java-version: 17
       - name: Build with maven and execute jacoco aggregation script
         run: |
           ./mvnw -V -B -ntp verify -Djacoco.skip=false 
-Dmaven.test.failure.ignore=true -DfailIfNoTests=false 
-Dsurefire.failIfNoSpecifiedTests=false &&
diff --git a/.github/workflows/nightly-ci.yml b/.github/workflows/nightly-ci.yml
index 6706c048811..a615f4532dc 100644
--- a/.github/workflows/nightly-ci.yml
+++ b/.github/workflows/nightly-ci.yml
@@ -47,20 +47,10 @@ jobs:
         if: matrix.os == 'windows-latest'
         run: git config --global core.longpaths true
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
           java-version: ${{ matrix.java-version }}
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-${{ github.sha }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - name: Build Project with Maven
         run: ./mvnw clean install -B -ntp -T1C
       - name: Build Examples with Maven
@@ -87,22 +77,13 @@ jobs:
         run: |
           ./test/native/src/test/resources/test-native/ps1/config-rdctl.ps1
           "PATH=$env:PATH" >> $env:GITHUB_ENV
-      - uses: graalvm/setup-graalvm@v1
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
           java-version: '24.0.2'
-          distribution: 'graalvm-community'
+          distribution: 'graalvm'
           github-token: ${{ secrets.GITHUB_TOKEN }}
-          native-image-job-reports: 'true'
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-${{ github.sha }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
+          cache-suffix: 'native-test'
       # TODO Remove this workaround after. The graalvm native image built with 
windows server is missing some GRMs for testcontainers
       - name: Run test with GraalVM CE
         if: matrix.os == 'windows-latest'
diff --git a/.github/workflows/nightly-e2e-agent.yml 
b/.github/workflows/nightly-e2e-agent.yml
index 361b982563a..0dc9423826a 100644
--- a/.github/workflows/nightly-e2e-agent.yml
+++ b/.github/workflows/nightly-e2e-agent.yml
@@ -42,24 +42,14 @@ jobs:
     timeout-minutes: 40
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
           java-version: 21
+          cache-suffix: 'e2e-agent'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
           set-host: true
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: apache-shardingsphere-maven-third-party-e2e-cache-${{ 
github.sha }}
-          restore-keys: |
-            apache-shardingsphere-maven-third-party-e2e-cache-
-            apache-shardingsphere-maven-third-party-
       - name: Build Project
         run: ./mvnw -B clean install -DskipTests -Prelease,default-dep
       - name: Build Proxy E2E Image
@@ -118,23 +108,14 @@ jobs:
             plugin: zipkin
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
           java-version: 21
+          cache-suffix: 'e2e-agent'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
           set-host: true
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: apache-shardingsphere-maven-third-party-${{ 
hashFiles('**/pom.xml') }}
-          restore-keys: |
-            apache-shardingsphere-maven-third-party-
       - name: Download Proxy E2E Image
         if: matrix.adapter == 'proxy'
         uses: actions/download-artifact@v4
diff --git a/.github/workflows/nightly-e2e-operation.yml 
b/.github/workflows/nightly-e2e-operation.yml
index eeca8dc003c..b264f59cf97 100644
--- a/.github/workflows/nightly-e2e-operation.yml
+++ b/.github/workflows/nightly-e2e-operation.yml
@@ -47,11 +47,9 @@ jobs:
     timeout-minutes: 40
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
-          cache: 'maven'
+          cache-suffix: 'e2e-operation'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
@@ -99,12 +97,10 @@ jobs:
             image: { type: "e2e.docker.database.opengauss.images", version: 
"opengauss/opengauss:3.1.0" }
     steps:
       - uses: actions/[email protected]
-      - name: Setup JDK ${{ matrix.java-version }}
-        uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
           java-version: ${{ matrix.java-version }}
-          cache: 'maven'
+          cache-suffix: 'e2e'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
diff --git a/.github/workflows/nightly-e2e-sql.yml 
b/.github/workflows/nightly-e2e-sql.yml
index 8aa0f37f129..42436bcf4b0 100644
--- a/.github/workflows/nightly-e2e-sql.yml
+++ b/.github/workflows/nightly-e2e-sql.yml
@@ -42,24 +42,15 @@ jobs:
     timeout-minutes: 40
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
           java-version: 21
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
+          cache-suffix: 'e2e-sql'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
           set-host: true
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-e2e-cache-${{ github.sha }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-e2e-cache-
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
       - name: Build E2E Image
         run: ./mvnw -B clean install -am -pl test/e2e/sql -Pe2e.env.docker 
-DskipTests -Dspotless.apply.skip=true
       - name: Save E2E Image
@@ -112,17 +103,11 @@ jobs:
             scenario: passthrough
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-e2e-cache-${{ github.sha }}
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
           java-version: 21
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
+          cache-suffix: 'e2e-sql'
       - uses: docker/setup-docker-action@v4
         with:
           version: v28.0.4
diff --git a/.github/workflows/nightly-sql-parser.yml 
b/.github/workflows/nightly-sql-parser.yml
index c5d91d64381..824178c80dc 100644
--- a/.github/workflows/nightly-sql-parser.yml
+++ b/.github/workflows/nightly-sql-parser.yml
@@ -44,20 +44,9 @@ jobs:
         database: [ mysql, postgresql ]
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-${{ github.sha }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-cache-
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - name: Build Project with Maven
         run: ./mvnw -T1C -B -ntp clean install
       - name: Run SQL Parser
diff --git 
a/.github/workflows/resources/actions/setup-build-environment/action.yml 
b/.github/workflows/resources/actions/setup-build-environment/action.yml
new file mode 100644
index 00000000000..70a91968182
--- /dev/null
+++ b/.github/workflows/resources/actions/setup-build-environment/action.yml
@@ -0,0 +1,94 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+name: 'Setup Build Environment'
+description: |
+  Setup Java and Maven cache for ShardingSphere builds.
+
+  This action configures Java environment and sets up Maven dependency caching
+  with support for multi-project isolation and build scope optimization.
+
+  Usage:
+    - uses: ./.github/workflows/resources/actions/setup-build-environment
+
+    - uses: ./.github/workflows/resources/actions/setup-build-environment
+      with:
+        java-version: '21'
+        cache-suffix: 'e2e-sql'
+
+  Cache key format: {cache-prefix}-maven-{cache-suffix}-{pom.xml hash}
+  Default cache-prefix: 'apache-shardingsphere'
+  Default cache-suffix: 'full'
+
+inputs:
+  java-version:
+    description: 'Java version to setup (default: 17)'
+    required: false
+    default: '17'
+  distribution:
+    description: 'Java distribution (default: temurin)'
+    required: false
+    default: 'temurin'
+  cache-prefix:
+    description: |
+      Cache key prefix for multi-project isolation.
+      Used to separate caches between different projects or forks.
+      Default: 'apache-shardingsphere'
+    required: false
+    default: 'apache-shardingsphere'
+  cache-suffix:
+    description: |
+      Cache key suffix for build scope optimization.
+      Examples: 'full' for full build, 'e2e-sql' for E2E SQL tests, 
'e2e-agent' for E2E Agent tests.
+      Different suffixes allow separate caches for different build scopes 
while maintaining fallback chain.
+      Default: 'full'
+    required: false
+    default: 'full'
+  github-token:
+    description: 'GitHub token for GraalVM setup (required when distribution 
is graalvm)'
+    required: false
+    default: ''
+
+runs:
+  using: composite
+  steps:
+    - name: Setup Java (Temurin)
+      if: inputs.distribution != 'graalvm'
+      uses: actions/[email protected]
+      with:
+        distribution: ${{ inputs.distribution }}
+        java-version: ${{ inputs.java-version }}
+    - name: Setup GraalVM
+      if: inputs.distribution == 'graalvm'
+      uses: graalvm/setup-graalvm@v1
+      with:
+        distribution: 'graalvm-community'
+        java-version: ${{ inputs.java-version }}
+        github-token: ${{ inputs.github-token }}
+        native-image-job-reports: 'true'
+    - uses: actions/[email protected]
+      with:
+        path: |
+          ~/.m2/repository
+          !~/.m2/repository/org/apache/shardingsphere
+          ~/.m2/repository/org/apache/shardingsphere/elasticjob
+        key: ${{ inputs.cache-prefix }}-maven-${{ inputs.cache-suffix }}-${{ 
hashFiles('**/pom.xml') }}
+        restore-keys: |
+          ${{ inputs.cache-prefix }}-maven-${{ inputs.cache-suffix }}-
+          ${{ inputs.cache-prefix }}-maven-full-
+          ${{ inputs.cache-prefix }}-maven-
+          ${{ inputs.cache-prefix }}-
diff --git a/.github/workflows/schedule-report.yml 
b/.github/workflows/schedule-report.yml
index eaf9af37305..931541a6e7a 100644
--- a/.github/workflows/schedule-report.yml
+++ b/.github/workflows/schedule-report.yml
@@ -38,24 +38,14 @@ jobs:
     timeout-minutes: 40
     steps:
       - uses: actions/[email protected]
-      - uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: 'temurin'
-          java-version: 17
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - uses: actions/[email protected]
         with:
           path: ~/.sonar/cache
           key: ${{ runner.os }}-sonar
           restore-keys: ${{ runner.os }}-sonar
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-${{ hashFiles('pom.xml','*/pom.xml') }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
       - name: Analyze with SonarCloud
         env:
           MAVEN_OPTS: "-XX:+UseG1GC -XX:InitialHeapSize=2g -XX:MaxHeapSize=6g 
-XX:+UseStringDeduplication"
@@ -71,27 +61,11 @@ jobs:
     timeout-minutes: 60
     steps:
       - uses: actions/[email protected]
-      - name: Setup JDK
-        uses: actions/[email protected]
+      - uses: ./.github/workflows/resources/actions/setup-build-environment
         with:
-          distribution: temurin
-          java-version: 17
-      - uses: actions/[email protected]
-        with:
-          path: |
-            ~/.m2/repository
-            !~/.m2/repository/org/apache/shardingsphere
-            ~/.m2/repository/org/apache/shardingsphere/elasticjob
-          key: ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-${{ hashFiles('pom.xml','*/pom.xml') }}
-          restore-keys: |
-            ${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX 
}}-maven-third-party-
+          cache-prefix: ${{ 
needs.global-environment.outputs.GLOBAL_CACHE_PREFIX }}
       - name: Install Project
         run: ./mvnw clean install -DskipTests -T1C
-      - name: Set up JDK for Jacoco
-        uses: actions/[email protected]
-        with:
-          distribution: temurin
-          java-version: 17
       - name: Build with maven and execute jacoco aggregation script
         run: |
           ./mvnw -V -B -ntp verify -Djacoco.skip=false 
-Dmaven.test.failure.ignore=true -DfailIfNoTests=false 
-Dsurefire.failIfNoSpecifiedTests=false &&


Reply via email to