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

snuyanzin pushed a commit to branch release-2.3
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-2.3 by this push:
     new 7757f2ce50d [FLINK-40124][ci] Do not store cache on every run if no 
dependency changed
7757f2ce50d is described below

commit 7757f2ce50dcb1a4f0c421305aa704b63823005c
Author: Sergey Nuyanzin <[email protected]>
AuthorDate: Mon Jul 13 16:51:37 2026 +0200

    [FLINK-40124][ci] Do not store cache on every run if no dependency changed
---
 .github/actions/job_init/action.yml     | 21 ++++++++++++++++----
 .github/workflows/template.flink-ci.yml | 34 +++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/.github/actions/job_init/action.yml 
b/.github/actions/job_init/action.yml
index a56238be3c6..ea44331507d 100644
--- a/.github/actions/job_init/action.yml
+++ b/.github/actions/job_init/action.yml
@@ -38,6 +38,13 @@ inputs:
     description: "Runs tools/azure-pipelines/free_disk_space.sh to remove 
unneeded pre-installed software from the runner (only works for jobs that run 
directly on the host, not in a container)."
     required: false
     default: "false"
+outputs:
+  maven-cache-hit:
+    description: "Whether the Maven package cache was restored via an exact 
key match. Callers should only save a new cache when this is not 'true'."
+    value: ${{ steps.maven-cache-restore.outputs.cache-hit }}
+  maven-cache-key:
+    description: "The cache key computed for the Maven package cache, for use 
by a caller's own explicit save step (placed after Maven has actually run)."
+    value: ${{ steps.maven-cache-key.outputs.key }}
 runs:
   using: "composite"
   steps:
@@ -105,14 +112,20 @@ runs:
         echo "namespace=${ns}" >> "${GITHUB_OUTPUT}"
         echo "Cache namespace: ${ns}"
 
-    - name: "Setup Maven package cache"
+    - name: "Compute Maven package cache key"
       if: ${{ inputs.maven_repo_folder != '' }}
-      uses: actions/cache@v5
+      id: maven-cache-key
+      shell: bash
+      run: echo "key=${{ runner.os }}-ns-${{ steps.cache-ns.outputs.namespace 
}}-maven-${{ hashFiles('**/pom.xml') }}" >> "${GITHUB_OUTPUT}"
+
+    - name: "Restore Maven package cache"
+      if: ${{ inputs.maven_repo_folder != '' }}
+      id: maven-cache-restore
+      uses: actions/cache/restore@v6
       with:
         path: ${{ inputs.maven_repo_folder }}
-        key: ${{ runner.os }}-ns-${{ steps.cache-ns.outputs.namespace 
}}-maven-${{ hashFiles('**/pom.xml') }}-${{ github.run_id }}
+        key: ${{ steps.maven-cache-key.outputs.key }}
         restore-keys: |
-          ${{ runner.os }}-ns-${{ steps.cache-ns.outputs.namespace 
}}-maven-${{ hashFiles('**/pom.xml') }}-
           ${{ runner.os }}-ns-${{ steps.cache-ns.outputs.namespace }}-maven-
           ${{ runner.os }}-maven-
 
diff --git a/.github/workflows/template.flink-ci.yml 
b/.github/workflows/template.flink-ci.yml
index 9d668f68641..d8158084f1b 100644
--- a/.github/workflows/template.flink-ci.yml
+++ b/.github/workflows/template.flink-ci.yml
@@ -88,6 +88,7 @@ jobs:
           persist-credentials: false
 
       - name: "Initialize job"
+        id: job-init
         uses: "./.github/actions/job_init"
         with:
           jdk_version: ${{ inputs.jdk_version }}
@@ -123,6 +124,15 @@ jobs:
           # use minimum here because we only need these artifacts to speed up 
the build
           retention-days: 1
 
+      # Only saves when the restore in job_init wasn't an exact hit, i.e. 
pom.xml actually
+      # changed since the last save for this namespace - avoids re-uploading 
an unchanged cache.
+      - name: "Save Maven package cache"
+        if: ${{ !cancelled() && steps.job-init.outputs.maven-cache-hit != 
'true' }}
+        uses: actions/cache/save@v6
+        with:
+          path: ${{ env.MAVEN_REPO_FOLDER }}
+          key: ${{ steps.job-init.outputs.maven-cache-key }}
+
   packaging:
     name: "Test packaging/licensing"
     needs: compile
@@ -140,6 +150,7 @@ jobs:
           persist-credentials: false
 
       - name: "Initialize job"
+        id: job-init
         uses: "./.github/actions/job_init"
         with:
           jdk_version: ${{ inputs.jdk_version }}
@@ -163,6 +174,13 @@ jobs:
         run: |
           ${{ inputs.environment }} ./tools/ci/compile_ci.sh || exit $?
 
+      - name: "Save Maven package cache"
+        if: ${{ !cancelled() && steps.job-init.outputs.maven-cache-hit != 
'true' }}
+        uses: actions/cache/save@v6
+        with:
+          path: ${{ env.MAVEN_REPO_FOLDER }}
+          key: ${{ steps.job-init.outputs.maven-cache-key }}
+
   test:
     name: "Test (module: ${{ matrix.module }})"
     needs: compile
@@ -202,6 +220,7 @@ jobs:
           persist-credentials: false
 
       - name: "Initialize job"
+        id: job-init
         uses: "./.github/actions/job_init"
         with:
           jdk_version: ${{ inputs.jdk_version }}
@@ -305,6 +324,13 @@ jobs:
         if: ${{ !cancelled() && (failure() || 
steps.docker-cache.outputs.cache-hit != 'true') }}
         run: ./tools/azure-pipelines/cache_docker_images.sh save
 
+      - name: "Save Maven package cache"
+        if: ${{ !cancelled() && steps.job-init.outputs.maven-cache-hit != 
'true' }}
+        uses: actions/cache/save@v6
+        with:
+          path: ${{ env.MAVEN_REPO_FOLDER }}
+          key: ${{ steps.job-init.outputs.maven-cache-key }}
+
   e2e:
     name: "E2E (group ${{ matrix.group }})"
     needs: compile
@@ -339,6 +365,7 @@ jobs:
           persist-credentials: false
 
       - name: "Initialize job"
+        id: job-init
         uses: "./.github/actions/job_init"
         with:
           jdk_version: ${{ inputs.jdk_version }}
@@ -432,3 +459,10 @@ jobs:
       - name: "Save Docker images to Cache"
         if: ${{ !cancelled() && (failure() || 
steps.docker-cache.outputs.cache-hit != 'true') }}
         run: ./tools/azure-pipelines/cache_docker_images.sh save
+
+      - name: "Save Maven package cache"
+        if: ${{ !cancelled() && steps.job-init.outputs.maven-cache-hit != 
'true' }}
+        uses: actions/cache/save@v6
+        with:
+          path: ${{ env.MAVEN_REPO_FOLDER }}
+          key: ${{ steps.job-init.outputs.maven-cache-key }}

Reply via email to