Skip to content
Merged
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
24 changes: 18 additions & 6 deletions dist/index.js

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

24 changes: 18 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,26 @@ async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine,
}

async function bundleInstall(platform, engine, version) {
if (!fs.existsSync('Gemfile')) {
console.log('No Gemfile, skipping "bundle install" and caching')
return
if (await bundleInstallSpecific('gems.rb', 'gems.locked', platform, engine, version)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bundleInstallSpecific does not return in the successful case.
Does the if work here? It doesn't seem so:

> async function foo() { console.log("foo"); }
> async function call() { var r=await foo(); console.log(r); if (r) { console.log("OK") } else { console.log("NOPE") } }
undefined
> call()
foo
Promise { <pending> }
> undefined
NOPE

return true
}

if (await bundleInstallSpecific('Gemfile', 'Gemfile.lock', platform, engine, version)) {
return true
}

console.log('No Gemfile/gems.rb, skipping "bundle install" and caching')
}

async function bundleInstallSpecific(gemsPath, lockPath, platform, engine, version) {
if (!fs.existsSync(gemsPath)) {
return false
}

// config
const path = 'vendor/bundle'
const hasGemfileLock = fs.existsSync('Gemfile.lock');
const hasGemfileLock = fs.existsSync(lockPath)

if (hasGemfileLock) {
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'])
}
Expand All @@ -232,9 +244,9 @@ async function bundleInstall(platform, engine, version) {
let key = baseKey
let restoreKeys
if (hasGemfileLock) {
key += `-Gemfile.lock-${await common.hashFile('Gemfile.lock')}`
key += `-${lockPath}-${await common.hashFile(lockPath)}`
// If only Gemfile.lock we can reuse some of the cache (but it will keep old gem versions in the cache)
restoreKeys = [`${baseKey}-Gemfile.lock-`]
restoreKeys = [`${baseKey}-${lockPath}-`]
} else {
// Only exact key, to never mix native gems of different platforms or Ruby versions
restoreKeys = []
Expand Down