mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3190662165 | ||
|
|
eb7f94ffae | ||
|
|
ad718faf7a |
@@ -18,7 +18,12 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, macos-10.15, macos-11, macos-12, windows-2019, windows-2022 ]
|
||||
ruby: [ '1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', ruby-head, jruby, jruby-head, truffleruby, truffleruby-head, truffleruby+graalvm, truffleruby+graalvm-head ]
|
||||
ruby: [
|
||||
'1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', ruby-head,
|
||||
jruby, jruby-head,
|
||||
truffleruby, truffleruby-head,
|
||||
truffleruby+graalvm, truffleruby+graalvm-head
|
||||
]
|
||||
include:
|
||||
- { os: windows-2019, ruby: mingw }
|
||||
- { os: windows-2019, ruby: mswin }
|
||||
@@ -239,6 +244,17 @@ jobs:
|
||||
bundler: 2.2.3
|
||||
- run: bundle --version | grep -F "Bundler version 2.2.3"
|
||||
|
||||
testBundlerPre:
|
||||
name: "Test with a Bundler pre/rc version"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./
|
||||
with:
|
||||
ruby-version: '2.6'
|
||||
bundler: 2.2.0.rc.2
|
||||
- run: bundle --version | grep -F "Bundler version 2.2.0.rc.2"
|
||||
|
||||
testBundlerDev:
|
||||
name: "Test BUNDLED WITH Bundler dev"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
+19
-16
@@ -6,7 +6,10 @@ const cache = require('@actions/cache')
|
||||
const common = require('./common')
|
||||
|
||||
export const DEFAULT_CACHE_VERSION = '0'
|
||||
export const BUNDLER_VERSION_REGEXP = /^\d+(?:\.\d+){0,2}$/
|
||||
|
||||
function isValidBundlerVersion(bundlerVersion) {
|
||||
return /^\d+(?:\.\d+){0,2}/.test(bundlerVersion) && !bundlerVersion.endsWith('.dev')
|
||||
}
|
||||
|
||||
// The returned gemfile is guaranteed to exist, the lockfile might not exist
|
||||
export function detectGemfiles() {
|
||||
@@ -33,7 +36,7 @@ function readBundledWithFromGemfileLock(lockFile) {
|
||||
const nextLine = lines[bundledWithLine+1]
|
||||
if (nextLine) {
|
||||
const bundlerVersion = nextLine.trim()
|
||||
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) {
|
||||
if (isValidBundlerVersion(bundlerVersion)) {
|
||||
console.log(`Using Bundler ${bundlerVersion} from ${lockFile} BUNDLED WITH ${bundlerVersion}`)
|
||||
return bundlerVersion
|
||||
} else {
|
||||
@@ -100,7 +103,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
|
||||
bundlerVersion = '2'
|
||||
}
|
||||
|
||||
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) {
|
||||
if (isValidBundlerVersion(bundlerVersion)) {
|
||||
// OK - input is a 1, 2, or 3 part version number
|
||||
} else {
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
@@ -123,7 +126,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
|
||||
const targetRubyVersion = common.targetRubyVersion(engine, rubyVersion)
|
||||
// Use Bundler 2.3 when we use Ruby 2.3.2 - 2.5
|
||||
// Use Bundler 2.4 when we use Ruby 2.6-2.7
|
||||
if (bundlerVersion == '2') {
|
||||
if (bundlerVersion === '2') {
|
||||
if (targetRubyVersion <= 2.5) { // < 2.3.2 already handled above
|
||||
console.log('Ruby 2.3.2 - 2.5 only works with Bundler 2.3')
|
||||
bundlerVersion = '2.3'
|
||||
@@ -139,10 +142,18 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
|
||||
const force = ((platform.startsWith('windows-') && engine === 'ruby' && floatVersion >= 3.1) || (engine === 'truffleruby')) ? ['--force'] : []
|
||||
|
||||
const versionParts = [...bundlerVersion.matchAll(/\d+/g)].length
|
||||
const bundlerVersionConstraint = versionParts === 3 ? bundlerVersion : `~> ${bundlerVersion}.0`
|
||||
const bundlerVersionConstraint = versionParts >= 3 ? bundlerVersion : `~> ${bundlerVersion}.0`
|
||||
|
||||
await exec.exec(gem, ['install', 'bundler', ...force, '-v', bundlerVersionConstraint])
|
||||
|
||||
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.
|
||||
// We actually set it globally for the case of bundler-cache: false with manual bundler install later.
|
||||
console.log(`Setting BUNDLER_VERSION=${bundlerVersion} to ensure Bundler 1 is used`)
|
||||
core.exportVariable('BUNDLER_VERSION', bundlerVersion)
|
||||
}
|
||||
|
||||
return bundlerVersion
|
||||
}
|
||||
|
||||
@@ -152,27 +163,19 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
|
||||
return false
|
||||
}
|
||||
|
||||
let envOptions = {}
|
||||
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
|
||||
const cachePath = 'vendor/bundle'
|
||||
// An absolute path, so it is reliably under $PWD/vendor/bundle, and not relative to the gemfile's directory
|
||||
const bundleCachePath = path.join(process.cwd(), cachePath)
|
||||
|
||||
await exec.exec('bundle', ['config', '--local', 'path', bundleCachePath], envOptions)
|
||||
await exec.exec('bundle', ['config', '--local', 'path', bundleCachePath])
|
||||
|
||||
if (fs.existsSync(lockFile)) {
|
||||
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], envOptions)
|
||||
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'])
|
||||
} else {
|
||||
// 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.
|
||||
await exec.exec('bundle', ['lock'], envOptions)
|
||||
await exec.exec('bundle', ['lock'])
|
||||
}
|
||||
|
||||
await afterLockFile(lockFile, platform, engine, rubyVersion)
|
||||
|
||||
+19
-17
@@ -8,7 +8,6 @@
|
||||
__nccwpck_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "DEFAULT_CACHE_VERSION": () => (/* binding */ DEFAULT_CACHE_VERSION),
|
||||
/* harmony export */ "BUNDLER_VERSION_REGEXP": () => (/* binding */ BUNDLER_VERSION_REGEXP),
|
||||
/* harmony export */ "detectGemfiles": () => (/* binding */ detectGemfiles),
|
||||
/* harmony export */ "installBundler": () => (/* binding */ installBundler),
|
||||
/* harmony export */ "bundleInstall": () => (/* binding */ bundleInstall)
|
||||
@@ -21,7 +20,10 @@ const cache = __nccwpck_require__(7799)
|
||||
const common = __nccwpck_require__(4717)
|
||||
|
||||
const DEFAULT_CACHE_VERSION = '0'
|
||||
const BUNDLER_VERSION_REGEXP = /^\d+(?:\.\d+){0,2}$/
|
||||
|
||||
function isValidBundlerVersion(bundlerVersion) {
|
||||
return /^\d+(?:\.\d+){0,2}/.test(bundlerVersion) && !bundlerVersion.endsWith('.dev')
|
||||
}
|
||||
|
||||
// The returned gemfile is guaranteed to exist, the lockfile might not exist
|
||||
function detectGemfiles() {
|
||||
@@ -48,7 +50,7 @@ function readBundledWithFromGemfileLock(lockFile) {
|
||||
const nextLine = lines[bundledWithLine+1]
|
||||
if (nextLine) {
|
||||
const bundlerVersion = nextLine.trim()
|
||||
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) {
|
||||
if (isValidBundlerVersion(bundlerVersion)) {
|
||||
console.log(`Using Bundler ${bundlerVersion} from ${lockFile} BUNDLED WITH ${bundlerVersion}`)
|
||||
return bundlerVersion
|
||||
} else {
|
||||
@@ -115,7 +117,7 @@ async function installBundler(bundlerVersionInput, rubygemsInputSet, lockFile, p
|
||||
bundlerVersion = '2'
|
||||
}
|
||||
|
||||
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) {
|
||||
if (isValidBundlerVersion(bundlerVersion)) {
|
||||
// OK - input is a 1, 2, or 3 part version number
|
||||
} else {
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
@@ -138,7 +140,7 @@ async function installBundler(bundlerVersionInput, rubygemsInputSet, lockFile, p
|
||||
const targetRubyVersion = common.targetRubyVersion(engine, rubyVersion)
|
||||
// Use Bundler 2.3 when we use Ruby 2.3.2 - 2.5
|
||||
// Use Bundler 2.4 when we use Ruby 2.6-2.7
|
||||
if (bundlerVersion == '2') {
|
||||
if (bundlerVersion === '2') {
|
||||
if (targetRubyVersion <= 2.5) { // < 2.3.2 already handled above
|
||||
console.log('Ruby 2.3.2 - 2.5 only works with Bundler 2.3')
|
||||
bundlerVersion = '2.3'
|
||||
@@ -154,10 +156,18 @@ async function installBundler(bundlerVersionInput, rubygemsInputSet, lockFile, p
|
||||
const force = ((platform.startsWith('windows-') && engine === 'ruby' && floatVersion >= 3.1) || (engine === 'truffleruby')) ? ['--force'] : []
|
||||
|
||||
const versionParts = [...bundlerVersion.matchAll(/\d+/g)].length
|
||||
const bundlerVersionConstraint = versionParts === 3 ? bundlerVersion : `~> ${bundlerVersion}.0`
|
||||
const bundlerVersionConstraint = versionParts >= 3 ? bundlerVersion : `~> ${bundlerVersion}.0`
|
||||
|
||||
await exec.exec(gem, ['install', 'bundler', ...force, '-v', bundlerVersionConstraint])
|
||||
|
||||
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.
|
||||
// We actually set it globally for the case of bundler-cache: false with manual bundler install later.
|
||||
console.log(`Setting BUNDLER_VERSION=${bundlerVersion} to ensure Bundler 1 is used`)
|
||||
core.exportVariable('BUNDLER_VERSION', bundlerVersion)
|
||||
}
|
||||
|
||||
return bundlerVersion
|
||||
}
|
||||
|
||||
@@ -167,27 +177,19 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
|
||||
return false
|
||||
}
|
||||
|
||||
let envOptions = {}
|
||||
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
|
||||
const cachePath = 'vendor/bundle'
|
||||
// An absolute path, so it is reliably under $PWD/vendor/bundle, and not relative to the gemfile's directory
|
||||
const bundleCachePath = path.join(process.cwd(), cachePath)
|
||||
|
||||
await exec.exec('bundle', ['config', '--local', 'path', bundleCachePath], envOptions)
|
||||
await exec.exec('bundle', ['config', '--local', 'path', bundleCachePath])
|
||||
|
||||
if (fs.existsSync(lockFile)) {
|
||||
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], envOptions)
|
||||
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'])
|
||||
} else {
|
||||
// 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.
|
||||
await exec.exec('bundle', ['lock'], envOptions)
|
||||
await exec.exec('bundle', ['lock'])
|
||||
}
|
||||
|
||||
await afterLockFile(lockFile, platform, engine, rubyVersion)
|
||||
|
||||
Reference in New Issue
Block a user