Compare commits

...
1 Commits
3 changed files with 62 additions and 12 deletions
+19
View File
@@ -40,6 +40,25 @@ export function isStableVersion(rubyVersion) {
return /^\d+(\.\d+)*$/.test(rubyVersion) return /^\d+(\.\d+)*$/.test(rubyVersion)
} }
export function isBundler2Default(engine, rubyVersion) {
if (engine === 'ruby') {
return isHeadVersion(rubyVersion) || floatVersion(rubyVersion) >= 2.7
} else if (engine === 'truffleruby') {
return isHeadVersion(rubyVersion)
} else {
return false
}
}
export function floatVersion(rubyVersion) {
const match = rubyVersion.match(/^\d+\.\d+/)
if (match) {
return parseFloat(match[0])
} else {
return 0.0
}
}
export async function hashFile(file) { export async function hashFile(file) {
// See https://github.com/actions/runner/blob/master/src/Misc/expressionFunc/hashFiles/src/hashFiles.ts // See https://github.com/actions/runner/blob/master/src/Misc/expressionFunc/hashFiles/src/hashFiles.ts
const hash = crypto.createHash('sha256') const hash = crypto.createHash('sha256')
Generated Vendored
+32 -6
View File
@@ -32114,6 +32114,8 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "measure", function() { return measure; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "measure", function() { return measure; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHeadVersion", function() { return isHeadVersion; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHeadVersion", function() { return isHeadVersion; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isStableVersion", function() { return isStableVersion; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isStableVersion", function() { return isStableVersion; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isBundler2Default", function() { return isBundler2Default; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "floatVersion", function() { return floatVersion; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hashFile", function() { return hashFile; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hashFile", function() { return hashFile; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldUseToolCache", function() { return shouldUseToolCache; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldUseToolCache", function() { return shouldUseToolCache; });
@@ -32163,6 +32165,25 @@ function isStableVersion(rubyVersion) {
return /^\d+(\.\d+)*$/.test(rubyVersion) return /^\d+(\.\d+)*$/.test(rubyVersion)
} }
function isBundler2Default(engine, rubyVersion) {
if (engine === 'ruby') {
return isHeadVersion(rubyVersion) || floatVersion(rubyVersion) >= 2.7
} else if (engine === 'truffleruby') {
return isHeadVersion(rubyVersion)
} else {
return false
}
}
function floatVersion(rubyVersion) {
const match = rubyVersion.match(/^\d+\.\d+/)
if (match) {
return parseFloat(match[0])
} else {
return 0.0
}
}
async function hashFile(file) { async function hashFile(file) {
// See https://github.com/actions/runner/blob/master/src/Misc/expressionFunc/hashFiles/src/hashFiles.ts // See https://github.com/actions/runner/blob/master/src/Misc/expressionFunc/hashFiles/src/hashFiles.ts
const hash = crypto.createHash('sha256') const hash = crypto.createHash('sha256')
@@ -51416,7 +51437,7 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
bundlerVersion = '1' bundlerVersion = '1'
} }
if ((engine === 'ruby' || engine === 'truffleruby') && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') { if (common.isHeadVersion(rubyVersion) && common.isBundler2Default(engine, rubyVersion) && bundlerVersion === '2') {
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`) console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
} else if (engine === 'truffleruby' && !common.isHeadVersion(rubyVersion) && bundlerVersion === '1') { } else if (engine === 'truffleruby' && !common.isHeadVersion(rubyVersion) && bundlerVersion === '1') {
console.log(`Using Bundler 1 shipped with ${engine}`) console.log(`Using Bundler 1 shipped with ${engine}`)
@@ -51434,20 +51455,25 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
return false return false
} }
// Before the lockfile exists, we need to specify which Bundler version to use explicitly let envOptions = {}
const optionsWithBundlerVersion = { env: { ...process.env, BUNDLER_VERSION: bundlerVersion } } if (bundlerVersion.startsWith('1') && common.isBundler2Default(engine, rubyVersion)) {
// If Bundler 1 is specified on Rubies which ship with Bundler 2,
// we need to specify which Bundler version to use explicitly until the lockfile exists.
console.log(`Setting BUNDLER_VERSION=${bundlerVersion} for "bundle config|lock" commands below to ensure Bundler 1 is used`)
envOptions = { env: { ...process.env, BUNDLER_VERSION: bundlerVersion } }
}
// config // config
const path = 'vendor/bundle' const path = 'vendor/bundle'
await exec.exec('bundle', ['config', '--local', 'path', path], optionsWithBundlerVersion) await exec.exec('bundle', ['config', '--local', 'path', path], envOptions)
if (fs.existsSync(lockFile)) { if (fs.existsSync(lockFile)) {
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], optionsWithBundlerVersion) await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], envOptions)
} else { } else {
// Generate the lockfile so we can use it to compute the cache key. // Generate the lockfile so we can use it to compute the cache key.
// This will also automatically pick up the latest gem versions compatible with the Gemfile. // This will also automatically pick up the latest gem versions compatible with the Gemfile.
await exec.exec('bundle', ['lock'], optionsWithBundlerVersion) await exec.exec('bundle', ['lock'], envOptions)
} }
// cache key // cache key
+11 -6
View File
@@ -222,7 +222,7 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
bundlerVersion = '1' bundlerVersion = '1'
} }
if ((engine === 'ruby' || engine === 'truffleruby') && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') { if (common.isHeadVersion(rubyVersion) && common.isBundler2Default(engine, rubyVersion) && bundlerVersion === '2') {
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`) console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
} else if (engine === 'truffleruby' && !common.isHeadVersion(rubyVersion) && bundlerVersion === '1') { } else if (engine === 'truffleruby' && !common.isHeadVersion(rubyVersion) && bundlerVersion === '1') {
console.log(`Using Bundler 1 shipped with ${engine}`) console.log(`Using Bundler 1 shipped with ${engine}`)
@@ -240,20 +240,25 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
return false return false
} }
// Before the lockfile exists, we need to specify which Bundler version to use explicitly let envOptions = {}
const optionsWithBundlerVersion = { env: { ...process.env, BUNDLER_VERSION: bundlerVersion } } if (bundlerVersion.startsWith('1') && common.isBundler2Default(engine, rubyVersion)) {
// If Bundler 1 is specified on Rubies which ship with Bundler 2,
// we need to specify which Bundler version to use explicitly until the lockfile exists.
console.log(`Setting BUNDLER_VERSION=${bundlerVersion} for "bundle config|lock" commands below to ensure Bundler 1 is used`)
envOptions = { env: { ...process.env, BUNDLER_VERSION: bundlerVersion } }
}
// config // config
const path = 'vendor/bundle' const path = 'vendor/bundle'
await exec.exec('bundle', ['config', '--local', 'path', path], optionsWithBundlerVersion) await exec.exec('bundle', ['config', '--local', 'path', path], envOptions)
if (fs.existsSync(lockFile)) { if (fs.existsSync(lockFile)) {
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], optionsWithBundlerVersion) await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], envOptions)
} else { } else {
// Generate the lockfile so we can use it to compute the cache key. // Generate the lockfile so we can use it to compute the cache key.
// This will also automatically pick up the latest gem versions compatible with the Gemfile. // This will also automatically pick up the latest gem versions compatible with the Gemfile.
await exec.exec('bundle', ['lock'], optionsWithBundlerVersion) await exec.exec('bundle', ['lock'], envOptions)
} }
// cache key // cache key