mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66836a17bb | ||
|
|
933f496844 | ||
|
|
b3249de963 | ||
|
|
2a5386fca2 | ||
|
|
51f9fc6d8a | ||
|
|
0b83c28888 | ||
|
|
98c68de273 | ||
|
|
4c25e810ed | ||
|
|
2127b4bb68 | ||
|
|
626b752912 | ||
|
|
819c372fe9 | ||
|
|
268389d93d | ||
|
|
92bcdc74f7 | ||
|
|
5ee96a474a | ||
|
|
a61be15bff | ||
|
|
b339f321d1 | ||
|
|
73ad84b99b | ||
|
|
565ac51b83 | ||
|
|
f06c4d9ab7 | ||
|
|
5adac4fda6 |
@@ -7,7 +7,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
|
||||
# Use various version syntaxes here for testing
|
||||
ruby: [ 2.3, ruby-2.4, 2.5, ruby-2.6.5, 2.7.0, jruby, truffleruby ]
|
||||
ruby: [ .ruby-version, 2.3, ruby-2.4, 2.5, ruby-2.6.5, 2.7.0, jruby, truffleruby ]
|
||||
exclude:
|
||||
- os: windows-latest
|
||||
ruby: 2.3
|
||||
@@ -21,8 +21,21 @@ jobs:
|
||||
- uses: ./
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby }}
|
||||
- run: ruby -v
|
||||
- run: ruby --version
|
||||
- run: ridk version
|
||||
if: matrix.os == 'windows-latest'
|
||||
- run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(2014) }'
|
||||
- run: gem install json --no-document
|
||||
- name: OpenSSL test
|
||||
run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(2014) }'
|
||||
- name: C extension test
|
||||
run: gem install json --no-document
|
||||
- name: Check that Bundler is installed
|
||||
run: bundle --version
|
||||
- name: Check that Bundler works
|
||||
run: bundle install
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn install
|
||||
- run: yarn run lint
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ruby-2.6.5
|
||||
@@ -0,0 +1,5 @@
|
||||
# Used for testing
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem "path"
|
||||
gem "json"
|
||||
@@ -11,9 +11,9 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
|
||||
|
||||
| Interpreter | Versions |
|
||||
| ----------- | -------- |
|
||||
| Ruby | 2.3.8, 2.4.9, 2.5.7, 2.6.5, 2.7.0 |
|
||||
| Ruby | 2.3.0 - 2.3.8, 2.4.0 - 2.4.9, 2.5.0 - 2.5.7, 2.6.0 - 2.6.5, 2.7.0 |
|
||||
| JRuby | 9.2.9.0 |
|
||||
| TruffleRuby | 19.3.0 |
|
||||
| TruffleRuby | 19.3.0, 19.3.1 |
|
||||
|
||||
The recommended way to refer to these versions is:
|
||||
`2.3`, `2.4`, `2.5`, `2.6`, `2.7`, `jruby`, `truffleruby`.
|
||||
@@ -24,6 +24,7 @@ for the always up-to-date list of available Ruby versions.
|
||||
|
||||
Note that Ruby 2.3 and the OpenSSL version it needs (1.0.2) are both end-of-life,
|
||||
which means Ruby 2.3 is unmaintained and considered insecure.
|
||||
On Windows, Ruby 2.4 uses OpenSSL 1.0.2, which is no longer maintained.
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
@@ -82,6 +83,37 @@ jobs:
|
||||
* short version like `2.6`, automatically using the latest release matching that version (`2.6.5`)
|
||||
* version only like `2.6.5`, assumes MRI for the engine
|
||||
* engine only like `truffleruby`, uses the latest stable release of that implementation
|
||||
* `.ruby-version` (also the default value) reads from the project's `.ruby-version` file
|
||||
|
||||
### Bundler
|
||||
|
||||
Currently, Bundler is guaranteed to be installed for all versions.
|
||||
If the Ruby ships with Bundler (Ruby >= 2.6), that version is used.
|
||||
Otherwise (Ruby < 2.6), Bundler 1 is installed when that Ruby was built.
|
||||
|
||||
### Caching `bundle install`
|
||||
|
||||
You can cache the installed gems with these two steps:
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: vendor/bundle
|
||||
key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
|
||||
restore-keys: |
|
||||
bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-
|
||||
- name: Bundle install
|
||||
run: |
|
||||
bundle config path vendor/bundle
|
||||
bundle install --jobs 4 --retry 3
|
||||
```
|
||||
|
||||
When using a single job with a Ruby version, replace `${{ matrix.ruby }}` with the Ruby version.
|
||||
When using `.ruby-version`, replace `${{ matrix.ruby }}` with `${{ hashFiles('.ruby-version') }}`.
|
||||
|
||||
This uses the [cache action](https://github.com/actions/cache).
|
||||
The code above is a more complete version of the [Ruby - Gem example](https://github.com/actions/cache/blob/master/examples.md#ruby---gem).
|
||||
Make sure to include `use-ruby` in the `key` to avoid conflicting with previous caches.
|
||||
|
||||
## Limitations
|
||||
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ branding:
|
||||
icon: download
|
||||
inputs:
|
||||
ruby-version:
|
||||
description: 'Engine and version to use, see the syntax in the README'
|
||||
required: true
|
||||
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version if unset.'
|
||||
default: '.ruby-version'
|
||||
outputs:
|
||||
ruby-prefix:
|
||||
description: 'The prefix of the installed ruby'
|
||||
|
||||
+15
-1
@@ -1399,6 +1399,10 @@ async function run() {
|
||||
if (platform === 'windows-latest') {
|
||||
rubyPrefix = await windows.downloadExtractAndSetPATH(ruby)
|
||||
} else {
|
||||
if (ruby.startsWith('jruby')) {
|
||||
// Workaround for https://github.com/actions/virtual-environments/issues/242
|
||||
core.exportVariable('CLASSPATH', '')
|
||||
}
|
||||
rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||
core.addPath(`${rubyPrefix}/bin`)
|
||||
}
|
||||
@@ -1428,6 +1432,11 @@ async function getLatestReleaseTag() {
|
||||
}
|
||||
|
||||
async function getRubyEngineAndVersion(rubyVersion) {
|
||||
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
|
||||
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
|
||||
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
|
||||
}
|
||||
|
||||
let engine, version
|
||||
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
|
||||
engine = 'ruby'
|
||||
@@ -6463,6 +6472,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
// Most of this logic is from
|
||||
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
||||
|
||||
const fs = __webpack_require__(747)
|
||||
const core = __webpack_require__(470)
|
||||
const exec = __webpack_require__(986)
|
||||
const tc = __webpack_require__(533)
|
||||
@@ -6488,6 +6498,10 @@ async function downloadExtractAndSetPATH(ruby) {
|
||||
const newPath = setupPath(msys2, rubyPrefix)
|
||||
core.exportVariable('PATH', newPath)
|
||||
|
||||
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
|
||||
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
|
||||
}
|
||||
|
||||
return rubyPrefix
|
||||
}
|
||||
|
||||
@@ -6516,7 +6530,7 @@ function setupPath(msys2, rubyPrefix) {
|
||||
path = path.filter(e => !e.match(/\bRuby\b/))
|
||||
|
||||
// Add MSYS2 in PATH
|
||||
path.unshift(`${msys2}\\mingw64`, `${msys2}\\usr`)
|
||||
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
|
||||
|
||||
// Add the downloaded Ruby in PATH
|
||||
path.unshift(`${rubyPrefix}\\bin`)
|
||||
|
||||
@@ -18,6 +18,10 @@ async function run() {
|
||||
if (platform === 'windows-latest') {
|
||||
rubyPrefix = await windows.downloadExtractAndSetPATH(ruby)
|
||||
} else {
|
||||
if (ruby.startsWith('jruby')) {
|
||||
// Workaround for https://github.com/actions/virtual-environments/issues/242
|
||||
core.exportVariable('CLASSPATH', '')
|
||||
}
|
||||
rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||
core.addPath(`${rubyPrefix}/bin`)
|
||||
}
|
||||
@@ -47,6 +51,11 @@ async function getLatestReleaseTag() {
|
||||
}
|
||||
|
||||
async function getRubyEngineAndVersion(rubyVersion) {
|
||||
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
|
||||
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
|
||||
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
|
||||
}
|
||||
|
||||
let engine, version
|
||||
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
|
||||
engine = 'ruby'
|
||||
|
||||
+6
-1
@@ -1,6 +1,7 @@
|
||||
// Most of this logic is from
|
||||
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
||||
|
||||
const fs = require('fs')
|
||||
const core = require('@actions/core')
|
||||
const exec = require('@actions/exec')
|
||||
const tc = require('@actions/tool-cache')
|
||||
@@ -26,6 +27,10 @@ export async function downloadExtractAndSetPATH(ruby) {
|
||||
const newPath = setupPath(msys2, rubyPrefix)
|
||||
core.exportVariable('PATH', newPath)
|
||||
|
||||
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
|
||||
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
|
||||
}
|
||||
|
||||
return rubyPrefix
|
||||
}
|
||||
|
||||
@@ -54,7 +59,7 @@ function setupPath(msys2, rubyPrefix) {
|
||||
path = path.filter(e => !e.match(/\bRuby\b/))
|
||||
|
||||
// Add MSYS2 in PATH
|
||||
path.unshift(`${msys2}\\mingw64`, `${msys2}\\usr`)
|
||||
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
|
||||
|
||||
// Add the downloaded Ruby in PATH
|
||||
path.unshift(`${rubyPrefix}\\bin`)
|
||||
|
||||
Reference in New Issue
Block a user