diff --git a/bundler.js b/bundler.js index d0f40eca3..6d3c22686 100644 --- a/bundler.js +++ b/bundler.js @@ -209,7 +209,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.isExactCacheKeyMatch(key, cachedKey)) { if (cachedKey) { // existing cache but Gemfile.lock differs, clean old gems await exec.exec('bundle', ['clean']) } diff --git a/common.js b/common.js index d2399579b..b2d337ada 100644 --- a/common.js +++ b/common.js @@ -393,3 +393,15 @@ export function setupPath(newPathEntries) { core.addPath(newPath.join(path.delimiter)) return msys2Type } + +// 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 isExactCacheKeyMatch(key, cacheKey) { + return !!( + cacheKey && + cacheKey.localeCompare(key, undefined, { + sensitivity: 'accent' + }) === 0 + ); +} diff --git a/dist/index.js b/dist/index.js index b54bcb81d..bbd0febdb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -223,7 +223,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.isExactCacheKeyMatch(key, cachedKey)) { if (cachedKey) { // existing cache but Gemfile.lock differs, clean old gems await exec.exec('bundle', ['clean']) } @@ -315,7 +315,8 @@ __nccwpck_require__.r(__webpack_exports__); /* harmony export */ "toolCacheCompleteFile": () => (/* binding */ toolCacheCompleteFile), /* harmony export */ "createToolCacheCompleteFile": () => (/* binding */ createToolCacheCompleteFile), /* harmony export */ "win2nix": () => (/* binding */ win2nix), -/* harmony export */ "setupPath": () => (/* binding */ setupPath) +/* harmony export */ "setupPath": () => (/* binding */ setupPath), +/* harmony export */ "isExactCacheKeyMatch": () => (/* binding */ isExactCacheKeyMatch) /* harmony export */ }); const os = __nccwpck_require__(2037) const path = __nccwpck_require__(1017) @@ -713,6 +714,18 @@ function setupPath(newPathEntries) { return msys2Type } +// 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 isExactCacheKeyMatch(key, cacheKey) { + return !!( + cacheKey && + cacheKey.localeCompare(key, undefined, { + sensitivity: 'accent' + }) === 0 + ); +} + /***/ }),