Compare commits

..
24 Commits
Author SHA1 Message Date
Benoit Daloze 66dc012cc3 Detect self-hosted runners not matching a GitHub-hosted runner image
* And give instructions for that case.
* Get the OS and OS version ourselves since some users set ImageOS incorrectly.
* This partially reverts commit ad1ebae995.
2023-03-03 16:33:57 +01:00
Benoit Daloze 2789f85824 Update bug_report.yml 2023-03-03 13:39:36 +01:00
Benoit Daloze fbb865d04d Update bug_report.yml 2023-03-03 13:36:11 +01:00
Benoit Daloze 96ac949ea0 Update bug_report.yml 2023-03-03 13:33:53 +01:00
Hiroshi SHIBATA 92aece5fc9 Also removed deprecated ubuntu-18.04 2023-02-27 19:56:46 +01:00
Hiroshi SHIBATA db791aad7b Removed macos-10.15 because it will be removed at 2023-03-31 2023-02-27 19:56:46 +01:00
ruby-builder-bot d3c9825d67 Update CRuby releases on Windows 2023-02-14 18:20:01 +01:00
Benoit Daloze f60ef1e808 Include working directory, $BUNDLE_WITH and $BUNDLE_WITHOUT in cache key
* Fixes https://github.com/ruby/setup-ruby/issues/350
* Fixes https://github.com/ruby/setup-ruby/issues/176
2023-02-11 14:17:29 +01:00
Benoit Daloze bc4e585e26 Don't show timing on error for clearer error output 2023-02-11 13:48:39 +01:00
Benoit Daloze 2cf593d66b Don't group bundle install output
* So any error from Bundler is immediately shown.
* Some users do not realize they should expand the group apparently.
2023-02-11 13:45:25 +01:00
Benoit Daloze a26e1fb6b3 Do not show a stacktrace if a process failed, only the message
* The stacktrace is confusing and rarely useful in that case.
2023-02-11 13:39:22 +01:00
ruby-builder-bot 4d060a10e6 Add ruby-3.2.1 2023-02-09 18:20:44 +00:00
ruby-builder-bot 77fe3b48b7 Add jruby-9.4.1.0 2023-02-08 10:26:25 +00:00
ruby-builder-bot 8df78e5576 Add jruby-9.3.10.0 2023-02-06 12:43:15 +00:00
ruby-builder-bot b8e62b879e Add truffleruby-22.3.1,truffleruby+graalvm-22.3.1 2023-01-24 19:23:27 +01:00
Benoit Daloze d60780f6b6 Simplify new-versions.rb 2023-01-24 19:15:59 +01:00
Benoit Daloze 8aa012b56d Debug new-versions.rb 2023-01-24 19:12:32 +01:00
Benoit Daloze 628be4e0e4 Fix new-versions.rb 2023-01-24 19:10:46 +01:00
MSP-Greg ee26e27437 Updates for Windows MSYS2 update to OpenSSL 3 2023-01-21 18:22:09 +01:00
Benoit Daloze 93287a1fa8 Revert "Export BUNDLER_VERSION after installing Bundler"
* This reverts commit 3190662165.
* It causes other issues such as https://github.com/ruby/setup-ruby/issues/444
  due to creating additional global state.
* The use-case it solves is too niche to risk such issues,
  using `bundler-cache: true` avoids the problem.
