mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d6280ad19 | ||
|
|
980126329a | ||
|
|
4f28d1c82e | ||
|
|
53b22d2360 | ||
|
|
55dff253ca | ||
|
|
e15ecc8aaa | ||
|
|
71f024b642 | ||
|
|
30011b6444 |
@@ -2,6 +2,7 @@ name: Test this action
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches-ignore:
|
branches-ignore:
|
||||||
|
- master
|
||||||
- v1
|
- v1
|
||||||
tags-ignore:
|
tags-ignore:
|
||||||
- '*'
|
- '*'
|
||||||
@@ -14,7 +15,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
|
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
|
||||||
# Use various version syntaxes here for testing
|
# Use various version syntaxes here for testing
|
||||||
ruby: [ .ruby-version, 2.2, 2.3, 2.7.0, ruby-head, jruby, truffleruby, truffleruby-head, rubinius ]
|
ruby: [ .ruby-version, .tool-versions, 2.2, 2.3, ruby-head, jruby, truffleruby, truffleruby-head, rubinius ]
|
||||||
exclude:
|
exclude:
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
ruby: truffleruby
|
ruby: truffleruby
|
||||||
@@ -34,7 +35,7 @@ jobs:
|
|||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: ${{ matrix.ruby }}
|
||||||
- run: ruby --version
|
- run: ruby --version
|
||||||
- run: ridk version
|
- run: ridk version
|
||||||
if: matrix.os == 'windows-latest' && !startsWith(matrix.ruby, '2.3') && !startsWith(matrix.ruby, '2.2')
|
if: matrix.os == 'windows-latest' && !startsWith(matrix.ruby, 'jruby') && !startsWith(matrix.ruby, '2.3') && !startsWith(matrix.ruby, '2.2')
|
||||||
- name: Subprocess test
|
- name: Subprocess test
|
||||||
run: ruby test_subprocess.rb
|
run: ruby test_subprocess.rb
|
||||||
- name: OpenSSL version
|
- name: OpenSSL version
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
nodejs 12.0.0
|
||||||
|
ruby 2.7.0
|
||||||
@@ -91,7 +91,11 @@ jobs:
|
|||||||
* short version like `2.6`, automatically using the latest release matching that version (`2.6.5`)
|
* 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
|
* version only like `2.6.5`, assumes MRI for the engine
|
||||||
* engine only like `truffleruby`, uses the latest stable release of that implementation
|
* 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
|
|
||||||
|
|
||||||
|
* `.ruby-version` reads from the project's `.ruby-version` file
|
||||||
|
* `.tool-versions` reads from the project's `.tool-versions` file
|
||||||
|
* If the `ruby-version` input is not specified, `.ruby-version` is tried first, followed by `.tool-versions`
|
||||||
|
|
||||||
### Bundler
|
### Bundler
|
||||||
|
|
||||||
@@ -117,12 +121,24 @@ You can cache the installed gems with these two steps:
|
|||||||
```
|
```
|
||||||
|
|
||||||
When using a single job with a Ruby version, replace `${{ matrix.ruby }}` with the Ruby version.
|
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') }}`.
|
When using `.ruby-version`, replace `${{ matrix.ruby }}` with `${{ hashFiles('.ruby-version') }}`.
|
||||||
|
When using `.tool-versions`, replace `${{ matrix.ruby }}` with `${{ hashFiles('.tool-versions') }}`.
|
||||||
|
|
||||||
This uses the [cache action](https://github.com/actions/cache).
|
This uses the [cache action](https://github.com/actions/cache).
|
||||||
The code above is a more complete version of the [Ruby - Bundler example](https://github.com/actions/cache/blob/master/examples.md#ruby---bundler).
|
The code above is a more complete version of the [Ruby - Bundler example](https://github.com/actions/cache/blob/master/examples.md#ruby---bundler).
|
||||||
Make sure to include `use-ruby` in the `key` to avoid conflicting with previous caches.
|
Make sure to include `use-ruby` in the `key` to avoid conflicting with previous caches.
|
||||||
|
|
||||||
|
## Windows
|
||||||
|
|
||||||
|
Note that running CI on Windows can be quite challenging if you are not very familiar with Windows.
|
||||||
|
It is recommended to first get your build working on Ubuntu and macOS before trying Windows.
|
||||||
|
|
||||||
|
* The default shell on Windows is not Bash but [PowerShell](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell).
|
||||||
|
This can lead issues such as multi-line scripts [not working as expected](https://github.com/ruby/setup-ruby/issues/13).
|
||||||
|
* The `PATH` contains [multiple compiler toolchains](https://github.com/ruby/setup-ruby/issues/19). Use `where.exe` to debug which tool is used.
|
||||||
|
* MSYS2 is prepended to the `PATH`, similar to what RubyInstaller2 does.
|
||||||
|
* JRuby on Windows has a known bug that `bundle exec rake` [fails](https://github.com/ruby/setup-ruby/issues/18).
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
* This action currently only works with GitHub-hosted runners, not private runners.
|
* This action currently only works with GitHub-hosted runners, not private runners.
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ inputs:
|
|||||||
ruby-version:
|
ruby-version:
|
||||||
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version if unset.'
|
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version if unset.'
|
||||||
required: false
|
required: false
|
||||||
default: '.ruby-version'
|
default: 'default'
|
||||||
outputs:
|
outputs:
|
||||||
ruby-prefix:
|
ruby-prefix:
|
||||||
description: 'The prefix of the installed ruby'
|
description: 'The prefix of the installed ruby'
|
||||||
|
|||||||
+40
-13
@@ -1416,9 +1416,24 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseRubyEngineAndVersion(rubyVersion) {
|
function parseRubyEngineAndVersion(rubyVersion) {
|
||||||
|
if (rubyVersion === 'default') {
|
||||||
|
if (fs.existsSync('.ruby-version')) {
|
||||||
|
rubyVersion = '.ruby-version'
|
||||||
|
} else if (fs.existsSync('.tool-versions')) {
|
||||||
|
rubyVersion = '.tool-versions'
|
||||||
|
} else {
|
||||||
|
throw new Error('input ruby-version needs to be specified if no .ruby-version or .tool-versions file exists')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
|
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
|
||||||
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
|
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
|
||||||
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
|
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
|
||||||
|
} else if (rubyVersion === '.tool-versions') { // Read from .tool-versions
|
||||||
|
const toolVersions = fs.readFileSync('.tool-versions', 'utf8').trim()
|
||||||
|
const rubyLine = toolVersions.split(/\r?\n/).filter(e => e.match(/^ruby\s/))[0]
|
||||||
|
rubyVersion = rubyLine.split(/\s+/, 2)[1]
|
||||||
|
console.log(`Using ${rubyVersion} as input from file .tool-versions`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let engine, version
|
let engine, version
|
||||||
@@ -5160,9 +5175,13 @@ function getAvailableVersions(platform, engine) {
|
|||||||
async function install(platform, ruby) {
|
async function install(platform, ruby) {
|
||||||
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||||
|
|
||||||
core.addPath(path.join(rubyPrefix, 'bin'))
|
if (platform === 'windows-latest') {
|
||||||
if (ruby.startsWith('rubinius')) {
|
__webpack_require__(826).setupPath(undefined, rubyPrefix)
|
||||||
core.addPath(path.join(rubyPrefix, 'gems', 'bin'))
|
} else {
|
||||||
|
core.addPath(path.join(rubyPrefix, 'bin'))
|
||||||
|
if (ruby.startsWith('rubinius')) {
|
||||||
|
core.addPath(path.join(rubyPrefix, 'gems', 'bin'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rubyPrefix
|
return rubyPrefix
|
||||||
@@ -7860,6 +7879,7 @@ module.exports = function mergeConfig(config1, config2) {
|
|||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAvailableVersions", function() { return getAvailableVersions; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAvailableVersions", function() { return getAvailableVersions; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "install", function() { return install; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "install", function() { return install; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupPath", function() { return setupPath; });
|
||||||
// Most of this logic is from
|
// Most of this logic is from
|
||||||
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
||||||
|
|
||||||
@@ -7891,12 +7911,11 @@ async function install(platform, ruby) {
|
|||||||
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
|
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
|
||||||
|
|
||||||
const downloadPath = await tc.downloadTool(url)
|
const downloadPath = await tc.downloadTool(url)
|
||||||
await exec.exec(`7z x ${downloadPath} -xr!${base}\\share\\doc -o${drive}:\\`)
|
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
|
||||||
const rubyPrefix = `${drive}:\\${base}`
|
const rubyPrefix = `${drive}:\\${base}`
|
||||||
|
|
||||||
const [hostedRuby, msys2] = await linkMSYS2()
|
const [hostedRuby, msys2] = await linkMSYS2()
|
||||||
const newPath = setupPath(msys2, rubyPrefix)
|
setupPath(msys2, rubyPrefix)
|
||||||
core.exportVariable('PATH', newPath)
|
|
||||||
|
|
||||||
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
||||||
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`)
|
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`)
|
||||||
@@ -7925,21 +7944,29 @@ async function linkMSYS2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupPath(msys2, rubyPrefix) {
|
function setupPath(msys2, rubyPrefix) {
|
||||||
let path = process.env['PATH'].split(';')
|
const originalPath = process.env['PATH'].split(';')
|
||||||
|
let path = originalPath.slice()
|
||||||
// Remove conflicting dev tools from PATH
|
|
||||||
path = path.filter(e => !e.match(/\b(Chocolatey|CMake|mingw64|OpenSSL|Strawberry)\b/))
|
|
||||||
|
|
||||||
// Remove default Ruby in PATH
|
// Remove default Ruby in PATH
|
||||||
path = path.filter(e => !e.match(/\bRuby\b/))
|
path = path.filter(e => !e.match(/\bRuby\b/))
|
||||||
|
|
||||||
// Add MSYS2 in PATH
|
if (msys2) {
|
||||||
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
|
// Add MSYS2 in PATH
|
||||||
|
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
|
||||||
|
}
|
||||||
|
|
||||||
// Add the downloaded Ruby in PATH
|
// Add the downloaded Ruby in PATH
|
||||||
path.unshift(`${rubyPrefix}\\bin`)
|
path.unshift(`${rubyPrefix}\\bin`)
|
||||||
|
|
||||||
return path.join(';')
|
console.log("Entries removed from PATH to avoid conflicts with Ruby:")
|
||||||
|
for (const entry of originalPath) {
|
||||||
|
if (!path.includes(entry)) {
|
||||||
|
console.log(entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const newPath = path.join(';')
|
||||||
|
core.exportVariable('PATH', newPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,24 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseRubyEngineAndVersion(rubyVersion) {
|
function parseRubyEngineAndVersion(rubyVersion) {
|
||||||
|
if (rubyVersion === 'default') {
|
||||||
|
if (fs.existsSync('.ruby-version')) {
|
||||||
|
rubyVersion = '.ruby-version'
|
||||||
|
} else if (fs.existsSync('.tool-versions')) {
|
||||||
|
rubyVersion = '.tool-versions'
|
||||||
|
} else {
|
||||||
|
throw new Error('input ruby-version needs to be specified if no .ruby-version or .tool-versions file exists')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
|
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
|
||||||
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
|
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
|
||||||
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
|
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
|
||||||
|
} else if (rubyVersion === '.tool-versions') { // Read from .tool-versions
|
||||||
|
const toolVersions = fs.readFileSync('.tool-versions', 'utf8').trim()
|
||||||
|
const rubyLine = toolVersions.split(/\r?\n/).filter(e => e.match(/^ruby\s/))[0]
|
||||||
|
rubyVersion = rubyLine.split(/\s+/, 2)[1]
|
||||||
|
console.log(`Using ${rubyVersion} as input from file .tool-versions`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let engine, version
|
let engine, version
|
||||||
|
|||||||
+7
-3
@@ -16,9 +16,13 @@ export function getAvailableVersions(platform, engine) {
|
|||||||
export async function install(platform, ruby) {
|
export async function install(platform, ruby) {
|
||||||
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||||
|
|
||||||
core.addPath(path.join(rubyPrefix, 'bin'))
|
if (platform === 'windows-latest') {
|
||||||
if (ruby.startsWith('rubinius')) {
|
require('./windows').setupPath(undefined, rubyPrefix)
|
||||||
core.addPath(path.join(rubyPrefix, 'gems', 'bin'))
|
} else {
|
||||||
|
core.addPath(path.join(rubyPrefix, 'bin'))
|
||||||
|
if (ruby.startsWith('rubinius')) {
|
||||||
|
core.addPath(path.join(rubyPrefix, 'gems', 'bin'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rubyPrefix
|
return rubyPrefix
|
||||||
|
|||||||
+18
-11
@@ -29,12 +29,11 @@ export async function install(platform, ruby) {
|
|||||||
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
|
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
|
||||||
|
|
||||||
const downloadPath = await tc.downloadTool(url)
|
const downloadPath = await tc.downloadTool(url)
|
||||||
await exec.exec(`7z x ${downloadPath} -xr!${base}\\share\\doc -o${drive}:\\`)
|
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
|
||||||
const rubyPrefix = `${drive}:\\${base}`
|
const rubyPrefix = `${drive}:\\${base}`
|
||||||
|
|
||||||
const [hostedRuby, msys2] = await linkMSYS2()
|
const [hostedRuby, msys2] = await linkMSYS2()
|
||||||
const newPath = setupPath(msys2, rubyPrefix)
|
setupPath(msys2, rubyPrefix)
|
||||||
core.exportVariable('PATH', newPath)
|
|
||||||
|
|
||||||
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
||||||
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`)
|
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`)
|
||||||
@@ -62,20 +61,28 @@ async function linkMSYS2() {
|
|||||||
return [latestHostedRuby, msys2]
|
return [latestHostedRuby, msys2]
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupPath(msys2, rubyPrefix) {
|
export function setupPath(msys2, rubyPrefix) {
|
||||||
let path = process.env['PATH'].split(';')
|
const originalPath = process.env['PATH'].split(';')
|
||||||
|
let path = originalPath.slice()
|
||||||
// Remove conflicting dev tools from PATH
|
|
||||||
path = path.filter(e => !e.match(/\b(Chocolatey|CMake|mingw64|OpenSSL|Strawberry)\b/))
|
|
||||||
|
|
||||||
// Remove default Ruby in PATH
|
// Remove default Ruby in PATH
|
||||||
path = path.filter(e => !e.match(/\bRuby\b/))
|
path = path.filter(e => !e.match(/\bRuby\b/))
|
||||||
|
|
||||||
// Add MSYS2 in PATH
|
if (msys2) {
|
||||||
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
|
// Add MSYS2 in PATH
|
||||||
|
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
|
||||||
|
}
|
||||||
|
|
||||||
// Add the downloaded Ruby in PATH
|
// Add the downloaded Ruby in PATH
|
||||||
path.unshift(`${rubyPrefix}\\bin`)
|
path.unshift(`${rubyPrefix}\\bin`)
|
||||||
|
|
||||||
return path.join(';')
|
console.log("Entries removed from PATH to avoid conflicts with Ruby:")
|
||||||
|
for (const entry of originalPath) {
|
||||||
|
if (!path.includes(entry)) {
|
||||||
|
console.log(entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const newPath = path.join(';')
|
||||||
|
core.exportVariable('PATH', newPath)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user