Include the Gemfile path in the cache key

* See https://github.com/ruby/setup-ruby/issues/103#issuecomment-723960352
This commit is contained in:
Benoit Daloze
2020-11-09 13:00:04 +01:00
parent efda314f4a
commit 693cf1794d
2 changed files with 8 additions and 8 deletions
Generated Vendored
+4 -4
View File
@@ -51365,12 +51365,12 @@ async function bundleInstall(gemfile, lockFile, platform, engine, version) {
// cache key
const paths = [path]
const baseKey = await computeBaseKey(platform, engine, version)
const baseKey = await computeBaseKey(platform, engine, version, gemfile)
let key = baseKey
let restoreKeys
if (lockFile !== null) {
key += `-${lockFile}-${await common.hashFile(lockFile)}`
// If only Gemfile.lock we can reuse some of the cache (but it will keep old gem versions in the cache)
// If only Gemfile.lock changes we can reuse part of the cache (but it will keep old gem versions in the cache)
restoreKeys = [`${baseKey}-${lockFile}-`]
} else {
// Only exact key, to never mix native gems of different platforms or Ruby versions
@@ -51421,8 +51421,8 @@ async function bundleInstall(gemfile, lockFile, platform, engine, version) {
return true
}
async function computeBaseKey(platform, engine, version) {
let baseKey = `setup-ruby-bundle-install-${platform}-${engine}-${version}`
async function computeBaseKey(platform, engine, version, gemfile) {
let baseKey = `setup-ruby-bundle-install-${platform}-${engine}-${version}-${gemfile}`
if (engine !== 'jruby' && common.isHeadVersion(version)) {
let revision = '';
await exec.exec('ruby', ['-e', 'print RUBY_REVISION'], {
+4 -4
View File
@@ -249,12 +249,12 @@ async function bundleInstall(gemfile, lockFile, platform, engine, version) {
// cache key
const paths = [path]
const baseKey = await computeBaseKey(platform, engine, version)
const baseKey = await computeBaseKey(platform, engine, version, gemfile)
let key = baseKey
let restoreKeys
if (lockFile !== null) {
key += `-${lockFile}-${await common.hashFile(lockFile)}`
// If only Gemfile.lock we can reuse some of the cache (but it will keep old gem versions in the cache)
// If only Gemfile.lock changes we can reuse part of the cache (but it will keep old gem versions in the cache)
restoreKeys = [`${baseKey}-${lockFile}-`]
} else {
// Only exact key, to never mix native gems of different platforms or Ruby versions
@@ -305,8 +305,8 @@ async function bundleInstall(gemfile, lockFile, platform, engine, version) {
return true
}
async function computeBaseKey(platform, engine, version) {
let baseKey = `setup-ruby-bundle-install-${platform}-${engine}-${version}`
async function computeBaseKey(platform, engine, version, gemfile) {
let baseKey = `setup-ruby-bundle-install-${platform}-${engine}-${version}-${gemfile}`
if (engine !== 'jruby' && common.isHeadVersion(version)) {
let revision = '';
await exec.exec('ruby', ['-e', 'print RUBY_REVISION'], {