Compare commits

...
33 Commits
Author SHA1 Message Date
Benoit Daloze 7978ff1579 Print the OpenSSL version 2020-01-18 16:42:55 +01:00
Benoit Daloze 30cd88adf9 Use the newer builds from ruby-install-builder
* Which uses a newer OpenSSL for Ruby 2.3 on Ubuntu and macOS.
2020-01-18 16:36:23 +01:00
Benoit Daloze 7005fbe92a Embed the used tag in this repo for atomic updates
* Avoids stale cached requests for the latest_release.tag file.
* This also ensures reproducible builds for this repository.
2020-01-18 16:36:05 +01:00
Benoit Daloze 026be4409b Fix typo in OpenSSL test 2020-01-18 14:39:18 +01:00
Benoit Daloze 0ed24c9d6c Use shorter links in README 2020-01-17 23:17:26 +01:00
Benoit Daloze 9dab9b8155 Use a table for the Supported Platforms 2020-01-17 23:14:05 +01:00
Benoit Daloze 69709d16de Simplify the supported versions section
* Do not recommend a specific version syntax, different projects have
  different needs. The sample usages below already show the recommendation.
2020-01-17 23:01:13 +01:00
Benoit Daloze ae627f04d2 Skip CI when only modifying the README 2020-01-17 22:55:24 +01:00
Benoit Daloze eb85b2a580 Use the full repository name as the README title 2020-01-17 22:31:38 +01:00
Benoit Daloze 61efe96192 Use a single bug tracker for the action 2020-01-17 22:30:14 +01:00
Benoit Daloze 7b9c95cc8e Use "the PATH" instead of "$PATH"
* Since $PATH is a Unix-specific syntax.
2020-01-17 22:26:52 +01:00
Benoit Daloze 74ac24dec4 Add a section about versioning 2020-01-17 22:09:58 +01:00
Benoit Daloze b01832a197 Recommend to use eregon/use-ruby-action@v1 in the README 2020-01-17 22:00:29 +01:00
Benoit Daloze 66836a17bb Add TruffleRuby 19.3.1 2020-01-15 10:54:10 +01:00
Benoit Daloze 933f496844 Add a note about Ruby 2.4 on Windows
* See https://github.com/eregon/ruby-build/pull/1#issuecomment-573237440
2020-01-11 00:03:25 +01:00
Benoit Daloze b3249de963 Fix typo 2020-01-10 23:07:19 +01:00
Benoit Daloze 2a5386fca2 Improve clarity about the key for caching bundle install 2020-01-10 23:06:04 +01:00
Benoit Daloze 51f9fc6d8a Show a full example for caching bundle install
* Which should help avoid conflicts with previous caches
* See https://github.com/eregon/use-ruby-action/issues/7
2020-01-10 23:00:33 +01:00
Benoit Daloze 0b83c28888 Add a note about the workaround for https://github.com/actions/virtual-environments/issues/242 2020-01-09 18:16:05 +01:00
MSP-Greg 98c68de273 Set CLASSPATH to empty for JRuby 2020-01-09 18:15:08 +01:00
Benoit Daloze 4c25e810ed All 33 Ruby versions between 2.3.0 and 2.7.0 are now supported 2020-01-09 00:12:16 +01:00
Benoit Daloze 2127b4bb68 All Ruby versions between 2.4.0 and 2.6.5 are now supported 2020-01-08 22:47:25 +01:00
MSP-Greg 626b752912 Correct Windows MSYS2 paths 2020-01-08 22:41:06 +01:00
Benoit Daloze 819c372fe9 Install Bundler 1 on Windows for Ruby < 2.6 without Bundler 2020-01-08 22:15:01 +01:00
Benoit Daloze 268389d93d Use Bundler 1 for Rubies which don't already ship Bundler (< 2.6) 2020-01-08 21:55:11 +01:00
Benoit Daloze 92bcdc74f7 Link to the actions/cache example for Bundler caching 2020-01-07 22:11:59 +01:00
Benoit Daloze 5ee96a474a Keep documentation about the version syntax in one place 2020-01-06 22:11:28 +01:00
Benoit Daloze a61be15bff Read from .ruby-version if version is unset or set to '.ruby-version'
* Fixes https://github.com/eregon/use-ruby-action/issues/4
2020-01-06 22:00:45 +01:00
Benoit Daloze b339f321d1 Run lint in CI 2020-01-06 22:00:30 +01:00
Benoit Daloze 73ad84b99b Document about Bundler 2020-01-05 23:34:38 +01:00
Benoit Daloze 565ac51b83 Check that Bundler works 2020-01-05 23:26:03 +01:00
Benoit Daloze f06c4d9ab7 Install Bundler if needed on Windows 2020-01-05 23:21:44 +01:00
Benoit Daloze 5adac4fda6 Check that Bundler is installed 2020-01-05 23:20:09 +01:00
9 changed files with 122 additions and 43 deletions
+22 -5
View File
@@ -1,5 +1,8 @@
name: Test this action
on: [push]
on:
push:
paths-ignore:
- README.md
jobs:
test:
strategy:
@@ -7,7 +10,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 +24,22 @@ 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
- run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
- name: OpenSSL test
run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(1024) }'
- 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
+1
View File
@@ -0,0 +1 @@
ruby-2.6.5
+5
View File
@@ -0,0 +1,5 @@
# Used for testing
source 'https://rubygems.org'
gem "path"
gem "json"
+54 -16
View File
@@ -1,8 +1,8 @@
# use-ruby
# use-ruby-action
This action downloads a prebuilt ruby and adds it to `$PATH`.
This action downloads a prebuilt ruby and adds it to the `PATH`.
It is very efficient and takes about 5 seconds to download, extract and add the given Ruby to `$PATH`.
It is very efficient and takes about 5 seconds to download, extract and add the given Ruby to the `PATH`.
No extra packages need to be installed.
### Supported Versions
@@ -11,29 +11,31 @@ 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`.
That way, the latest compatible release is used, which contains the most bug fixes.
See https://github.com/eregon/ruby-install-builder/blob/metadata/versions.json
See [versions.json](https://github.com/eregon/ruby-install-builder/blob/metadata/versions.json)
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
The action works for all GitHub-hosted runners:
`ubuntu-16.04`, `ubuntu-18.04`, `macos-latest` and `windows-latest`.
The action works for all [GitHub-hosted runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners).
| Operating System | Versions |
| ----------- | -------- |
| Ubuntu | `ubuntu-latest` (= `ubuntu-18.04`), `ubuntu-16.04` |
| macOS | `macos-latest` |
| Windows | `windows-latest` |
Ruby 2.3, JRuby and TruffleRuby are not yet supported on `windows-latest`.
The prebuilt rubies are generated by https://github.com/eregon/ruby-install-builder
and on Windows by https://github.com/oneclick/rubyinstaller2.
The prebuilt rubies are generated by [eregon/ruby-install-builder](https://github.com/eregon/ruby-install-builder)
and on Windows by [RubyInstaller2](https://github.com/oneclick/rubyinstaller2).
## Usage
@@ -47,7 +49,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: eregon/use-ruby-action@master
- uses: eregon/use-ruby-action@v1
with:
ruby-version: 2.6
- run: ruby -v
@@ -70,7 +72,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: eregon/use-ruby-action@master
- uses: eregon/use-ruby-action@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: ruby -v
@@ -82,11 +84,47 @@ 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
* This action currently only works with GitHub-hosted runners, not private runners.
## Versioning
This action follows semantic versioning with a moving `v1` branch.
This follows the [recommendations](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) of GitHub Actions.
## Credits
Most of the Windows logic is from https://github.com/MSP-Greg/actions-ruby by MSP-Greg.
+3 -3
View File
@@ -1,13 +1,13 @@
name: 'Setup Ruby, JRuby and TruffleRuby'
description: 'Download a prebuilt Ruby and add it to $PATH in 5 seconds'
description: 'Download a prebuilt Ruby and add it to the PATH in 5 seconds'
author: 'Benoit Daloze'
branding:
color: red
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'
Generated Vendored
+18 -9
View File
@@ -1387,6 +1387,7 @@ const tc = __webpack_require__(533)
const axios = __webpack_require__(53)
const windows = __webpack_require__(664)
const builderReleaseTag = 'builds-newer-openssl'
const releasesURL = 'https://github.com/eregon/ruby-install-builder/releases'
const metadataURL = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata'
@@ -1399,6 +1400,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`)
}
@@ -1412,8 +1417,7 @@ async function downloadAndExtract(platform, ruby) {
const rubiesDir = `${process.env.HOME}/.rubies`
await io.mkdirP(rubiesDir)
const tag = await getLatestReleaseTag()
const url = `${releasesURL}/download/${tag}/${ruby}-${platform}.tar.gz`
const url = `${releasesURL}/download/${builderReleaseTag}/${ruby}-${platform}.tar.gz`
console.log(url)
const downloadPath = await tc.downloadTool(url)
@@ -1422,12 +1426,12 @@ async function downloadAndExtract(platform, ruby) {
return `${rubiesDir}/${ruby}`
}
async function getLatestReleaseTag() {
const response = await axios.get(`${metadataURL}/latest_release.tag`)
return response.data.trim()
}
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'
@@ -1455,7 +1459,7 @@ async function getRubyEngineAndVersion(rubyVersion) {
throw new Error(`Unknown version ${version} for ${engine}
input: ${rubyVersion}
available versions for ${engine}: ${engineVersions.join(', ')}
File an issue at https://github.com/eregon/ruby-install-builder/issues if would like support for a new version`)
File an issue at https://github.com/eregon/use-ruby-action/issues if would like support for a new version`)
}
}
@@ -6463,6 +6467,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 +6493,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 +6525,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`)
+12 -8
View File
@@ -6,6 +6,7 @@ const tc = require('@actions/tool-cache')
const axios = require('axios')
const windows = require('./windows')
const builderReleaseTag = 'builds-newer-openssl'
const releasesURL = 'https://github.com/eregon/ruby-install-builder/releases'
const metadataURL = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata'
@@ -18,6 +19,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`)
}
@@ -31,8 +36,7 @@ async function downloadAndExtract(platform, ruby) {
const rubiesDir = `${process.env.HOME}/.rubies`
await io.mkdirP(rubiesDir)
const tag = await getLatestReleaseTag()
const url = `${releasesURL}/download/${tag}/${ruby}-${platform}.tar.gz`
const url = `${releasesURL}/download/${builderReleaseTag}/${ruby}-${platform}.tar.gz`
console.log(url)
const downloadPath = await tc.downloadTool(url)
@@ -41,12 +45,12 @@ async function downloadAndExtract(platform, ruby) {
return `${rubiesDir}/${ruby}`
}
async function getLatestReleaseTag() {
const response = await axios.get(`${metadataURL}/latest_release.tag`)
return response.data.trim()
}
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'
@@ -74,7 +78,7 @@ async function getRubyEngineAndVersion(rubyVersion) {
throw new Error(`Unknown version ${version} for ${engine}
input: ${rubyVersion}
available versions for ${engine}: ${engineVersions.join(', ')}
File an issue at https://github.com/eregon/ruby-install-builder/issues if would like support for a new version`)
File an issue at https://github.com/eregon/use-ruby-action/issues if would like support for a new version`)
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "use-ruby-action",
"version": "0.1.0",
"description": "Download a prebuilt ruby and add it to $PATH",
"description": "Download a prebuilt Ruby and add it to the PATH in 5 seconds",
"main": "index.js",
"scripts": {
"lint": "eslint *.js",
+6 -1
View File
@@ -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`)