Skip to content

Commit eb7f94f

Browse files
committed
Consider Bundler pre and rc versions valid, just exclude .dev
* Fixes #439
1 parent ad718fa commit eb7f94f

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,17 @@ jobs:
244244
bundler: 2.2.3
245245
- run: bundle --version | grep -F "Bundler version 2.2.3"
246246

247+
testBundlerPre:
248+
name: "Test with a Bundler pre/rc version"
249+
runs-on: ubuntu-latest
250+
steps:
251+
- uses: actions/checkout@v3
252+
- uses: ./
253+
with:
254+
ruby-version: '2.6'
255+
bundler: 2.2.0.rc.2
256+
- run: bundle --version | grep -F "Bundler version 2.2.0.rc.2"
257+
247258
testBundlerDev:
248259
name: "Test BUNDLED WITH Bundler dev"
249260
runs-on: ubuntu-latest

bundler.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ const cache = require('@actions/cache')
66
const common = require('./common')
77

88
export const DEFAULT_CACHE_VERSION = '0'
9-
export const BUNDLER_VERSION_REGEXP = /^\d+(?:\.\d+){0,2}$/
9+
10+
function isValidBundlerVersion(bundlerVersion) {
11+
return /^\d+(?:\.\d+){0,2}/.test(bundlerVersion) && !bundlerVersion.endsWith('.dev')
12+
}
1013

1114
// The returned gemfile is guaranteed to exist, the lockfile might not exist
1215
export function detectGemfiles() {
@@ -33,7 +36,7 @@ function readBundledWithFromGemfileLock(lockFile) {
3336
const nextLine = lines[bundledWithLine+1]
3437
if (nextLine) {
3538
const bundlerVersion = nextLine.trim()
36-
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) {
39+
if (isValidBundlerVersion(bundlerVersion)) {
3740
console.log(`Using Bundler ${bundlerVersion} from ${lockFile} BUNDLED WITH ${bundlerVersion}`)
3841
return bundlerVersion
3942
} else {
@@ -100,7 +103,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
100103
bundlerVersion = '2'
101104
}
102105

103-
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) {
106+
if (isValidBundlerVersion(bundlerVersion)) {
104107
// OK - input is a 1, 2, or 3 part version number
105108
} else {
106109
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
@@ -139,7 +142,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
139142
const force = ((platform.startsWith('windows-') && engine === 'ruby' && floatVersion >= 3.1) || (engine === 'truffleruby')) ? ['--force'] : []
140143

141144
const versionParts = [...bundlerVersion.matchAll(/\d+/g)].length
142-
const bundlerVersionConstraint = versionParts === 3 ? bundlerVersion : `~> ${bundlerVersion}.0`
145+
const bundlerVersionConstraint = versionParts >= 3 ? bundlerVersion : `~> ${bundlerVersion}.0`
143146

144147
await exec.exec(gem, ['install', 'bundler', ...force, '-v', bundlerVersionConstraint])
145148

dist/index.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)