Skip to content

Commit

Permalink
refactor: update bundler cache key generation
Browse files Browse the repository at this point in the history
Simplify the generation of the bundler cache key by including the repository name in the key. This ensures that the cache is specific to the repository being worked on. The previous key generation included the complete working directory path, but the working directory of hosted and self-hosted runners are different, so cache hits miss on self-hosted or vice-versa.
  • Loading branch information
bazlo committed Jun 3, 2024
1 parent 0cde468 commit 57011aa
Show file tree
Hide file tree
Showing 2 changed files with 1,722 additions and 1,720 deletions.
3 changes: 2 additions & 1 deletion bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer

async function computeBaseKey(platform, engine, version, lockFile, cacheVersion) {
const cwd = process.cwd()
const repoName = path.basename(cwd)
const bundleWith = process.env['BUNDLE_WITH'] || ''
const bundleWithout = process.env['BUNDLE_WITHOUT'] || ''
const bundleOnly = process.env['BUNDLE_ONLY'] || ''
let key = `setup-ruby-bundler-cache-v6-${common.getOSNameVersionArch()}-${engine}-${version}-wd-${cwd}-with-${bundleWith}-without-${bundleWithout}-only-${bundleOnly}`
let key = `setup-ruby-bundler-cache-v6-${common.getOSNameVersionArch()}-${engine}-${version}-repo-${repoName}-with-${bundleWith}-without-${bundleWithout}-only-${bundleOnly}`

if (cacheVersion !== DEFAULT_CACHE_VERSION) {
key += `-v-${cacheVersion}`
Expand Down
Loading

0 comments on commit 57011aa

Please sign in to comment.