Skip to content

Commit 229fe99

Browse files
committed
Introduce custom cache key prefix
1 parent 8c3b61c commit 229fe99

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

.github/actions/common/action.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ inputs:
5454
setup-java:
5555
description: Setup java based on env.JAVA_VERSION variable
5656
default: 'true'
57+
cache-key-prefix:
58+
description: Add a prefix to cache key
59+
default: ''
5760
runs:
5861
using: "composite"
5962
steps:
@@ -97,9 +100,9 @@ runs:
97100
!.m2/repository/io/helidon/**
98101
enableCrossOsArchive: true
99102
# only hash top-level poms to keep it fast
100-
key: local-maven-${{ hashFiles('*/pom.xml', 'pom.xml') }}
103+
key: ${{ inputs.cache-key-prefix }}local-maven-${{ hashFiles('*/pom.xml', 'pom.xml') }}
101104
restore-keys: |
102-
local-maven-
105+
${{ inputs.cache-key-prefix }}local-maven-
103106
- name: Cache local Maven repository (read-only)
104107
if: ${{ inputs.maven-cache == 'read-only' }}
105108
uses: actions/cache/[email protected]
@@ -108,9 +111,9 @@ runs:
108111
.m2/repository/**/*.*
109112
!.m2/repository/io/helidon/**
110113
enableCrossOsArchive: true
111-
key: local-maven-${{ hashFiles('*/pom.xml', 'pom.xml') }}
114+
key: ${{ inputs.cache-key-prefix }}local-maven-${{ hashFiles('*/pom.xml', 'pom.xml') }}
112115
restore-keys: |
113-
local-maven-
116+
${{ inputs.cache-key-prefix }}local-maven-
114117
- name: Build cache (read-write)
115118
if: ${{ inputs.build-cache == 'read-write' }}
116119
uses: actions/[email protected]
@@ -119,7 +122,7 @@ runs:
119122
./**/target/**
120123
.m2/repository/io/helidon/**
121124
enableCrossOsArchive: true
122-
key: build-cache-${{ github.run_id }}-${{ github.run_attempt }}-${{ inputs.build-cache-id }}
125+
key: ${{ inputs.cache-key-prefix }}build-cache-${{ github.run_id }}-${{ github.run_attempt }}-${{ inputs.build-cache-id }}
123126
restore-keys: |
124127
build-cache-${{ github.run_id }}-${{ github.run_attempt }}-
125128
build-cache-${{ github.run_id }}-
@@ -132,10 +135,10 @@ runs:
132135
.m2/repository/io/helidon/**
133136
enableCrossOsArchive: true
134137
fail-on-cache-miss: true
135-
key: build-cache-${{ github.run_id }}-${{ github.run_attempt }}-${{ inputs.build-cache-id }}
138+
key: ${{ inputs.cache-key-prefix }}build-cache-${{ github.run_id }}-${{ github.run_attempt }}-${{ inputs.build-cache-id }}
136139
restore-keys: |
137-
build-cache-${{ github.run_id }}-${{ github.run_attempt }}-
138-
build-cache-${{ github.run_id }}-
140+
${{ inputs.cache-key-prefix }}build-cache-${{ github.run_id }}-${{ github.run_attempt }}-
141+
${{ inputs.cache-key-prefix }}build-cache-${{ github.run_id }}-
139142
- name: Exec
140143
env:
141144
MVN_ARGS: |

.github/workflows/validate.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ env:
3232
JAVA_VERSION: 21
3333
GRAALVM_VERSION: 21.0.3
3434
JAVA_DISTRO: oracle
35+
CACHE-KEY-PREFIX: latest-java-
3536
MVN_ARGS: |
3637
-B -fae -e
3738
-Dmaven.wagon.httpconnectionManager.ttlSeconds=60
@@ -95,7 +96,6 @@ jobs:
9596
-Ptests \
9697
install
9798
build-latest-java:
98-
needs: test-results
9999
timeout-minutes: 15
100100
runs-on: ubuntu-22.04
101101
steps:
@@ -112,6 +112,7 @@ jobs:
112112
with:
113113
build-cache: read-write
114114
maven-cache: read-write
115+
cache-key-prefix: ${{ env.CACHE-KEY-PREFIX }}
115116
setup-java: false
116117
run: |
117118
mvn ${MVN_ARGS} --version
@@ -145,6 +146,7 @@ jobs:
145146
- uses: ./.github/actions/common
146147
with:
147148
build-cache: read-only
149+
cache-key-prefix: ${{ env.CACHE-KEY-PREFIX }}
148150
setup-java: false
149151
test-artifact-name: tests-${{ matrix.moduleSet }}-${{ matrix.platform }}-latest-java
150152
run: |

0 commit comments

Comments
 (0)