Skip to content

Commit

Permalink
Use case-insensitive key comparsion for cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
BytewaveMLP committed Oct 21, 2024
1 parent 7bae1d0 commit 767948d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.isExactKeyMatch(key, cachedKey)) {
if (cachedKey) { // existing cache but Gemfile.lock differs, clean old gems
await exec.exec('bundle', ['clean'])
}
Expand Down
12 changes: 12 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 isExactKeyMatch(key, cacheKey) {
return !!(
cacheKey &&
cacheKey.localeCompare(key, undefined, {
sensitivity: 'accent'
}) === 0
);
}
17 changes: 15 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 767948d

Please sign in to comment.