diff --git a/bundler.js b/bundler.js index 711871bae..816c56bf8 100644 --- a/bundler.js +++ b/bundler.js @@ -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.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 02e57b237..72e2a9ceb 100644 --- a/common.js +++ b/common.js @@ -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 isExactCacheKeyMatch(key, cacheKey) { + return !!( + cacheKey && + cacheKey.localeCompare(key, undefined, { + sensitivity: 'accent' + }) === 0 + ); +} diff --git a/dist/index.js b/dist/index.js index 4df23eced..95decd0c1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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.isExactCacheKeyMatch(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 */ isExactCacheKeyMatch: () => (/* binding */ isExactCacheKeyMatch), /* 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 isExactCacheKeyMatch(key, cacheKey) { + return !!( + cacheKey && + cacheKey.localeCompare(key, undefined, { + sensitivity: 'accent' + }) === 0 + ); +} + /***/ }),