Skip to content

Commit 25bc920

Browse files
committed
Honor $BUNDLE_JOBS for bundle install
bundle install was always invoked with an explicit `--jobs N` (the number of available processors, capped at 8). Since Bundler stores command-line options as temporary settings, which take precedence over every other configuration source, this silently overrode any `BUNDLE_JOBS` set by the user, making it impossible to e.g. disable parallel installation. Only pass `--jobs` when `BUNDLE_JOBS` is not set, so that the `BUNDLE_*` environment variables recommended in the README for configuring Bundler also work for the number of jobs. Fixes #673
1 parent 26e5b7d commit 25bc920

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ They should be set in the `env` at the job level as shown in the [example](#matr
204204
To find the correct the environment variable name, see the [Bundler docs](https://bundler.io/man/bundle-config.1.html) or look at `.bundle/config` after running `bundle config --local KEY VALUE` locally.
205205
You might need to `"`-quote the environment variable name in YAML if it has unusual characters like `/`.
206206

207+
By default, `bundle install` is run with `--jobs` set to the number of available processors (up to 8).
208+
This can be changed by setting `BUNDLE_JOBS`.
209+
207210
To perform caching, this action will use `bundle config --local path $PWD/vendor/bundle`.
208211
Therefore, the Bundler `path` should not be changed in your workflow for the cache to work (no `bundle config path`).
209212

‎bundler.js‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,15 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
214214
console.log(`Found cache for key: ${cachedKey}`)
215215
}
216216

217-
// Number of jobs should scale with runner, up to a point
218-
const jobs = Math.min(os.availableParallelism(), 8)
217+
const installArgs = ['install']
218+
// Honor $BUNDLE_JOBS if set, as passing --jobs would override it
219+
if (!process.env['BUNDLE_JOBS']) {
220+
// Number of jobs should scale with runner, up to a point
221+
const jobs = Math.min(os.availableParallelism(), 8)
222+
installArgs.push('--jobs', `${jobs}`)
223+
}
219224
// Always run 'bundle install' to list the gems
220-
await exec.exec('bundle', ['install', '--jobs', `${jobs}`])
225+
await exec.exec('bundle', installArgs)
221226

222227
// @actions/cache only allows to save for non-existing keys
223228
// Also, skip saving cache for merge_group event

‎dist/index.js‎

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

0 commit comments

Comments
 (0)