mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba5b846810 | ||
|
|
81be0938f7 | ||
|
|
b04e5b8846 | ||
|
|
a7df86edc6 | ||
|
|
8137829321 | ||
|
|
a1d280134e | ||
|
|
d01e942f09 | ||
|
|
e74945bcae | ||
|
|
8bff4379b9 | ||
|
|
23b9735206 |
@@ -15,13 +15,13 @@ jobs:
|
||||
matrix:
|
||||
os: [ ubuntu, macos, windows ]
|
||||
# Use various version syntax here for testing
|
||||
ruby: [ 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, ruby-head, ruby-debug, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
|
||||
ruby: [ 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, ruby-head, debug, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
|
||||
include:
|
||||
- { os: ubuntu, ruby: rubinius }
|
||||
- { os: windows, ruby: mingw }
|
||||
- { os: windows, ruby: mswin }
|
||||
exclude:
|
||||
- { os: windows, ruby: ruby-debug }
|
||||
- { os: windows, ruby: debug }
|
||||
- { os: windows, ruby: truffleruby }
|
||||
- { os: windows, ruby: truffleruby-head }
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
|
||||
| ----------- | -------- |
|
||||
| Ruby | 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.1, head, debug, mingw, mswin |
|
||||
| JRuby | 9.1.17.0, 9.2.9.0 - 9.2.11.1, head |
|
||||
| TruffleRuby | 19.3.0 - 20.0.0, head |
|
||||
| TruffleRuby | 19.3.0 - 20.1.0, head |
|
||||
| Rubinius | 4.14 |
|
||||
|
||||
`ruby-debug` is the same as `ruby-head` but with assertions enabled (`-DRUBY_DEBUG=1`).
|
||||
@@ -64,13 +64,14 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: ruby -v
|
||||
ruby-version: 2.6 # Not needed with a .ruby-version file
|
||||
- run: bundle install
|
||||
- run: bundle exec rake
|
||||
```
|
||||
|
||||
### Matrix
|
||||
|
||||
This matrix tests all stable releases 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.
|
||||
|
||||
```yaml
|
||||
name: My workflow
|
||||
@@ -80,17 +81,23 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-latest, macos-latest ]
|
||||
ruby: [ 2.4, 2.5, 2.6, 2.7, jruby, truffleruby ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
os: [ubuntu, macos]
|
||||
ruby: [2.5, 2.6, 2.7, head, debug, jruby, jruby-head, truffleruby, truffleruby-head]
|
||||
runs-on: ${{ matrix.os }}-latest
|
||||
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby }}
|
||||
- run: ruby -v
|
||||
- run: bundle install
|
||||
- run: bundle exec rake
|
||||
```
|
||||
|
||||
See the GitHub Actions documentation for more details about the
|
||||
[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).
|
||||
|
||||
### Supported Version Syntax
|
||||
|
||||
* engine-version like `ruby-2.6.5` and `truffleruby-19.3.0`
|
||||
@@ -105,7 +112,7 @@ jobs:
|
||||
|
||||
By default, if there is a `Gemfile.lock` file with a `BUNDLED WITH` section,
|
||||
the latest version of Bundler with the same major version will be installed.
|
||||
Otherwise, the latest Bundler version is installed (except for Ruby 2.2 where only Bundler 1 is supported).
|
||||
Otherwise, the latest Bundler version is installed (except for Ruby 2.2 and 2.3 where only Bundler 1 is supported).
|
||||
|
||||
This behavior can be customized, see [action.yml](action.yml) for details about the `bundler` input.
|
||||
|
||||
@@ -122,8 +129,9 @@ You can cache the installed gems with these two steps:
|
||||
bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-
|
||||
- name: bundle install
|
||||
run: |
|
||||
bundle config deployment true
|
||||
bundle config path vendor/bundle
|
||||
bundle install --jobs 4 --retry 3
|
||||
bundle install --jobs 4
|
||||
```
|
||||
|
||||
When using a single OS, replace `${{ matrix.os }}` with the OS.
|
||||
|
||||
+33
-15
@@ -969,6 +969,7 @@ module.exports = require("os");
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "run", function() { return run; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupRuby", function() { return setupRuby; });
|
||||
const os = __webpack_require__(87)
|
||||
const fs = __webpack_require__(747)
|
||||
const path = __webpack_require__(622)
|
||||
@@ -976,19 +977,31 @@ const core = __webpack_require__(470)
|
||||
const exec = __webpack_require__(986)
|
||||
const common = __webpack_require__(239)
|
||||
|
||||
const inputDefaults = {
|
||||
'ruby-version': 'default',
|
||||
'bundler': 'default',
|
||||
'working-directory': '.',
|
||||
}
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
await main()
|
||||
const options = {}
|
||||
for (const key in inputDefaults) {
|
||||
options[key] = core.getInput(key)
|
||||
}
|
||||
await setupRuby(options)
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
process.chdir(core.getInput('working-directory'))
|
||||
async function setupRuby(options) {
|
||||
const inputs = { ...inputDefaults, ...options }
|
||||
|
||||
process.chdir(inputs['working-directory'])
|
||||
|
||||
const platform = common.getVirtualEnvironmentName()
|
||||
const [engine, parsedVersion] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
||||
const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version'])
|
||||
|
||||
let installer
|
||||
if (platform === 'windows-latest' && engine !== 'jruby') {
|
||||
@@ -1006,9 +1019,9 @@ async function main() {
|
||||
|
||||
setupPath(newPathEntries)
|
||||
|
||||
if (core.getInput('bundler') !== 'none') {
|
||||
if (inputs['bundler'] !== 'none') {
|
||||
await common.measure('Installing Bundler', async () =>
|
||||
installBundler(platform, rubyPrefix, engine, version))
|
||||
installBundler(inputs['bundler'], platform, rubyPrefix, engine, version))
|
||||
}
|
||||
|
||||
core.setOutput('ruby-prefix', rubyPrefix)
|
||||
@@ -1036,7 +1049,7 @@ function parseRubyEngineAndVersion(rubyVersion) {
|
||||
}
|
||||
|
||||
let engine, version
|
||||
if (rubyVersion.match(/^(\d+|head|mingw|mswin)/)) { // X.Y.Z => ruby-X.Y.Z
|
||||
if (rubyVersion.match(/^(\d+)/) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z
|
||||
engine = 'ruby'
|
||||
version = rubyVersion
|
||||
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion
|
||||
@@ -1057,7 +1070,7 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe
|
||||
let version = parsedVersion
|
||||
if (!engineVersions.includes(parsedVersion)) {
|
||||
const latestToFirstVersion = engineVersions.slice().reverse()
|
||||
const found = latestToFirstVersion.find(v => v !== 'head' && v.startsWith(parsedVersion))
|
||||
const found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion))
|
||||
if (found) {
|
||||
version = found
|
||||
} else {
|
||||
@@ -1113,8 +1126,8 @@ function readBundledWithFromGemfileLock() {
|
||||
return null
|
||||
}
|
||||
|
||||
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
var bundlerVersion = core.getInput('bundler')
|
||||
async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine, rubyVersion) {
|
||||
var bundlerVersion = bundlerVersionInput
|
||||
|
||||
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
||||
bundlerVersion = readBundledWithFromGemfileLock()
|
||||
@@ -1127,15 +1140,20 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
bundlerVersion = '2'
|
||||
}
|
||||
|
||||
if (rubyVersion.startsWith('2.2')) {
|
||||
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
|
||||
bundlerVersion = '1'
|
||||
} else if (/^\d+/.test(bundlerVersion)) {
|
||||
if (/^\d+/.test(bundlerVersion)) {
|
||||
// OK
|
||||
} else {
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
}
|
||||
|
||||
if (rubyVersion.startsWith('2.2')) {
|
||||
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
|
||||
bundlerVersion = '1'
|
||||
} else if (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')
|
||||
bundlerVersion = '1'
|
||||
}
|
||||
|
||||
if (engine === 'ruby' && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') {
|
||||
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
|
||||
} else if (engine === 'truffleruby' && bundlerVersion === '1') {
|
||||
@@ -1471,7 +1489,7 @@ function getVersions(platform) {
|
||||
],
|
||||
"truffleruby": [
|
||||
"19.3.0", "19.3.1",
|
||||
"20.0.0",
|
||||
"20.0.0", "20.1.0",
|
||||
"head"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,19 +5,31 @@ const core = require('@actions/core')
|
||||
const exec = require('@actions/exec')
|
||||
const common = require('./common')
|
||||
|
||||
const inputDefaults = {
|
||||
'ruby-version': 'default',
|
||||
'bundler': 'default',
|
||||
'working-directory': '.',
|
||||
}
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
await main()
|
||||
const options = {}
|
||||
for (const key in inputDefaults) {
|
||||
options[key] = core.getInput(key)
|
||||
}
|
||||
await setupRuby(options)
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
process.chdir(core.getInput('working-directory'))
|
||||
export async function setupRuby(options) {
|
||||
const inputs = { ...inputDefaults, ...options }
|
||||
|
||||
process.chdir(inputs['working-directory'])
|
||||
|
||||
const platform = common.getVirtualEnvironmentName()
|
||||
const [engine, parsedVersion] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
||||
const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version'])
|
||||
|
||||
let installer
|
||||
if (platform === 'windows-latest' && engine !== 'jruby') {
|
||||
@@ -35,9 +47,9 @@ async function main() {
|
||||
|
||||
setupPath(newPathEntries)
|
||||
|
||||
if (core.getInput('bundler') !== 'none') {
|
||||
if (inputs['bundler'] !== 'none') {
|
||||
await common.measure('Installing Bundler', async () =>
|
||||
installBundler(platform, rubyPrefix, engine, version))
|
||||
installBundler(inputs['bundler'], platform, rubyPrefix, engine, version))
|
||||
}
|
||||
|
||||
core.setOutput('ruby-prefix', rubyPrefix)
|
||||
@@ -65,7 +77,7 @@ function parseRubyEngineAndVersion(rubyVersion) {
|
||||
}
|
||||
|
||||
let engine, version
|
||||
if (rubyVersion.match(/^(\d+|head|mingw|mswin)/)) { // X.Y.Z => ruby-X.Y.Z
|
||||
if (rubyVersion.match(/^(\d+)/) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z
|
||||
engine = 'ruby'
|
||||
version = rubyVersion
|
||||
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion
|
||||
@@ -86,7 +98,7 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe
|
||||
let version = parsedVersion
|
||||
if (!engineVersions.includes(parsedVersion)) {
|
||||
const latestToFirstVersion = engineVersions.slice().reverse()
|
||||
const found = latestToFirstVersion.find(v => v !== 'head' && v.startsWith(parsedVersion))
|
||||
const found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion))
|
||||
if (found) {
|
||||
version = found
|
||||
} else {
|
||||
@@ -142,8 +154,8 @@ function readBundledWithFromGemfileLock() {
|
||||
return null
|
||||
}
|
||||
|
||||
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
var bundlerVersion = core.getInput('bundler')
|
||||
async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine, rubyVersion) {
|
||||
var bundlerVersion = bundlerVersionInput
|
||||
|
||||
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
||||
bundlerVersion = readBundledWithFromGemfileLock()
|
||||
@@ -156,15 +168,20 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
bundlerVersion = '2'
|
||||
}
|
||||
|
||||
if (rubyVersion.startsWith('2.2')) {
|
||||
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
|
||||
bundlerVersion = '1'
|
||||
} else if (/^\d+/.test(bundlerVersion)) {
|
||||
if (/^\d+/.test(bundlerVersion)) {
|
||||
// OK
|
||||
} else {
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
}
|
||||
|
||||
if (rubyVersion.startsWith('2.2')) {
|
||||
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
|
||||
bundlerVersion = '1'
|
||||
} else if (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')
|
||||
bundlerVersion = '1'
|
||||
}
|
||||
|
||||
if (engine === 'ruby' && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') {
|
||||
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
|
||||
} else if (engine === 'truffleruby' && bundlerVersion === '1') {
|
||||
|
||||
@@ -16,7 +16,7 @@ export function getVersions(platform) {
|
||||
],
|
||||
"truffleruby": [
|
||||
"19.3.0", "19.3.1",
|
||||
"20.0.0",
|
||||
"20.0.0", "20.1.0",
|
||||
"head"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user