Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use case-insensitive key comparison for cache keys #660

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.isExactCacheKeyMatch(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 isExactCacheKeyMatch(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.