Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .github/actions/job_init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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-

Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/template.flink-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand All @@ -145,6 +155,7 @@ jobs:
tools

- name: "Initialize job"
id: job-init
uses: "./.github/actions/job_init"
with:
jdk_version: ${{ inputs.jdk_version }}
Expand All @@ -168,6 +179,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
Expand Down Expand Up @@ -212,6 +230,7 @@ jobs:
tools

- name: "Initialize job"
id: job-init
uses: "./.github/actions/job_init"
with:
jdk_version: ${{ inputs.jdk_version }}
Expand Down Expand Up @@ -315,6 +334,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
Expand Down Expand Up @@ -353,6 +379,7 @@ jobs:
tools

- name: "Initialize job"
id: job-init
uses: "./.github/actions/job_init"
with:
jdk_version: ${{ inputs.jdk_version }}
Expand Down Expand Up @@ -446,3 +473,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 }}