Compare commits

...
16 Commits
Author SHA1 Message Date
Benoit Daloze f964e8aa48 Try to find the Bundler version from Gemfile.lock, otherwise install latest 2020-04-01 00:10:54 +02:00
Benoit Daloze e16528e678 Test all Ruby minor versions
* Skip tests on the older ubuntu-16.04 to have a reasonable number of jobs
2020-04-01 00:10:54 +02:00
Benoit Daloze 11238a2c00 Install Bundler at runtime if not already part of the stdlib
* This gives more flexibility to choose the Bundler version.
2020-03-31 22:23:11 +02:00
Benoit Daloze 1e2e6e19e3 Add the latest CRuby releases 2020-03-31 22:16:34 +02:00
Benoit Daloze a1c5b2a66c Switch to builds with --enable-shared and without Bundler pre-installed 2020-03-31 22:14:53 +02:00
MSP-Greg e648fd85b4 Windows - set ENV['MAKE'] 2020-03-31 18:44:54 +02:00
Benoit Daloze fb9d6fbc69 Automatically create a ~/.gemrc file
* To avoid generating documentation on `gem install`, which can take a long time.
2020-03-30 22:04:39 +02:00
Benoit Daloze 9c77d1b41f Prefer path.delimiter to the hardcoded value 2020-03-30 22:04:39 +02:00
MSP-Greg 2641afc25c Windows MSYS - move install to ssd drive 2020-03-30 12:28:12 +02:00
MSP-Greg d785726c7f export run 2020-03-28 15:28:40 +01:00
Benoit Daloze c33236e6da Simplify README 2020-03-28 14:06:05 +01:00
Benoit Daloze e0c562b83f Call 7z silently since it's too verbose 2020-03-28 14:05:21 +01:00
MSP-Greg 04510c677e README.md - add info re MSYS install for MinGW 2.2 and 2.3 Rubies 2020-03-28 14:00:06 +01:00
MSP-Greg c4665148cf Actions - add gcc --version output for MinGW Rubies 2020-03-28 14:00:06 +01:00
MSP-Greg 0a45f18d44 windows.js - install old MSYS devkit for MinGW 2.2 and 2.3 2020-03-28 14:00:06 +01:00
Benoit Daloze 2e60bdd7e4 Mention that only a few Ruby 2.3.x versions are available on Windows
* Fixes https://github.com/ruby/setup-ruby/issues/40
2020-03-27 15:39:59 +01:00
8 changed files with 261 additions and 68 deletions
+19 -13
View File
@@ -14,9 +14,9 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ] os: [ ubuntu-latest, macos-latest, windows-latest ]
# Use various version syntaxes here for testing # Use various version syntaxes here for testing
ruby: [ 2.2, 2.3, .ruby-version, .tool-versions, ruby-head, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ] ruby: [ 2.2, 2.3, 2.4, 2.5, 2.6.5, 2.7, ruby-head, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
exclude: exclude:
- os: windows-latest - os: windows-latest
ruby: truffleruby ruby: truffleruby
@@ -33,14 +33,17 @@ jobs:
- name: build compiler - name: build compiler
run: | run: |
ruby -e "puts 'build compiler: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown').lines.first" ruby -e "puts 'build compiler: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown').lines.first"
- name: ridk version (mingw) - name: gcc and ridk version (mingw)
if: startsWith(matrix.os, 'windows') if: startsWith(matrix.os, 'windows')
run: | run: |
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ') $abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
if (($abi -ge '2.4') -and $plat.Contains('mingw')) { if ($plat.Contains('mingw')) {
ridk version gcc --version
} else { if ($abi -ge '2.4') {
echo 'ridk is unavailable' ridk version
} else {
echo 'ridk is unavailable'
}
} }
- name: Subprocess test - name: Subprocess test
run: ruby test_subprocess.rb run: ruby test_subprocess.rb
@@ -87,14 +90,17 @@ jobs:
- name: build compiler - name: build compiler
run: | run: |
ruby -e "puts 'build compiler: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown').lines.first" ruby -e "puts 'build compiler: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown').lines.first"
- name: ridk version (mingw) - name: gcc and ridk version (mingw)
if: startsWith(matrix.cfg.os, 'windows') if: startsWith(matrix.os, 'windows')
run: | run: |
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ') $abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
if (($abi -ge '2.4') -and $plat.Contains('mingw')) { if ($plat.Contains('mingw')) {
ridk version gcc --version
} else { if ($abi -ge '2.4') {
echo 'ridk is unavailable' ridk version
} else {
echo 'ridk is unavailable'
}
} }
- name: Subprocess test - name: Subprocess test
run: ruby test_subprocess.rb run: ruby test_subprocess.rb
+13 -7
View File
@@ -17,16 +17,19 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
| Interpreter | Versions | | Interpreter | Versions |
| ----------- | -------- | | ----------- | -------- |
| Ruby | 2.2, 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, head, mingw, mswin | | 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, mingw, mswin |
| JRuby | 9.1.17.0, 9.2.9.0 - 9.2.11.1, head | | 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.0.0, head |
| Rubinius | 4.14 | | Rubinius | 4.14 |
On Windows, `mingw` and `mswin` are `ruby-head` builds using the MSYS2/MinGW and the MSVC toolchains respectively. On Windows, `mingw` and `mswin` are `ruby-head` builds using the MSYS2/MinGW and the MSVC toolchains respectively.
Ruby 2.2 resolves to 2.2.6 on Windows (last build from RubyInstaller) and 2.2.10 otherwise.
Ruby 2.3 on Windows only has builds for 2.3.0, 2.3.1 and 2.3.3 (same as RubyInstaller).
Note that Ruby ≤ 2.3 and the OpenSSL version it needs (1.0.2) are both end-of-life, 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. 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. On Windows, Ruby 2.4 uses OpenSSL 1.0.2, which is no longer maintained.
Ruby 2.2 resolves to 2.2.6 on Windows (last build from RubyInstaller) and 2.2.10 otherwise.
### Supported Platforms ### Supported Platforms
@@ -102,9 +105,11 @@ jobs:
### Bundler ### Bundler
Currently, Bundler is guaranteed to be installed for all versions. By default, if there is a `Gemfile.lock` file with a `BUNDLED WITH` section,
If the Ruby ships with Bundler (Ruby >= 2.6), that version is used. the latest version of Bundler with the same major version will be installed.
Otherwise (Ruby < 2.6), Bundler 1 is installed when that Ruby was built. Otherwise, the latest Bundler version is installed (except for Ruby 2.2 where only Bundler 1 is supported).
This behavior can be customized, see [action.yml](action.yml) for details about the `bundler` input.
### Caching `bundle install` ### Caching `bundle install`
@@ -140,7 +145,8 @@ It is recommended to first get your build working on Ubuntu and macOS before try
* 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). * 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). 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. * 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. * For Ruby ≥ 2.4, MSYS2 is prepended to the `Path`, similar to what RubyInstaller2 does.
* For Ruby < 2.4, the DevKit MSYS tools are installed and prepended to the `Path`.
* JRuby on Windows has a known bug that `bundle exec rake` [fails](https://github.com/ruby/setup-ruby/issues/18). * JRuby on Windows has a known bug that `bundle exec rake` [fails](https://github.com/ruby/setup-ruby/issues/18).
## Limitations ## Limitations
+4
View File
@@ -9,6 +9,10 @@ inputs:
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: 'default' default: 'default'
bundler:
description: 'The version of Bundler to install. Either none, 1, 2, latest or Gemfile.lock. The default tries Gemfile.lock and otherwise uses latest.'
required: false
default: 'default'
outputs: outputs:
ruby-prefix: ruby-prefix:
description: 'The prefix of the installed ruby' description: 'The prefix of the installed ruby'
Generated Vendored
+114 -24
View File
@@ -951,12 +951,16 @@ module.exports = require("os");
/***/ }), /***/ }),
/***/ 104: /***/ 104:
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) { /***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "run", function() { return run; });
const os = __webpack_require__(87) const os = __webpack_require__(87)
const fs = __webpack_require__(747) const fs = __webpack_require__(747)
const path = __webpack_require__(622) const path = __webpack_require__(622)
const core = __webpack_require__(470) const core = __webpack_require__(470)
const exec = __webpack_require__(986)
async function run() { async function run() {
try { try {
@@ -973,9 +977,14 @@ async function run() {
const engineVersions = installer.getAvailableVersions(platform, engine) const engineVersions = installer.getAvailableVersions(platform, engine)
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version) const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
createGemRC()
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby) const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
setupPath(ruby, newPathEntries) setupPath(ruby, newPathEntries)
await installBundler(platform, rubyPrefix, engine, version)
core.setOutput('ruby-prefix', rubyPrefix) core.setOutput('ruby-prefix', rubyPrefix)
} catch (error) { } catch (error) {
core.setFailed(error.message) core.setFailed(error.message)
@@ -1037,6 +1046,13 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, version)
return engine + '-' + version return engine + '-' + version
} }
function createGemRC() {
const gemrc = path.join(os.homedir(), '.gemrc')
if (!fs.existsSync(gemrc)) {
fs.writeFileSync(gemrc, `gem: --no-document${os.EOL}`)
}
}
function setupPath(ruby, newPathEntries) { function setupPath(ruby, newPathEntries) {
const originalPath = process.env['PATH'].split(path.delimiter) const originalPath = process.env['PATH'].split(path.delimiter)
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry)) let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
@@ -1053,6 +1069,58 @@ function setupPath(ruby, newPathEntries) {
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter)) core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
} }
function readBundledWithFromGemfileLock() {
if (fs.existsSync('Gemfile.lock')) {
const contents = fs.readFileSync('Gemfile.lock', 'utf8')
const lines = contents.split(/\r?\n/)
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
if (bundledWithLine !== -1) {
const nextLine = lines[bundledWithLine+1]
if (nextLine && /^\d+/.test(nextLine.trim())) {
const bundlerVersion = nextLine.trim()
const majorVersion = bundlerVersion.match(/^\d+/)[0]
console.log(`Using Bundler ${majorVersion} from Gemfile.lock BUNDLED WITH ${bundlerVersion}`)
return majorVersion
}
}
}
return null
}
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
var bundlerVersion = core.getInput('bundler')
if (bundlerVersion === 'none') {
return
}
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
bundlerVersion = readBundledWithFromGemfileLock()
if (!bundlerVersion) {
bundlerVersion = 'latest'
}
}
let versionArray
if (rubyVersion.startsWith('2.2')) {
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
versionArray = ['-v', '~> 1']
} else if (/^\d+/.test(bundlerVersion)) {
versionArray = ['-v', `~> ${bundlerVersion}`]
} else if (bundlerVersion === 'latest') {
versionArray = []
} else {
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
}
if (engine === 'rubinius') {
console.log(`Rubinius only supports the version of Bundler shipped with it`)
} else if (bundlerVersion === '1' && engine === 'truffleruby') {
console.log(`Using the Bundler version shipped with ${engine}`)
} else {
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', ...versionArray, '--no-document'])
}
}
function getVirtualEnvironmentName() { function getVirtualEnvironmentName() {
const platform = os.platform() const platform = os.platform()
if (platform === 'linux') { if (platform === 'linux') {
@@ -1076,7 +1144,7 @@ function findUbuntuVersion() {
} }
} }
run() if (__filename.endsWith('index.js')) { run() }
/***/ }), /***/ }),
@@ -1386,10 +1454,10 @@ function getVersions(platform) {
"ruby": [ "ruby": [
"2.2.10", "2.2.10",
"2.3.0", "2.3.1", "2.3.2", "2.3.3", "2.3.4", "2.3.5", "2.3.6", "2.3.7", "2.3.8", "2.3.0", "2.3.1", "2.3.2", "2.3.3", "2.3.4", "2.3.5", "2.3.6", "2.3.7", "2.3.8",
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9", "2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9", "2.4.10",
"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.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.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
"2.7.0", "2.7.0", "2.7.1",
"head" "head"
], ],
"jruby": [ "jruby": [
@@ -3403,7 +3471,7 @@ const io = __webpack_require__(1)
const tc = __webpack_require__(533) const tc = __webpack_require__(533)
const rubyBuilderVersions = __webpack_require__(156) const rubyBuilderVersions = __webpack_require__(156)
const builderReleaseTag = 'builds-no-warn' const builderReleaseTag = 'enable-shared'
const releasesURL = 'https://github.com/ruby/ruby-builder/releases' const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
function getAvailableVersions(platform, engine) { function getAvailableVersions(platform, engine) {
@@ -3412,7 +3480,7 @@ 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)
let newPathEntries; let newPathEntries
if (ruby.startsWith('rubinius')) { if (ruby.startsWith('rubinius')) {
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')] newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
} else { } else {
@@ -4798,19 +4866,28 @@ __webpack_require__.r(__webpack_exports__);
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js // https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
const fs = __webpack_require__(747) const fs = __webpack_require__(747)
const path = __webpack_require__(622)
const cp = __webpack_require__(129) const cp = __webpack_require__(129)
const core = __webpack_require__(470) const core = __webpack_require__(470)
const exec = __webpack_require__(986) const exec = __webpack_require__(986)
const tc = __webpack_require__(533) const tc = __webpack_require__(533)
const rubyInstallerVersions = __webpack_require__(471).versions const rubyInstallerVersions = __webpack_require__(471).versions
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
// needed for 2.2, 2.3, and mswin, cert file used by Git for Windows // needed for 2.2, 2.3, and mswin, cert file used by Git for Windows
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem' const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
// standard MSYS2 location, found by 'devkit' // standard MSYS2 location, found by 'devkit.rb'
const msys2 = 'C:\\msys64' const msys2 = 'C:\\msys64'
const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`] const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.2 and 2.3
const msys = `${drive}:\\DevKit64`
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`,
`${msys}\\mingw\\bin`, `${msys}\\bin`]
function getAvailableVersions(platform, engine) { function getAvailableVersions(platform, engine) {
if (engine === 'ruby') { if (engine === 'ruby') {
return Object.keys(rubyInstallerVersions) return Object.keys(rubyInstallerVersions)
@@ -4829,9 +4906,6 @@ async function install(platform, ruby) {
} }
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length) const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
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}:\\`], { silent: true }) await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
const rubyPrefix = `${drive}:\\${base}` const rubyPrefix = `${drive}:\\${base}`
@@ -4840,11 +4914,6 @@ async function install(platform, ruby) {
await setupMSWin() : await setupMingw(version) await setupMSWin() : await setupMingw(version)
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths] const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
// Install Bundler if needed
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
}
return [rubyPrefix, newPathEntries] return [rubyPrefix, newPathEntries]
} }
@@ -4861,19 +4930,40 @@ async function symLinkToEmbeddedMSYS2() {
} }
async function setupMingw(version) { async function setupMingw(version) {
core.exportVariable('MAKE', 'make.exe')
if (version.startsWith('2.2') || version.startsWith('2.3')) { if (version.startsWith('2.2') || version.startsWith('2.3')) {
core.exportVariable('SSL_CERT_FILE', certFile) core.exportVariable('SSL_CERT_FILE', certFile)
} await installMSYS(version)
// Remove when Actions Windows image contains MSYS2 install return msysPathEntries
if (!fs.existsSync(msys2)) { } else {
await symLinkToEmbeddedMSYS2() // Remove when Actions Windows image contains MSYS2 install
} if (!fs.existsSync(msys2)) {
await symLinkToEmbeddedMSYS2()
}
return msys2PathEntries return msys2PathEntries
}
}
// Ruby 2.2 and 2.3
async function installMSYS(version) {
const url = 'https://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe'
const downloadPath = await tc.downloadTool(url)
await exec.exec('7z', ['x', downloadPath, `-o${msys}`], { silent: true })
// below are set in the old devkit.rb file ?
core.exportVariable('RI_DEVKIT', msys)
core.exportVariable('CC' , 'gcc')
core.exportVariable('CXX', 'g++')
core.exportVariable('CPP', 'cpp')
core.info(`Installed RubyInstaller DevKit for Ruby ${version}`)
} }
async function setupMSWin() { async function setupMSWin() {
core.exportVariable('MAKE', 'nmake.exe')
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL // All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs' const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
if (!fs.existsSync(certsDir)) { if (!fs.existsSync(certsDir)) {
@@ -4915,7 +5005,7 @@ function addVCVARSEnv() {
for (let [k, v] of newEnv) { for (let [k, v] of newEnv) {
if (process.env[k] !== v) { if (process.env[k] !== v) {
if (k === 'Path') { if (k === 'Path') {
newPathEntries = v.replace(process.env['Path'], '').split(';') newPathEntries = v.replace(process.env['Path'], '').split(path.delimiter)
} else { } else {
core.exportVariable(k, v) core.exportVariable(k, v)
} }
+67 -2
View File
@@ -2,8 +2,9 @@ const os = require('os')
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const core = require('@actions/core') const core = require('@actions/core')
const exec = require('@actions/exec')
async function run() { export async function run() {
try { try {
const platform = getVirtualEnvironmentName() const platform = getVirtualEnvironmentName()
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version')) const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
@@ -18,9 +19,14 @@ async function run() {
const engineVersions = installer.getAvailableVersions(platform, engine) const engineVersions = installer.getAvailableVersions(platform, engine)
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version) const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
createGemRC()
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby) const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
setupPath(ruby, newPathEntries) setupPath(ruby, newPathEntries)
await installBundler(platform, rubyPrefix, engine, version)
core.setOutput('ruby-prefix', rubyPrefix) core.setOutput('ruby-prefix', rubyPrefix)
} catch (error) { } catch (error) {
core.setFailed(error.message) core.setFailed(error.message)
@@ -82,6 +88,13 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, version)
return engine + '-' + version return engine + '-' + version
} }
function createGemRC() {
const gemrc = path.join(os.homedir(), '.gemrc')
if (!fs.existsSync(gemrc)) {
fs.writeFileSync(gemrc, `gem: --no-document${os.EOL}`)
}
}
function setupPath(ruby, newPathEntries) { function setupPath(ruby, newPathEntries) {
const originalPath = process.env['PATH'].split(path.delimiter) const originalPath = process.env['PATH'].split(path.delimiter)
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry)) let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
@@ -98,6 +111,58 @@ function setupPath(ruby, newPathEntries) {
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter)) core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
} }
function readBundledWithFromGemfileLock() {
if (fs.existsSync('Gemfile.lock')) {
const contents = fs.readFileSync('Gemfile.lock', 'utf8')
const lines = contents.split(/\r?\n/)
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
if (bundledWithLine !== -1) {
const nextLine = lines[bundledWithLine+1]
if (nextLine && /^\d+/.test(nextLine.trim())) {
const bundlerVersion = nextLine.trim()
const majorVersion = bundlerVersion.match(/^\d+/)[0]
console.log(`Using Bundler ${majorVersion} from Gemfile.lock BUNDLED WITH ${bundlerVersion}`)
return majorVersion
}
}
}
return null
}
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
var bundlerVersion = core.getInput('bundler')
if (bundlerVersion === 'none') {
return
}
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
bundlerVersion = readBundledWithFromGemfileLock()
if (!bundlerVersion) {
bundlerVersion = 'latest'
}
}
let versionArray
if (rubyVersion.startsWith('2.2')) {
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
versionArray = ['-v', '~> 1']
} else if (/^\d+/.test(bundlerVersion)) {
versionArray = ['-v', `~> ${bundlerVersion}`]
} else if (bundlerVersion === 'latest') {
versionArray = []
} else {
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
}
if (engine === 'rubinius') {
console.log(`Rubinius only supports the version of Bundler shipped with it`)
} else if (bundlerVersion === '1' && engine === 'truffleruby') {
console.log(`Using the Bundler version shipped with ${engine}`)
} else {
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', ...versionArray, '--no-document'])
}
}
function getVirtualEnvironmentName() { function getVirtualEnvironmentName() {
const platform = os.platform() const platform = os.platform()
if (platform === 'linux') { if (platform === 'linux') {
@@ -121,4 +186,4 @@ function findUbuntuVersion() {
} }
} }
run() if (__filename.endsWith('index.js')) { run() }
+4 -4
View File
@@ -3,10 +3,10 @@ export function getVersions(platform) {
"ruby": [ "ruby": [
"2.2.10", "2.2.10",
"2.3.0", "2.3.1", "2.3.2", "2.3.3", "2.3.4", "2.3.5", "2.3.6", "2.3.7", "2.3.8", "2.3.0", "2.3.1", "2.3.2", "2.3.3", "2.3.4", "2.3.5", "2.3.6", "2.3.7", "2.3.8",
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9", "2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9", "2.4.10",
"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.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.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
"2.7.0", "2.7.0", "2.7.1",
"head" "head"
], ],
"jruby": [ "jruby": [
+2 -2
View File
@@ -5,7 +5,7 @@ const io = require('@actions/io')
const tc = require('@actions/tool-cache') const tc = require('@actions/tool-cache')
const rubyBuilderVersions = require('./ruby-builder-versions') const rubyBuilderVersions = require('./ruby-builder-versions')
const builderReleaseTag = 'builds-no-warn' const builderReleaseTag = 'enable-shared'
const releasesURL = 'https://github.com/ruby/ruby-builder/releases' const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
export function getAvailableVersions(platform, engine) { export function getAvailableVersions(platform, engine) {
@@ -14,7 +14,7 @@ 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)
let newPathEntries; let newPathEntries
if (ruby.startsWith('rubinius')) { if (ruby.startsWith('rubinius')) {
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')] newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
} else { } else {
+38 -16
View File
@@ -2,19 +2,28 @@
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js // https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
const fs = require('fs') const fs = require('fs')
const path = require('path')
const cp = require('child_process') const cp = require('child_process')
const core = require('@actions/core') const core = require('@actions/core')
const exec = require('@actions/exec') const exec = require('@actions/exec')
const tc = require('@actions/tool-cache') const tc = require('@actions/tool-cache')
const rubyInstallerVersions = require('./windows-versions').versions const rubyInstallerVersions = require('./windows-versions').versions
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
// needed for 2.2, 2.3, and mswin, cert file used by Git for Windows // needed for 2.2, 2.3, and mswin, cert file used by Git for Windows
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem' const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
// standard MSYS2 location, found by 'devkit' // standard MSYS2 location, found by 'devkit.rb'
const msys2 = 'C:\\msys64' const msys2 = 'C:\\msys64'
const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`] const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.2 and 2.3
const msys = `${drive}:\\DevKit64`
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`,
`${msys}\\mingw\\bin`, `${msys}\\bin`]
export function getAvailableVersions(platform, engine) { export function getAvailableVersions(platform, engine) {
if (engine === 'ruby') { if (engine === 'ruby') {
return Object.keys(rubyInstallerVersions) return Object.keys(rubyInstallerVersions)
@@ -33,9 +42,6 @@ export async function install(platform, ruby) {
} }
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length) const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
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}:\\`], { silent: true }) await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
const rubyPrefix = `${drive}:\\${base}` const rubyPrefix = `${drive}:\\${base}`
@@ -44,11 +50,6 @@ export async function install(platform, ruby) {
await setupMSWin() : await setupMingw(version) await setupMSWin() : await setupMingw(version)
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths] const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
// Install Bundler if needed
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
}
return [rubyPrefix, newPathEntries] return [rubyPrefix, newPathEntries]
} }
@@ -65,19 +66,40 @@ async function symLinkToEmbeddedMSYS2() {
} }
async function setupMingw(version) { async function setupMingw(version) {
core.exportVariable('MAKE', 'make.exe')
if (version.startsWith('2.2') || version.startsWith('2.3')) { if (version.startsWith('2.2') || version.startsWith('2.3')) {
core.exportVariable('SSL_CERT_FILE', certFile) core.exportVariable('SSL_CERT_FILE', certFile)
} await installMSYS(version)
// Remove when Actions Windows image contains MSYS2 install return msysPathEntries
if (!fs.existsSync(msys2)) { } else {
await symLinkToEmbeddedMSYS2() // Remove when Actions Windows image contains MSYS2 install
} if (!fs.existsSync(msys2)) {
await symLinkToEmbeddedMSYS2()
}
return msys2PathEntries return msys2PathEntries
}
}
// Ruby 2.2 and 2.3
async function installMSYS(version) {
const url = 'https://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe'
const downloadPath = await tc.downloadTool(url)
await exec.exec('7z', ['x', downloadPath, `-o${msys}`], { silent: true })
// below are set in the old devkit.rb file ?
core.exportVariable('RI_DEVKIT', msys)
core.exportVariable('CC' , 'gcc')
core.exportVariable('CXX', 'g++')
core.exportVariable('CPP', 'cpp')
core.info(`Installed RubyInstaller DevKit for Ruby ${version}`)
} }
async function setupMSWin() { async function setupMSWin() {
core.exportVariable('MAKE', 'nmake.exe')
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL // All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs' const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
if (!fs.existsSync(certsDir)) { if (!fs.existsSync(certsDir)) {
@@ -119,7 +141,7 @@ export function addVCVARSEnv() {
for (let [k, v] of newEnv) { for (let [k, v] of newEnv) {
if (process.env[k] !== v) { if (process.env[k] !== v) {
if (k === 'Path') { if (k === 'Path') {
newPathEntries = v.replace(process.env['Path'], '').split(';') newPathEntries = v.replace(process.env['Path'], '').split(path.delimiter)
} else { } else {
core.exportVariable(k, v) core.exportVariable(k, v)
} }