Skip to content

Commit

Permalink
Ignore Bundler dev version in Gemfile.lock
Browse files Browse the repository at this point in the history
* Fixes ruby#394
  • Loading branch information
eregon committed Nov 22, 2022
1 parent f2c070b commit 8cdc7ba
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -239,6 +239,18 @@ jobs:
bundler: 2.2.3
- run: bundle --version | grep -F "Bundler version 2.2.3"

testBundlerDev:
name: "Test gemfile depending on Bundler 1"
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/bundler-dev.gemfile
steps:
- uses: actions/checkout@v3
- uses: ./
with:
ruby-version: ruby-head
bundler-cache: true

testDependencyOnBundler1:
name: "Test gemfile depending on Bundler 1"
runs-on: ubuntu-latest
Expand Down
13 changes: 9 additions & 4 deletions bundler.js
Expand Up @@ -6,6 +6,7 @@ const cache = require('@actions/cache')
const common = require('./common')

export const DEFAULT_CACHE_VERSION = '0'
export const BUNDLER_VERSION_REGEXP = /^\d+(?:\.\d+){0,2}$/

// The returned gemfile is guaranteed to exist, the lockfile might not exist
export function detectGemfiles() {
Expand All @@ -30,10 +31,14 @@ function readBundledWithFromGemfileLock(lockFile) {
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
if (bundledWithLine !== -1) {
const nextLine = lines[bundledWithLine+1]
if (nextLine && /^\d+/.test(nextLine.trim())) {
if (nextLine) {
const bundlerVersion = nextLine.trim()
console.log(`Using Bundler ${bundlerVersion} from ${lockFile} BUNDLED WITH ${bundlerVersion}`)
return bundlerVersion
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) {
console.log(`Using Bundler ${bundlerVersion} from ${lockFile} BUNDLED WITH ${bundlerVersion}`)
return bundlerVersion
} else {
console.log(`Could not parse BUNDLED WITH version as a valid Bundler release, ignoring it: ${bundlerVersion}`)
}
}
}
}
Expand Down Expand Up @@ -95,7 +100,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
bundlerVersion = '2'
}

if (/^\d+(?:\.\d+){0,2}$/.test(bundlerVersion)) {
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) {
// OK - input is a 1, 2, or 3 part version number
} else {
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
Expand Down
14 changes: 10 additions & 4 deletions dist/index.js

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

3 changes: 3 additions & 0 deletions gemfiles/bundler-dev.gemfile
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem "path"
13 changes: 13 additions & 0 deletions gemfiles/bundler-dev.gemfile.lock
@@ -0,0 +1,13 @@
GEM
remote: https://rubygems.org/
specs:
path (2.0.1)

PLATFORMS
x86_64-linux

DEPENDENCIES
path

BUNDLED WITH
2.4.0.dev

0 comments on commit 8cdc7ba

Please sign in to comment.