* See https://github.com/ruby/setup-ruby/issues/444#issuecomment-1377723414
2023-01-10 20:17:22 +01:00
Benoit Daloze 3190662165 Export BUNDLER_VERSION after installing Bundler
* Fixes https://github.com/ruby/setup-ruby/issues/440
2023-01-06 12:50:46 +01:00
Benoit Daloze eb7f94ffae Consider Bundler pre and rc versions valid, just exclude .dev
* Fixes https://github.com/ruby/setup-ruby/issues/439
2023-01-06 12:49:10 +01:00
Benoit Daloze ad718faf7a Break long line in workflow 2022-12-30 15:59:58 +01:00
Benoit Daloze 09c10210cc Implement targetRubyVersion for TruffleRuby
* Fixes #433
2022-12-30 15:55:07 +01:00
14 changed files with 609 additions and 226 deletions
+6 -1
View File
@@ -3,7 +3,12 @@ description: Create a report to help us improve
body: body:
- type: markdown - type: markdown
attributes: attributes:
value: Please note we will close your issue without comment if you do not fill out the requested information. value: |
First, take some time to think whether this is really an issue of ruby/setup-ruby and whether it is fixable in this action.
This action basically just downloads a prebuilt Ruby and adds it to `PATH`, so it is unlikely the bug is in this action.
Give some thoughts whether it could be an issue in your workflow, in the gems you use, in GitHub Actions, in Ruby, RubyGems, Bundler, etc.
This is NOT the place to ask help about your workflow failing (ask that on [GitHub Community](https://github.com/orgs/community/discussions/categories/actions) or [Discussions](https://github.com/ruby/setup-ruby/discussions) instead), it is only to report issues about ruby/setup-ruby.
Please note we will close your issue without comment if you do not fill out the requested information.
- type: checkboxes - type: checkboxes
attributes: attributes:
label: Ensure the following before filing this issue label: Ensure the following before filing this issue
+18 -2
View File
@@ -17,8 +17,13 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, macos-10.15, macos-11, macos-12, windows-2019, windows-2022 ] os: [ ubuntu-20.04, ubuntu-22.04, macos-11, macos-12, windows-2019, windows-2022 ]
ruby: [ '1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', ruby-head, jruby, jruby-head, truffleruby, truffleruby-head, truffleruby+graalvm, truffleruby+graalvm-head ] ruby: [
'1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', ruby-head,
jruby, jruby-head,
truffleruby, truffleruby-head,
truffleruby+graalvm, truffleruby+graalvm-head
]
include: include:
- { os: windows-2019, ruby: mingw } - { os: windows-2019, ruby: mingw }
- { os: windows-2019, ruby: mswin } - { os: windows-2019, ruby: mswin }
@@ -239,6 +244,17 @@ jobs:
bundler: 2.2.3 bundler: 2.2.3
- run: bundle --version | grep -F "Bundler version 2.2.3" - run: bundle --version | grep -F "Bundler version 2.2.3"
testBundlerPre:
name: "Test with a Bundler pre/rc version"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
ruby-version: '2.6'
bundler: 2.2.0.rc.2
- run: bundle --version | grep -F "Bundler version 2.2.0.rc.2"
testBundlerDev: testBundlerDev:
name: "Test BUNDLED WITH Bundler dev" name: "Test BUNDLED WITH Bundler dev"
runs-on: ubuntu-latest runs-on: ubuntu-latest
+9 -10
View File
@@ -15,10 +15,10 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
| Interpreter | Versions | | Interpreter | Versions |
| ----------- | -------- | | ----------- | -------- |
| `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.2.0, head, debug, mingw, mswin, ucrt | | `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.2.1, head, debug, mingw, mswin, ucrt |
| `jruby` | 9.1.17.0 - 9.4.0.0, head | | `jruby` | 9.1.17.0 - 9.4.1.0, head |
| `truffleruby` | 19.3.0 - 22.3.0, head | | `truffleruby` | 19.3.0 - 22.3.1, head |
| `truffleruby+graalvm` | 21.2.0 - 22.3.0, head | | `truffleruby+graalvm` | 21.2.0 - 22.3.1, head |
`ruby-debug` is the same as `ruby-head` but with assertions enabled (`-DRUBY_DEBUG=1`). `ruby-debug` is the same as `ruby-head` but with assertions enabled (`-DRUBY_DEBUG=1`).
@@ -42,8 +42,8 @@ The action works on these [GitHub-hosted runners](https://docs.github.com/en/act
| Operating System | Supported | | Operating System | Supported |
| ---------------- | --------- | | ---------------- | --------- |
| Ubuntu | `ubuntu-18.04`, `ubuntu-20.04`, `ubuntu-22.04` | | Ubuntu | `ubuntu-20.04`, `ubuntu-22.04` |
| macOS | `macos-10.15`, `macos-11`, `macos-12` | | macOS | `macos-11`, `macos-12` |
| Windows | `windows-2019`, `windows-2022` | | Windows | `windows-2019`, `windows-2022` |
The prebuilt releases are generated by [ruby-builder](https://github.com/ruby/ruby-builder) The prebuilt releases are generated by [ruby-builder](https://github.com/ruby/ruby-builder)
@@ -252,7 +252,6 @@ This action might work with [self-hosted runners](https://docs.github.com/en/act
if the [Runner Image](https://github.com/actions/runner-images) is very similar to the ones used by GitHub runners. Notably: if the [Runner Image](https://github.com/actions/runner-images) is very similar to the ones used by GitHub runners. Notably:
* Make sure to use the same operating system and version. * Make sure to use the same operating system and version.
* Set the environment variable `ImageOS` on the runner to the corresponding value on GitHub-hosted runners (e.g. `ubuntu18`/`macos1015`/`win19`). This is necessary to detect the operating system and version.
* Make sure to use the same version of libssl. * Make sure to use the same version of libssl.
* Make sure that the operating system has `libyaml-0` and [`libgmp`](https://stackoverflow.com/questions/26555902/ruby-v-dyld-library-not-loaded-usr-local-lib-libgmp-10-dylib) installed * Make sure that the operating system has `libyaml-0` and [`libgmp`](https://stackoverflow.com/questions/26555902/ruby-v-dyld-library-not-loaded-usr-local-lib-libgmp-10-dylib) installed
* The default tool cache directory (`/opt/hostedtoolcache` on Linux, `/Users/runner/hostedtoolcache` on macOS, * The default tool cache directory (`/opt/hostedtoolcache` on Linux, `/Users/runner/hostedtoolcache` on macOS,
@@ -260,9 +259,9 @@ if the [Runner Image](https://github.com/actions/runner-images) is very similar
This is necessary since the Ruby builds embed the install path when built and cannot be moved around. This is necessary since the Ruby builds embed the install path when built and cannot be moved around.
* `/home/runner` must be writable by the `runner` user. * `/home/runner` must be writable by the `runner` user.
In other cases, please use a system Ruby or [install Ruby manually](https://github.com/postmodern/chruby/wiki#installing-rubies) instead. In other cases, you will need to install Ruby in the runner tool cache as shown by the action when it detects that case
(run it so it will show you where to install Ruby).
On a self-hosted runner you need to define the `ImageOs` as an evironment variable on the host, you can do this in the `~/actions-runner/.env` file (See [#230](https://github.com/ruby/setup-ruby/issues/230)). You could of course also not use this action and e.g. use Ruby from a system package or use a Docker image instead.
## History ## History
+15 -6
View File
@@ -6,7 +6,10 @@ const cache = require('@actions/cache')
const common = require('./common') const common = require('./common')
export const DEFAULT_CACHE_VERSION = '0' export const DEFAULT_CACHE_VERSION = '0'
export const BUNDLER_VERSION_REGEXP = /^\d+(?:\.\d+){0,2}$/
function isValidBundlerVersion(bundlerVersion) {
return /^\d+(?:\.\d+){0,2}/.test(bundlerVersion) && !bundlerVersion.endsWith('.dev')
}
// The returned gemfile is guaranteed to exist, the lockfile might not exist // The returned gemfile is guaranteed to exist, the lockfile might not exist
export function detectGemfiles() { export function detectGemfiles() {
@@ -33,7 +36,7 @@ function readBundledWithFromGemfileLock(lockFile) {
const nextLine = lines[bundledWithLine+1] const nextLine = lines[bundledWithLine+1]
if (nextLine) { if (nextLine) {
const bundlerVersion = nextLine.trim() const bundlerVersion = nextLine.trim()
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) { if (isValidBundlerVersion(bundlerVersion)) {
console.log(`Using Bundler ${bundlerVersion} from ${lockFile} BUNDLED WITH ${bundlerVersion}`) console.log(`Using Bundler ${bundlerVersion} from ${lockFile} BUNDLED WITH ${bundlerVersion}`)
return bundlerVersion return bundlerVersion
} else { } else {
@@ -100,7 +103,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
bundlerVersion = '2' bundlerVersion = '2'
} }
if (BUNDLER_VERSION_REGEXP.test(bundlerVersion)) { if (isValidBundlerVersion(bundlerVersion)) {
// OK - input is a 1, 2, or 3 part version number // OK - input is a 1, 2, or 3 part version number
} else { } else {
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`) throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
@@ -139,7 +142,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
const force = ((platform.startsWith('windows-') && engine === 'ruby' && floatVersion >= 3.1) || (engine === 'truffleruby')) ? ['--force'] : [] const force = ((platform.startsWith('windows-') && engine === 'ruby' && floatVersion >= 3.1) || (engine === 'truffleruby')) ? ['--force'] : []
const versionParts = [...bundlerVersion.matchAll(/\d+/g)].length const versionParts = [...bundlerVersion.matchAll(/\d+/g)].length
const bundlerVersionConstraint = versionParts === 3 ? bundlerVersion : `~> ${bundlerVersion}.0` const bundlerVersionConstraint = versionParts >= 3 ? bundlerVersion : `~> ${bundlerVersion}.0`
await exec.exec(gem, ['install', 'bundler', ...force, '-v', bundlerVersionConstraint]) await exec.exec(gem, ['install', 'bundler', ...force, '-v', bundlerVersionConstraint])
@@ -229,8 +232,14 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
} }
async function computeBaseKey(platform, engine, version, lockFile, cacheVersion) { async function computeBaseKey(platform, engine, version, lockFile, cacheVersion) {
const cacheVersionSuffix = DEFAULT_CACHE_VERSION === cacheVersion ? '' : `-cachever:${cacheVersion}` const cwd = process.cwd()
let key = `setup-ruby-bundler-cache-v4-${platform}-${engine}-${version}${cacheVersionSuffix}` const bundleWith = process.env['BUNDLE_WITH'] || ''
const bundleWithout = process.env['BUNDLE_WITHOUT'] || ''
let key = `setup-ruby-bundler-cache-v5-${common.getOSNameVersionArch()}-${engine}-${version}-wd-${cwd}-with-${bundleWith}-without-${bundleWithout}`
if (cacheVersion !== DEFAULT_CACHE_VERSION) {
key += `-v-${cacheVersion}`
}
if (common.isHeadVersion(version)) { if (common.isHeadVersion(version)) {
if (engine !== 'jruby') { if (engine !== 'jruby') {
+89 -39
View File
@@ -6,6 +6,8 @@ const stream = require('stream')
const crypto = require('crypto') const crypto = require('crypto')
const core = require('@actions/core') const core = require('@actions/core')
const { performance } = require('perf_hooks') const { performance } = require('perf_hooks')
const linuxOSInfo = require('linux-os-info')
import macosRelease from 'macos-release'
export const windows = (os.platform() === 'win32') export const windows = (os.platform() === 'win32')
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14 // Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
@@ -47,6 +49,18 @@ export async function measure(name, block) {
} }
} }
// Same as mesaure() but without the group, and no time shown on error
export async function time(name, block) {
console.log(`> ${name}`)
const start = performance.now()
const value = await block()
const end = performance.now()
const duration = (end - start) / 1000.0
console.log(`Took ${duration.toFixed(2).padStart(6)} seconds`)
return value
}
export function isHeadVersion(rubyVersion) { export function isHeadVersion(rubyVersion) {
return ['head', 'debug', 'mingw', 'mswin', 'ucrt'].includes(rubyVersion) return ['head', 'debug', 'mingw', 'mswin', 'ucrt'].includes(rubyVersion)
} }
@@ -107,6 +121,14 @@ export function targetRubyVersion(engine, rubyVersion) {
} else if (version === 9.3) { } else if (version === 9.3) {
return 2.6 return 2.6
} }
} else if (engine.startsWith('truffleruby')) {
if (version < 21.0) {
return 2.6
} else if (version < 22.0) {
return 2.7
} else if (version < 23.0) {
return 3.0
}
} }
return 9.9 // unknown, assume recent return 9.9 // unknown, assume recent
@@ -131,55 +153,74 @@ export async function hashFile(file) {
return hash.digest('hex') return hash.digest('hex')
} }
function getImageOS() { const GitHubHostedPlatforms = [
const imageOS = process.env['ImageOS'] 'ubuntu-20.04-x64',
if (!imageOS) { 'ubuntu-22.04-x64',
throw new Error('The environment variable ImageOS must be set') 'macos-11-x64',
} 'macos-12-x64',
return imageOS 'windows-2019-x64',
} 'windows-2022-x64',
export const supportedPlatforms = [
'ubuntu-18.04',
'ubuntu-20.04',
'ubuntu-22.04',
'macos-10.15',
'macos-11',
'macos-12',
'windows-2019',
'windows-2022',
] ]
// Actually a self-hosted runner which does not correspond to a GitHub-hosted runner image
export function isSelfHostedRunner() {
return !GitHubHostedPlatforms.includes(getOSNameVersionArch())
}
let virtualEnvironmentName = undefined
export function getVirtualEnvironmentName() { export function getVirtualEnvironmentName() {
const imageOS = getImageOS() if (virtualEnvironmentName !== undefined) {
return virtualEnvironmentName
let match = imageOS.match(/^ubuntu(\d+)/) // e.g. ubuntu18
if (match) {
return `ubuntu-${match[1]}.04`
} }
match = imageOS.match(/^macos(\d{2})(\d+)?/) // e.g. macos1015, macos11 const platform = os.platform()
if (match) { let osName
if (match[2]) { let osVersion
return `macos-${match[1]}.${match[2]}` if (platform === 'linux') {
} else { const info = linuxOSInfo({mode: 'sync'})
return `macos-${match[1]}` osName = info.id
} osVersion = info.version_id
} else if (platform === 'darwin') {
osName = 'macos'
osVersion = macosRelease().version
} else if (platform === 'win32') {
osName = 'windows'
osVersion = findWindowsVersion()
} else {
throw new Error(`Unknown platform ${platform}`)
} }
match = imageOS.match(/^win(\d+)/) // e.g. win19 virtualEnvironmentName = `${osName}-${osVersion}`
if (match) { return virtualEnvironmentName
return `windows-20${match[1]}` }
}
throw new Error(`Unknown ImageOS ${imageOS}`) export function getOSNameVersionArch() {
return `${getVirtualEnvironmentName()}-${os.arch()}`
}
function findWindowsVersion() {
const version = os.version();
const match = version.match(/^Windows Server (\d+) Datacenter/)
if (match) {
return match[1]
} else {
throw new Error('Could not find Windows version')
}
} }
export function shouldUseToolCache(engine, version) { export function shouldUseToolCache(engine, version) {
return engine === 'ruby' && !isHeadVersion(version) return (engine === 'ruby' && !isHeadVersion(version)) || isSelfHostedRunner()
} }
function getPlatformToolCache(platform) { function getPlatformToolCache(platform) {
if (isSelfHostedRunner()) {
const runnerToolCache = process.env['RUNNER_TOOL_CACHE']
if (!runnerToolCache) {
throw new Error('$RUNNER_TOOL_CACHE must be set on self-hosted runners')
}
return runnerToolCache
}
// Hardcode paths rather than using $RUNNER_TOOL_CACHE because the prebuilt Rubies cannot be moved anyway // Hardcode paths rather than using $RUNNER_TOOL_CACHE because the prebuilt Rubies cannot be moved anyway
if (platform.startsWith('ubuntu-')) { if (platform.startsWith('ubuntu-')) {
return '/opt/hostedtoolcache' return '/opt/hostedtoolcache'
@@ -192,14 +233,23 @@ function getPlatformToolCache(platform) {
} }
} }
export function getToolCacheRubyPrefix(platform, version) { export function getToolCacheRubyPrefix(platform, engine, version) {
const toolCache = getPlatformToolCache(platform) const toolCache = getPlatformToolCache(platform)
return path.join(toolCache, 'Ruby', version, 'x64') const name = {
ruby: 'Ruby',
jruby: 'JRuby',
truffleruby: 'TruffleRuby',
"truffleruby+graalvm": 'TruffleRubyGraalVM'
}[engine]
return path.join(toolCache, name, version, os.arch())
}
export function toolCacheCompleteFile(toolCacheRubyPrefix) {
return `${toolCacheRubyPrefix}.complete`
} }
export function createToolCacheCompleteFile(toolCacheRubyPrefix) { export function createToolCacheCompleteFile(toolCacheRubyPrefix) {
const completeFile = `${toolCacheRubyPrefix}.complete` fs.writeFileSync(toolCacheCompleteFile(toolCacheRubyPrefix), '')
fs.writeFileSync(completeFile, '')
} }
// convert windows path like C:\Users\runneradmin to /c/Users/runneradmin // convert windows path like C:\Users\runneradmin to /c/Users/runneradmin
Generated Vendored
+381 -97
View File
File diff suppressed because one or more lines are too long
+8 -4
View File
@@ -23,7 +23,11 @@ export async function run() {
try { try {
await setupRuby() await setupRuby()
} catch (error) { } catch (error) {
core.setFailed(error.stack) if (/\bprocess\b.+\bfailed\b/.test(error.message)) {
core.setFailed(error.message)
} else {
core.setFailed(error.stack)
}
} }
} }
@@ -42,7 +46,7 @@ export async function setupRuby(options = {}) {
const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version']) const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version'])
let installer let installer
if (platform.startsWith('windows-') && engine === 'ruby') { if (platform.startsWith('windows-') && engine === 'ruby' && !common.isSelfHostedRunner()) {
installer = require('./windows') installer = require('./windows')
} else { } else {
installer = require('./ruby-builder') installer = require('./ruby-builder')
@@ -56,7 +60,7 @@ export async function setupRuby(options = {}) {
// JRuby can use compiled extension code, so make sure gcc exists. // JRuby can use compiled extension code, so make sure gcc exists.
// As of Jan-2022, JRuby compiles against msvcrt. // As of Jan-2022, JRuby compiles against msvcrt.
if (platform.startsWith('windows') && (engine === 'jruby') && if (platform.startsWith('windows') && engine === 'jruby' &&
!fs.existsSync('C:\\msys64\\mingw64\\bin\\gcc.exe')) { !fs.existsSync('C:\\msys64\\mingw64\\bin\\gcc.exe')) {
await require('./windows').installJRubyTools() await require('./windows').installJRubyTools()
} }
@@ -88,7 +92,7 @@ export async function setupRuby(options = {}) {
} }
if (inputs['bundler-cache'] === 'true') { if (inputs['bundler-cache'] === 'true') {
await common.measure('bundle install', async () => await common.time('bundle install', async () =>
bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version'])) bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version']))
} }
+43 -46
View File
@@ -1,65 +1,62 @@
versions = ARGV.fetch(0).split(',').map(&:strip) versions = ARGV.fetch(0).split(',').map(&:strip)
versions.each do |engine_version| p versions
engine_input, version = engine_version.split('-', 2)
if engine_input == 'windows' versions.each do |engine_version|
puts engine_version
engine, version = engine_version.split('-', 2)
p [engine, version]
if engine == 'windows'
require_relative 'generate-windows-versions' require_relative 'generate-windows-versions'
exit exit
end end
MATCH = case engine_input match = case engine
when 'ruby', 'jruby' when 'ruby', 'jruby'
/^\d+\.\d+\./ /^\d+\.\d+\./
when 'truffleruby' when 'truffleruby', 'truffleruby+graalvm'
/^\d+\./ /^\d+\./
end end
raise unless version[MATCH] raise engine_version unless version[match]
engines = [engine_input] # Update ruby-builder-versions.json
engines << 'truffleruby+graalvm' if engine_input == 'truffleruby' file = "#{__dir__}/ruby-builder-versions.json"
lines = File.readlines(file, chomp: true)
engines.each do |engine| from = lines.index { |line| line.include?(%{"#{engine}": [}) }
puts engine raise "Could not find start of #{engine}" unless from
to = from
to += 1 until lines[to].include?(']')
# Update ruby-builder-versions.json from += 1 # [
file = "#{__dir__}/ruby-builder-versions.json" to -= 2 # head, ]
lines = File.readlines(file, chomp: true)
from = lines.index { |line| line.include?(%{"#{engine}": [}) } puts lines[from..to]
raise "Could not find start of #{engine}" unless from
to = from
to += 1 until lines[to].include?(']')
from += 1 # [ release_line = lines[from..to].find { |line|
to -= 2 # head, ] v = line[/"([^"]+)"/, 1] and v[match] == version[match]
}
puts lines[from..to] if release_line
append = " #{version.inspect},"
release_line = lines[from..to].find { |line| release_line << append unless release_line.end_with?(append)
v = line[/"([^"]+)"/, 1] and v[MATCH] == version[MATCH] else
} lines.insert to+1, " #{version.inspect},"
if release_line
append = " #{version.inspect},"
release_line << append unless release_line.end_with?(append)
else
lines.insert to+1, " #{version.inspect},"
end
File.write(file, lines.join("\n") + "\n")
# Update README.md
file = "#{__dir__}/README.md"
lines = File.readlines(file)
engine_line = lines.find { |line| line.start_with?("| `#{engine}`") }
engine_line.sub!(/(.+ (?:-|until)) (\d+(?:\.\d+)+(?:-\w+)?)/) do
if Gem::Version.new(version) > Gem::Version.new($2)
"#{$1} #{version}"
else
$&
end
end
File.write(file, lines.join)
end end
File.write(file, lines.join("\n") + "\n")
# Update README.md
file = "#{__dir__}/README.md"
lines = File.readlines(file)
engine_line = lines.find { |line| line.start_with?("| `#{engine}`") }
engine_line.sub!(/(.+ (?:-|until)) (\d+(?:\.\d+)+(?:-\w+)?)/) do
if Gem::Version.new(version) > Gem::Version.new($2)
"#{$1} #{version}"
else
$&
end
end
File.write(file, lines.join)
end end
+2
View File
@@ -27,6 +27,8 @@
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2", "@actions/io": "^1.1.2",
"@actions/tool-cache": "^2", "@actions/tool-cache": "^2",
"linux-os-info": "^2.0.0",
"macos-release": "^3.1.0",
"semver": "^7.3.7" "semver": "^7.3.7"
}, },
"devDependencies": { "devDependencies": {
+5 -5
View File
@@ -11,26 +11,26 @@
"2.7.0", "2.7.1", "2.7.2", "2.7.3", "2.7.4", "2.7.5", "2.7.6", "2.7.7", "2.7.0", "2.7.1", "2.7.2", "2.7.3", "2.7.4", "2.7.5", "2.7.6", "2.7.7",
"3.0.0-preview1", "3.0.0-preview2", "3.0.0-rc1", "3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4", "3.0.5", "3.0.0-preview1", "3.0.0-preview2", "3.0.0-rc1", "3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4", "3.0.5",
"3.1.0-preview1", "3.1.0", "3.1.1", "3.1.2", "3.1.3", "3.1.0-preview1", "3.1.0", "3.1.1", "3.1.2", "3.1.3",
"3.2.0-preview1", "3.2.0-preview2", "3.2.0-preview3", "3.2.0-rc1", "3.2.0", "3.2.0-preview1", "3.2.0-preview2", "3.2.0-preview3", "3.2.0-rc1", "3.2.0", "3.2.1",
"head", "debug" "head", "debug"
], ],
"jruby": [ "jruby": [
"9.1.17.0", "9.1.17.0",
"9.2.9.0", "9.2.10.0", "9.2.11.0", "9.2.11.1", "9.2.12.0", "9.2.13.0", "9.2.14.0", "9.2.15.0", "9.2.16.0", "9.2.17.0", "9.2.18.0", "9.2.19.0", "9.2.20.0", "9.2.20.1", "9.2.21.0", "9.2.9.0", "9.2.10.0", "9.2.11.0", "9.2.11.1", "9.2.12.0", "9.2.13.0", "9.2.14.0", "9.2.15.0", "9.2.16.0", "9.2.17.0", "9.2.18.0", "9.2.19.0", "9.2.20.0", "9.2.20.1", "9.2.21.0",
"9.3.0.0", "9.3.1.0", "9.3.2.0", "9.3.3.0", "9.3.4.0", "9.3.6.0", "9.3.7.0", "9.3.8.0", "9.3.9.0", "9.3.0.0", "9.3.1.0", "9.3.2.0", "9.3.3.0", "9.3.4.0", "9.3.6.0", "9.3.7.0", "9.3.8.0", "9.3.9.0", "9.3.10.0",
"9.4.0.0", "9.4.0.0", "9.4.1.0",
"head" "head"
], ],
"truffleruby": [ "truffleruby": [
"19.3.0", "19.3.1", "19.3.0", "19.3.1",
"20.0.0", "20.1.0", "20.2.0", "20.3.0", "20.0.0", "20.1.0", "20.2.0", "20.3.0",
"21.0.0", "21.1.0", "21.2.0", "21.2.0.1", "21.3.0", "21.0.0", "21.1.0", "21.2.0", "21.2.0.1", "21.3.0",
"22.0.0.2", "22.1.0", "22.2.0", "22.3.0", "22.0.0.2", "22.1.0", "22.2.0", "22.3.0", "22.3.1",
"head" "head"
], ],
"truffleruby+graalvm": [ "truffleruby+graalvm": [
"21.2.0", "21.3.0", "21.2.0", "21.3.0",
"22.0.0.2", "22.1.0", "22.2.0", "22.3.0", "22.0.0.2", "22.1.0", "22.2.0", "22.3.0", "22.3.1",
"head" "head"
] ]
} }
+16 -5
View File
@@ -1,6 +1,7 @@
const os = require('os') 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 exec = require('@actions/exec') const exec = require('@actions/exec')
const io = require('@actions/io') const io = require('@actions/io')
const tc = require('@actions/tool-cache') const tc = require('@actions/tool-cache')
@@ -13,10 +14,6 @@ const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
const windows = common.windows const windows = common.windows
export function getAvailableVersions(platform, engine) { export function getAvailableVersions(platform, engine) {
if (!common.supportedPlatforms.includes(platform)) {
throw new Error(`Unsupported platform ${platform}`)
}
return rubyBuilderVersions[engine] return rubyBuilderVersions[engine]
} }
@@ -27,7 +24,21 @@ export async function install(platform, engine, version) {
if (inToolCache) { if (inToolCache) {
rubyPrefix = inToolCache rubyPrefix = inToolCache
} else { } else {
rubyPrefix = common.getToolCacheRubyPrefix(platform, version) const toolCacheRubyPrefix = common.getToolCacheRubyPrefix(platform, engine, version)
if (common.isSelfHostedRunner()) {
const rubyBuildDefinition = engine === 'ruby' ? version : `${engine}-${version}`
core.error(
`The current runner (${common.getOSNameVersionArch()}) was detected as self-hosted and not matching a GitHub-hosted runner image.\n` +
`In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build:\n` +
`You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml\n` +
`$ ruby-build ${rubyBuildDefinition} ${toolCacheRubyPrefix}\n` +
`Once that completes successfully, mark it as complete with:\n` +
`$ touch ${common.toolCacheCompleteFile(toolCacheRubyPrefix)}\n` +
`It is your responsibility to ensure installing Ruby like that is not done in parallel.\n`)
process.exit(1)
} else {
rubyPrefix = toolCacheRubyPrefix
}
} }
} else if (windows) { } else if (windows) {
rubyPrefix = path.join(`${common.drive}:`, `${engine}-${version}`) rubyPrefix = path.join(`${common.drive}:`, `${engine}-${version}`)
+1
View File
@@ -52,6 +52,7 @@
"3.1.2": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.1.2-1/rubyinstaller-3.1.2-1-x64.7z", "3.1.2": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.1.2-1/rubyinstaller-3.1.2-1-x64.7z",
"3.1.3": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.1.3-1/rubyinstaller-3.1.3-1-x64.7z", "3.1.3": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.1.3-1/rubyinstaller-3.1.3-1-x64.7z",
"3.2.0": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.2.0-1/rubyinstaller-3.2.0-1-x64.7z", "3.2.0": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.2.0-1/rubyinstaller-3.2.0-1-x64.7z",
"3.2.1": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.2.1-1/rubyinstaller-3.2.1-1-x64.7z",
"head": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-head-x64.7z", "head": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-head-x64.7z",
"mingw": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z", "mingw": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z",
"mswin": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z", "mswin": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z",
+6 -11
View File
@@ -27,13 +27,7 @@ const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
const msys1 = `${drive}:\\DevKit64` const msys1 = `${drive}:\\DevKit64`
const msysPathEntries = [`${msys1}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys1}\\mingw\\bin`, `${msys1}\\bin`] const msysPathEntries = [`${msys1}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys1}\\mingw\\bin`, `${msys1}\\bin`]
const virtualEnv = common.getVirtualEnvironmentName()
export function getAvailableVersions(platform, engine) { export function getAvailableVersions(platform, engine) {
if (!common.supportedPlatforms.includes(platform)) {
throw new Error(`Unsupported platform ${platform}`)
}
if (engine === 'ruby') { if (engine === 'ruby') {
return Object.keys(rubyInstallerVersions) return Object.keys(rubyInstallerVersions)
} else { } else {
@@ -46,7 +40,7 @@ export async function install(platform, engine, version) {
// The windows-2016 and windows-2019 images have MSYS2 build tools (C:/msys64/usr) // The windows-2016 and windows-2019 images have MSYS2 build tools (C:/msys64/usr)
// and MinGW build tools installed. The windows-2022 image has neither. // and MinGW build tools installed. The windows-2022 image has neither.
const hasMSYS2PreInstalled = ['windows-2019', 'windows-2016'].includes(virtualEnv) const hasMSYS2PreInstalled = ['windows-2019', 'windows-2016'].includes(platform)
if (!url.endsWith('.7z')) { if (!url.endsWith('.7z')) {
throw new Error(`URL should end in .7z: ${url}`) throw new Error(`URL should end in .7z: ${url}`)
@@ -59,7 +53,7 @@ export async function install(platform, engine, version) {
if (inToolCache) { if (inToolCache) {
rubyPrefix = inToolCache rubyPrefix = inToolCache
} else { } else {
rubyPrefix = common.getToolCacheRubyPrefix(platform, version) rubyPrefix = common.getToolCacheRubyPrefix(platform, engine, version)
} }
} else { } else {
rubyPrefix = `${drive}:\\${base}` rubyPrefix = `${drive}:\\${base}`
@@ -103,10 +97,11 @@ async function installGCCTools(type, version) {
// 2022-Dec ruby/msys2-gcc-pkgs now uses a suffix to delineate different archive versions. // 2022-Dec ruby/msys2-gcc-pkgs now uses a suffix to delineate different archive versions.
// At present, the only use is to indicate the included OpenSSL version. // At present, the only use is to indicate the included OpenSSL version.
// With no suffix, archives include OpenSSL 1.1.1, with a '-3.0' suffix, they include // With no suffix, archives include OpenSSL 1.1.1, with a '-3.0' suffix, they include
// OpenSSL 3.0.x. // OpenSSL 3.0.x. Note that the mswin archive uses OpenSSL 3.
// Currently, OpenSSL 3 is used in Ruby 3.2 & 'head', both use a custom RubyInstaller2 package. // As of Jan-2023, OpenSSL 3 is used in Ruby 3.2 & all head versions. MSYS2 updated
// to OpenSSL 3 on 14-Jan-2023.
let suffix = '' let suffix = ''
if ((version === 'head') || (!common.isHeadVersion(version) && common.floatVersion(version) >= 3.2)) { if (common.isHeadVersion(version) || common.floatVersion(version) >= 3.2) {
suffix = '-3.0' suffix = '-3.0'
} }
const downloadPath = await common.measure(`Downloading ${type}${suffix} build tools`, async () => { const downloadPath = await common.measure(`Downloading ${type}${suffix} build tools`, async () => {
Generated
+10
View File
@@ -283,6 +283,11 @@ ip-regex@^2.1.0:
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9" resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9"
integrity sha512-58yWmlHpp7VYfcdTwMTvwMmqx/Elfxjd9RXTDyMsbL7lLWmhMylLEqiYVLKuLzOZqVgiWXD9MfR62Vv89VRxkw== integrity sha512-58yWmlHpp7VYfcdTwMTvwMmqx/Elfxjd9RXTDyMsbL7lLWmhMylLEqiYVLKuLzOZqVgiWXD9MfR62Vv89VRxkw==
linux-os-info@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/linux-os-info/-/linux-os-info-2.0.0.tgz#32a251077c13af1a69dbcb36a168901208e32776"
integrity sha512-ZopyH4kT2Ehnmix8iUgS/41pfv7fSlUV1JukIn3DB3qD3byvhBNtgCbUApoAtiqcHRLKXCY3zakXlJgiExm2Qg==
lru-cache@^6.0.0: lru-cache@^6.0.0:
version "6.0.0" version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
@@ -290,6 +295,11 @@ lru-cache@^6.0.0:
dependencies: dependencies:
yallist "^4.0.0" yallist "^4.0.0"
macos-release@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-3.1.0.tgz#6165bb0736ae567ed6649e36ce6a24d87cbb7aca"
integrity sha512-/M/R0gCDgM+Cv1IuBG1XGdfTFnMEG6PZeT+KGWHO/OG+imqmaD9CH5vHBTycEM3+Kc4uG2Il+tFAuUWLqQOeUA==
mime-db@1.52.0: mime-db@1.52.0:
version "1.52.0" version "1.52.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"