Compare commits

..
12 Commits
8 changed files with 96 additions and 39 deletions
+34 -3
View File
@@ -15,9 +15,9 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ ubuntu-16.04, ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11.0, windows-2016, windows-2019 ] os: [ ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11.0, windows-2016, windows-2019 ]
# Use various version syntax here for testing # Use various version syntax here for testing
ruby: [ 2.1, 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, '3.0', ruby-head, debug, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ] ruby: [ 2.1, 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, '3.0', ruby-head, jruby, jruby-head, truffleruby, truffleruby-head ]
include: include:
- { os: windows-2016, ruby: mingw } - { os: windows-2016, ruby: mingw }
- { os: windows-2019, ruby: mingw } - { os: windows-2019, ruby: mingw }
@@ -111,7 +111,38 @@ jobs:
with: with:
ruby-version: 2.6 ruby-version: 2.6
bundler: 2.1.4 bundler: 2.1.4
- run: bundle --version | grep -F 2.1.4 - run: bundle --version | grep -F "Bundler version 2.1.4"
testDependencyOnBundler1:
name: "Test gemfile depending on Bundler 1"
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: gemfiles/bundler1.gemfile
steps:
- uses: actions/checkout@v2
- uses: ./
with:
ruby-version: 2.7
bundler: 1
bundler-cache: true
- run: bundle --version | grep -F "Bundler version 1."
testGemfileMatrix:
strategy:
fail-fast: false
matrix:
gemfile: [ rails5, rails6 ]
name: "Test with ${{ matrix.gemfile }} gemfile"
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v2
- uses: ./
with:
ruby-version: 2.6
bundler-cache: true
- run: bundle exec rails --version
lint: lint:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
+33 -24
View File
@@ -14,7 +14,7 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
| Interpreter | Versions | | Interpreter | Versions |
| ----------- | -------- | | ----------- | -------- |
| `ruby` | 2.1.9, 2.2, 2.3.0 - 2.3.8, 2.4.0 - 2.4.10, 2.5.0 - 2.5.8, 2.6.0 - 2.6.6, 2.7.2, head, debug, mingw, mswin | | `ruby` | 2.1.9, 2.2, 2.3.0 - 2.3.8, 2.4.0 - 2.4.10, 2.5.0 - 2.5.8, 2.6.0 - 2.6.6, 2.7.2, 3.0.0,<br/> head, debug, mingw, mswin |
| `jruby` | 9.1.17.0, 9.2.9.0 - 9.2.13.0, head | | `jruby` | 9.1.17.0, 9.2.9.0 - 9.2.13.0, head |
| `truffleruby` | 19.3.0 - 20.3.0, head | | `truffleruby` | 19.3.0 - 20.3.0, head |
@@ -70,7 +70,7 @@ jobs:
- run: bundle exec rake - run: bundle exec rake
``` ```
### Matrix ### Matrix of Ruby Versions
This matrix tests all stable releases and `head` versions of MRI, JRuby and TruffleRuby on Ubuntu and macOS. This matrix tests all stable releases and `head` versions of MRI, JRuby and TruffleRuby on Ubuntu and macOS.
@@ -82,9 +82,9 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu, macos] os: [ubuntu-latest, macos-latest]
ruby: [2.5, 2.6, 2.7, head, debug, jruby, jruby-head, truffleruby, truffleruby-head] ruby: [2.5, 2.6, 2.7, '3.0', head, jruby, jruby-head, truffleruby, truffleruby-head]
runs-on: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1
@@ -94,6 +94,29 @@ jobs:
- run: bundle exec rake - run: bundle exec rake
``` ```
### Matrix of Gemfiles
```yaml
name: My workflow
on: [push]
jobs:
test:
strategy:
fail-fast: false
matrix:
gemfile: [ rails5, rails6 ]
runs-on: ubuntu-latest
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v2
- uses: ./
with:
ruby-version: 2.6
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: bundle exec rake
```
See the GitHub Actions documentation for more details about the See the GitHub Actions documentation for more details about the
[workflow syntax](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions) [workflow syntax](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions)
and the [condition and expression syntax](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions). and the [condition and expression syntax](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions).
@@ -116,10 +139,10 @@ if they are not at the root of the repository, see [action.yml](action.yml) for
### Bundler ### Bundler
By default, if there is a `Gemfile.lock` file (or `$BUNDLE_GEMFILE.lock` or `gems.locked`) with a `BUNDLED WITH` section, By default, if there is a `Gemfile.lock` file (or `$BUNDLE_GEMFILE.lock` or `gems.locked`) with a `BUNDLED WITH` section,
the latest version of Bundler with the same major version will be installed. that version of Bundler will be installed and used.
Otherwise, the latest compatible Bundler version is installed (Bundler 2 on Ruby >= 2.4, Bundler 1 on Ruby < 2.4). Otherwise, the latest compatible Bundler version is installed (Bundler 2 on Ruby >= 2.4, Bundler 1 on Ruby < 2.4).
This behavior can be customized, see [action.yml](action.yml) for details about the `bundler` input. This behavior can be customized, see [action.yml](action.yml) for more details about the `bundler` input.
### Caching `bundle install` automatically ### Caching `bundle install` automatically
@@ -136,24 +159,10 @@ This caching speeds up installing gems significantly and avoids too many request
It needs a `Gemfile` (or `$BUNDLE_GEMFILE` or `gems.rb`) under the [`working-directory`](#working-directory). It needs a `Gemfile` (or `$BUNDLE_GEMFILE` or `gems.rb`) under the [`working-directory`](#working-directory).
If there is a `Gemfile.lock` (or `$BUNDLE_GEMFILE.lock` or `gems.locked`), `bundle config --local deployment true` is used. If there is a `Gemfile.lock` (or `$BUNDLE_GEMFILE.lock` or `gems.locked`), `bundle config --local deployment true` is used.
To use a `Gemfile` which is not at the root or has a different name, set `BUNDLE_GEMFILE` in the `env` at the job level, so it is set for all steps: To use a `Gemfile` which is not at the root or has a different name, set `BUNDLE_GEMFILE` in the `env` at the job level
```yaml as shown in the [example](#matrix-of-gemfiles).
jobs:
test:
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: subdir/mygemfile
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
bundler-cache: true
- run: bundle exec rake
```
Of course you can also use a matrix of gemfiles if you need to test multiple gemfiles.
To perform caching, this action will use `bundle config --local path vendor/bundle`. To perform caching, this action will use `bundle config --local path $PWD/vendor/bundle`.
Therefore, the Bundler `path` should not be changed in your workflow for the cache to work (no `bundle config path`). Therefore, the Bundler `path` should not be changed in your workflow for the cache to work (no `bundle config path`).
## Windows ## Windows
Generated Vendored
+10 -6
View File
@@ -45192,7 +45192,7 @@ function getVersions(platform) {
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7", "2.5.8", "2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7", "2.5.8",
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6", "2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
"2.7.0", "2.7.1", "2.7.2", "2.7.0", "2.7.1", "2.7.2",
"3.0.0-preview1", "3.0.0-preview2", "3.0.0-preview1", "3.0.0-preview2", "3.0.0-rc1", "3.0.0",
"head", "debug", "head", "debug",
], ],
"jruby": [ "jruby": [
@@ -51908,6 +51908,8 @@ function detectGemfiles() {
const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile' const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile'
if (fs.existsSync(gemfilePath)) { if (fs.existsSync(gemfilePath)) {
return [gemfilePath, `${gemfilePath}.lock`] return [gemfilePath, `${gemfilePath}.lock`]
} else if (process.env['BUNDLE_GEMFILE']) {
throw new Error(`$BUNDLE_GEMFILE is set to ${gemfilePath} but does not exist`)
} }
if (fs.existsSync("gems.rb")) { if (fs.existsSync("gems.rb")) {
@@ -52044,7 +52046,7 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
} else if (engine === 'ruby' && rubyVersion.startsWith('2.3')) { } else if (engine === 'ruby' && rubyVersion.startsWith('2.3')) {
console.log('Ruby 2.3 has a bug with Bundler 2 (https://github.com/rubygems/rubygems/issues/3570), using Bundler 1 instead on Ruby 2.3') console.log('Ruby 2.3 has a bug with Bundler 2 (https://github.com/rubygems/rubygems/issues/3570), using Bundler 1 instead on Ruby 2.3')
bundlerVersion = '1' bundlerVersion = '1'
} else if (engine === 'jruby' && rubyVersion.startsWith('9.1.')) { // JRuby 9.1 targets Ruby 2.3, treat it the same } else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same
console.log('JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1') console.log('JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1')
bundlerVersion = '1' bundlerVersion = '1'
} }
@@ -52076,9 +52078,11 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
} }
// config // config
const path = 'vendor/bundle' 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', path], envOptions) await exec.exec('bundle', ['config', '--local', 'path', bundleCachePath], envOptions)
if (fs.existsSync(lockFile)) { if (fs.existsSync(lockFile)) {
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], envOptions) await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], envOptions)
@@ -52089,7 +52093,7 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
} }
// cache key // cache key
const paths = [path] const paths = [cachePath]
const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile) const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile)
const key = `${baseKey}-${await common.hashFile(lockFile)}` const key = `${baseKey}-${await common.hashFile(lockFile)}`
// If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below // If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below
@@ -52140,7 +52144,7 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
} }
async function computeBaseKey(platform, engine, version, lockFile) { async function computeBaseKey(platform, engine, version, lockFile) {
let key = `setup-ruby-bundler-cache-v2-${platform}-${engine}-${version}` let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}`
if (engine !== 'jruby' && common.isHeadVersion(version)) { if (engine !== 'jruby' && common.isHeadVersion(version)) {
let revision = ''; let revision = '';
+3
View File
@@ -0,0 +1,3 @@
source 'https://rubygems.org'
gem "bundler", "~> 1.0"
+3
View File
@@ -0,0 +1,3 @@
source "https://rubygems.org"
gem "rails", "~> 5.2.0"
+3
View File
@@ -0,0 +1,3 @@
source "https://rubygems.org"
gem "rails", "~> 6.0.0"
+9 -5
View File
@@ -80,6 +80,8 @@ function detectGemfiles() {
const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile' const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile'
if (fs.existsSync(gemfilePath)) { if (fs.existsSync(gemfilePath)) {
return [gemfilePath, `${gemfilePath}.lock`] return [gemfilePath, `${gemfilePath}.lock`]
} else if (process.env['BUNDLE_GEMFILE']) {
throw new Error(`$BUNDLE_GEMFILE is set to ${gemfilePath} but does not exist`)
} }
if (fs.existsSync("gems.rb")) { if (fs.existsSync("gems.rb")) {
@@ -216,7 +218,7 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
} else if (engine === 'ruby' && rubyVersion.startsWith('2.3')) { } else if (engine === 'ruby' && rubyVersion.startsWith('2.3')) {
console.log('Ruby 2.3 has a bug with Bundler 2 (https://github.com/rubygems/rubygems/issues/3570), using Bundler 1 instead on Ruby 2.3') console.log('Ruby 2.3 has a bug with Bundler 2 (https://github.com/rubygems/rubygems/issues/3570), using Bundler 1 instead on Ruby 2.3')
bundlerVersion = '1' bundlerVersion = '1'
} else if (engine === 'jruby' && rubyVersion.startsWith('9.1.')) { // JRuby 9.1 targets Ruby 2.3, treat it the same } else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same
console.log('JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1') console.log('JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1')
bundlerVersion = '1' bundlerVersion = '1'
} }
@@ -248,9 +250,11 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
} }
// config // config
const path = 'vendor/bundle' 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', path], envOptions) await exec.exec('bundle', ['config', '--local', 'path', bundleCachePath], envOptions)
if (fs.existsSync(lockFile)) { if (fs.existsSync(lockFile)) {
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], envOptions) await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], envOptions)
@@ -261,7 +265,7 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
} }
// cache key // cache key
const paths = [path] const paths = [cachePath]
const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile) const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile)
const key = `${baseKey}-${await common.hashFile(lockFile)}` const key = `${baseKey}-${await common.hashFile(lockFile)}`
// If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below // If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below
@@ -312,7 +316,7 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
} }
async function computeBaseKey(platform, engine, version, lockFile) { async function computeBaseKey(platform, engine, version, lockFile) {
let key = `setup-ruby-bundler-cache-v2-${platform}-${engine}-${version}` let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}`
if (engine !== 'jruby' && common.isHeadVersion(version)) { if (engine !== 'jruby' && common.isHeadVersion(version)) {
let revision = ''; let revision = '';
+1 -1
View File
@@ -8,7 +8,7 @@ export function getVersions(platform) {
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7", "2.5.8", "2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7", "2.5.8",
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6", "2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
"2.7.0", "2.7.1", "2.7.2", "2.7.0", "2.7.1", "2.7.2",
"3.0.0-preview1", "3.0.0-preview2", "3.0.0-preview1", "3.0.0-preview2", "3.0.0-rc1", "3.0.0",
"head", "debug", "head", "debug",
], ],
"jruby": [ "jruby": [