Use case-insensitive key comparsion for cache keys

This commit is contained in:
Eliot Partridge
2025-07-29 22:24:35 +02:00
committed by Benoit Daloze
parent 3ec1ec0529
commit 78876b7c88
3 changed files with 27 additions and 2 deletions
+1 -1
View File
@@ -206,7 +206,7 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
await exec.exec('bundle', ['install', '--jobs', '4'])
// @actions/cache only allows to save for non-existing keys
if (cachedKey !== key) {
if (!common.isExactKeyMatch(key, cachedKey)) {
if (cachedKey) { // existing cache but Gemfile.lock differs, clean old gems
await exec.exec('bundle', ['clean'])
}
+12
View File
@@ -412,3 +412,15 @@ export async function setupJavaHome(rubyPrefix) {
}
})
}
// Determines if two keys are an exact match for the purposes of cache matching
// Specifically, this is a case-insensitive match that ignores accents
// From actions/cache@v3 src/utils/actionUtils.ts (MIT)
export function isExactKeyMatch(key, cacheKey) {
return !!(
cacheKey &&
cacheKey.localeCompare(key, undefined, {
sensitivity: 'accent'
}) === 0
);
}
Generated Vendored
+14 -1
View File
@@ -220,7 +220,7 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
await exec.exec('bundle', ['install', '--jobs', '4'])
// @actions/cache only allows to save for non-existing keys
if (cachedKey !== key) {
if (!common.isExactKeyMatch(key, cachedKey)) {
if (cachedKey) { // existing cache but Gemfile.lock differs, clean old gems
await exec.exec('bundle', ['clean'])
}
@@ -299,6 +299,7 @@ __nccwpck_require__.r(__webpack_exports__);
/* harmony export */ isBundler1Default: () => (/* binding */ isBundler1Default),
/* harmony export */ isBundler2Default: () => (/* binding */ isBundler2Default),
/* harmony export */ isBundler2dot2Default: () => (/* binding */ isBundler2dot2Default),
/* harmony export */ isExactKeyMatch: () => (/* binding */ isExactKeyMatch),
/* harmony export */ isHeadVersion: () => (/* binding */ isHeadVersion),
/* harmony export */ isSelfHostedRunner: () => (/* binding */ isSelfHostedRunner),
/* harmony export */ isStableVersion: () => (/* binding */ isStableVersion),
@@ -730,6 +731,18 @@ async function setupJavaHome(rubyPrefix) {
})
}
// Determines if two keys are an exact match for the purposes of cache matching
// Specifically, this is a case-insensitive match that ignores accents
// From actions/cache@v3 src/utils/actionUtils.ts (MIT)
function isExactKeyMatch(key, cacheKey) {
return !!(
cacheKey &&
cacheKey.localeCompare(key, undefined, {
sensitivity: 'accent'
}) === 0
);
}
/***/ }),