Skip to content

Commit

Permalink
Merge pull request #12 from useblacksmith/bump-ruby
Browse files Browse the repository at this point in the history
*: resync fork
  • Loading branch information
adityamaru authored Nov 18, 2024
2 parents 75a665c + 993f449 commit 87fa4f5
Show file tree
Hide file tree
Showing 9 changed files with 66,748 additions and 53,152 deletions.
37 changes: 26 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, macos-13, macos-14, windows-2019, windows-2022 ]
os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, macos-13, macos-14, macos-15, 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', '3.3', ruby-head,
'1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', ruby-head,
jruby, jruby-head,
truffleruby, truffleruby-head,
truffleruby+graalvm, truffleruby+graalvm-head
Expand All @@ -30,31 +30,41 @@ jobs:
- { os: windows-2022, ruby: mingw }
- { os: windows-2022, ruby: mswin }
- { os: windows-2022, ruby: ucrt }
- { os: ubuntu-24.04, ruby: asan }
exclude:
# https://github.com/ruby/setup-ruby/issues/496
- { os: ubuntu-22.04, ruby: '2.2' }
- { os: ubuntu-24.04, ruby: '1.9' }
- { os: ubuntu-24.04, ruby: '2.2' }
# These old Rubies fail to compile on macos-14 (macOS 14, arm64), which is used for ruby/ruby-builder
# These old Rubies fail to compile on macOS arm64
- { os: macos-14, ruby: '1.9' }
- { os: macos-14, ruby: '2.0' }
- { os: macos-14, ruby: '2.1' }
- { os: macos-14, ruby: '2.2' }
- { os: macos-14, ruby: '2.3' }
- { os: macos-14, ruby: '2.4' }
- { os: macos-14, ruby: '2.5' }
# Windows
- { os: macos-15, ruby: '1.9' }
- { os: macos-15, ruby: '2.0' }
- { os: macos-15, ruby: '2.1' }
- { os: macos-15, ruby: '2.2' }
- { os: macos-15, ruby: '2.3' }
- { os: macos-15, ruby: '2.4' }
- { os: macos-15, ruby: '2.5' }
# Windows (note: previews are not available on Windows)
- { os: windows-2019, ruby: '1.9' }
- { os: windows-2019, ruby: debug }
- { os: windows-2019, ruby: truffleruby }
- { os: windows-2019, ruby: truffleruby-head }
- { os: windows-2019, ruby: truffleruby+graalvm }
- { os: windows-2019, ruby: truffleruby+graalvm-head }
- { os: windows-2022, ruby: '1.9' }
- { os: windows-2019, ruby: '3.4' } # 3.4.0-preview2
- { os: windows-2022, ruby: '3.4' } # 3.4.0-preview2
- { os: windows-2019, ruby: debug }
- { os: windows-2022, ruby: debug }
- { os: windows-2019, ruby: truffleruby }
- { os: windows-2022, ruby: truffleruby }
- { os: windows-2019, ruby: truffleruby-head }
- { os: windows-2022, ruby: truffleruby-head }
- { os: windows-2019, ruby: truffleruby+graalvm }
- { os: windows-2022, ruby: truffleruby+graalvm }
- { os: windows-2019, ruby: truffleruby+graalvm-head }
- { os: windows-2022, ruby: truffleruby+graalvm-head }

name: ${{ matrix.os }} ${{ matrix.ruby }}
Expand Down Expand Up @@ -133,9 +143,14 @@ jobs:
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/gem_from_github.gemfile

- name: which ruby, bundle
- name: which ruby
shell: bash
run: which -a ruby
- name: which bundle
shell: bash
run: which -a ruby bundle
run: which -a bundle
# https://github.com/ruby/setup-ruby/issues/658
if: "matrix.ruby != 'mingw' && matrix.ruby != 'mswin' && matrix.ruby != 'ucrt'"
- name: which rake
run: which -a rake
if: "!startsWith(matrix.os, 'windows')"
Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:

| Interpreter | Versions |
| ----------- | -------- |
| `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.4.0-preview1, head, debug, mingw, mswin, ucrt |
| `jruby` | 9.1.17.0 - 9.4.8.0, head |
| `truffleruby` | 19.3.0 - 24.0.2, head |
| `truffleruby+graalvm` | 21.2.0 - 24.0.2, head |
| `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.4.0-preview2, head, debug, mingw, mswin, ucrt |
| `jruby` | 9.1.17.0 - 9.4.9.0, head |
| `truffleruby` | 19.3.0 - 24.1.1, head |
| `truffleruby+graalvm` | 21.2.0 - 24.1.1, head |

`ruby-debug` is the same as `ruby-head` but with assertions enabled (`-DRUBY_DEBUG=1`).

`ruby-asan` is the same as `ruby-head` but with AddressSanitizer (ASan) enabled, helpful for finding memory issues in native extensions.
Native extensions are automatically compiled with AddressSanitizer when using `ruby-asan`.
`ruby-asan` is currently only available on `ubuntu-24.04`.

Regarding Windows ruby master builds, `mingw` is a MSYS2/MinGW build, `head` & `ucrt` are MSYS2/UCRT64
builds, and `mswin` is a MSVC/VS 2022 build.

Expand Down Expand Up @@ -51,10 +55,10 @@ and on Windows by [RubyInstaller2](https://github.com/oneclick/rubyinstaller2).
The `mingw`, `ucrt` and `mswin` builds are generated by [ruby-loco](https://github.com/MSP-Greg/ruby-loco).
`ruby-head` is generated by [ruby-dev-builder](https://github.com/ruby/ruby-dev-builder),
`jruby-head` is generated by [jruby-dev-builder](https://github.com/ruby/jruby-dev-builder),
`truffleruby-head` is generated by [truffleruby-dev-builder](https://github.com/ruby/truffleruby-dev-builder)
and `truffleruby+graalvm` is generated by [graalvm-ce-dev-builds](https://github.com/graalvm/graalvm-ce-dev-builds).
The full list of available Ruby versions can be seen in [ruby-builder-versions.json](ruby-builder-versions.json)
for Ubuntu and macOS and in [windows-versions.json](windows-versions.json) for Windows.
`truffleruby-head` and `truffleruby+graalvm-head` are generated by [truffleruby-dev-builder](https://github.com/ruby/truffleruby-dev-builder).
The full list of available Ruby versions can be seen in [ruby-builder-versions.json](ruby-builder-versions.json) for Ubuntu and macOS
(although some combinations are not available, see [the full list](https://github.com/ruby/ruby-builder/releases/tag/toolcache))
and in [windows-versions.json](windows-versions.json) for Windows.

## Usage

Expand Down Expand Up @@ -233,6 +237,7 @@ It is recommended to first get your build working on Ubuntu and macOS before try
* For Ruby < 2.4, the DevKit MSYS tools are installed and prepended to the `Path`.
* Use JRuby 9.2.20+ on Windows (older versions have [bugs](https://github.com/ruby/setup-ruby/issues/18#issuecomment-889072695)).
* JRuby on Windows has multiple issues ([jruby/jruby#7106](https://github.com/jruby/jruby/issues/7106), [jruby/jruby#7182](https://github.com/jruby/jruby/issues/7182)).
* When compiling extension code, note that the packages required to build Ruby are included when using Windows 2022, but that Windows 2019 does not include all of them, and may require installing package(s). This can be done with [setup-ruby-pkgs](https://github.com/ruby/setup-ruby-pkgs) or via MSYS2's pacman. These packages may be required when installing or updating Ruby std-lib extension gems.

## Versioning

Expand Down
92 changes: 61 additions & 31 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const core = require('@actions/core')
const tc = require('@actions/tool-cache')
const { performance } = require('perf_hooks')
const linuxOSInfo = require('linux-os-info')
import macosRelease from 'macos-release'

export const windows = (os.platform() === 'win32')
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
Expand Down Expand Up @@ -67,7 +66,7 @@ export async function time(name, block) {
}

export function isHeadVersion(rubyVersion) {
return ['head', 'debug', 'mingw', 'mswin', 'ucrt'].includes(rubyVersion)
return ['head', 'debug', 'mingw', 'mswin', 'ucrt', 'asan'].includes(rubyVersion)
}

export function isStableVersion(engine, rubyVersion) {
Expand Down Expand Up @@ -162,73 +161,105 @@ export async function hashFile(file) {
return hash.digest('hex')
}

// macos is not listed explicitly, see below
const GitHubHostedPlatforms = [
'ubuntu-20.04-x64',
'ubuntu-22.04-x64',
'ubuntu-24.04-x64',
'macos-12-x64',
'macos-13-x64',
'macos-13-arm64',
'macos-14-x64',
'macos-14-arm64',
'windows-2019-x64',
'windows-2022-x64',
]

// Precisely: whether we have builds for that platform and there are GitHub-hosted runners to test it
function isSupportedPlatform() {
const platform = getOSName()
switch (platform) {
case 'ubuntu':
return GitHubHostedPlatforms.includes(getOSNameVersionArch())
case 'macos':
// See https://github.com/ruby/ruby-builder/blob/master/README.md#naming
// 13 on arm64 because of old macos-arm-oss runners
return (os.arch() === 'x64' && parseInt(getOSVersion()) >= 12) ||
(os.arch() === 'arm64' && parseInt(getOSVersion()) >= 13)
case 'windows':
return GitHubHostedPlatforms.includes(getOSNameVersionArch())
}
}

// Actually a self-hosted runner for which the OS and OS version does not correspond to a GitHub-hosted runner image,
export function isSelfHostedRunner() {
if (inputs.selfHosted === undefined) {
throw new Error('inputs.selfHosted should have been already set')
}

return inputs.selfHosted === 'true' ||
!GitHubHostedPlatforms.includes(getOSNameVersionArch())
return inputs.selfHosted === 'true' || !isSupportedPlatform()
}

export function selfHostedRunnerReason() {
if (inputs.selfHosted === 'true') {
return 'the self-hosted input was set'
} else if (!GitHubHostedPlatforms.includes(getOSNameVersionArch())) {
} else if (!isSupportedPlatform()) {
return 'the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported)'
} else {
return 'unknown reason'
}
}

let osNameVersion = undefined
let osName = undefined
let osVersion = undefined

export function getOSNameVersion() {
if (osNameVersion !== undefined) {
return osNameVersion
export function getOSName() {
if (osName !== undefined) {
return osName
}

const platform = os.platform()
let osName
let osVersion
if (platform === 'linux') {
const info = linuxOSInfo({mode: 'sync'})
osName = info.id
osVersion = info.version_id
} else if (platform === 'darwin') {
osName = 'macos'
osVersion = macosRelease().version
} else if (platform === 'win32') {
osName = 'windows'
} else {
throw new Error(`Unknown platform ${platform}`)
}

return osName
}

export function getOSVersion() {
if (osVersion !== undefined) {
return osVersion
}

const platform = os.platform()
if (platform === 'linux') {
const info = linuxOSInfo({mode: 'sync'})
osVersion = info.version_id
} else if (platform === 'darwin') {
// See https://github.com/sindresorhus/macos-release/blob/main/index.js
const darwinVersion = parseInt(os.release().match(/^\d+/)[0])
osVersion = `${darwinVersion - 9}`
} else if (platform === 'win32') {
osVersion = findWindowsVersion()
} else {
throw new Error(`Unknown platform ${platform}`)
}

osNameVersion = `${osName}-${osVersion}`
return osNameVersion
return osVersion
}

export function getOSNameVersion() {
return `${getOSName()}-${getOSVersion()}`
}

export function getOSNameVersionArch() {
return `${getOSNameVersion()}-${os.arch()}`
return `${getOSName()}-${getOSVersion()}-${os.arch()}`
}

function findWindowsVersion() {
const version = os.version();
const version = os.version()
const match = version.match(/^Windows Server (\d+) Datacenter/)
if (match) {
return match[1]
Expand Down Expand Up @@ -261,15 +292,14 @@ export function getRunnerToolCache() {

// Rubies prebuilt by this action embed this path rather than using $RUNNER_TOOL_CACHE
function getDefaultToolCachePath() {
const platform = getOSNameVersion()
if (platform.startsWith('ubuntu-')) {
return '/opt/hostedtoolcache'
} else if (platform.startsWith('macos-')) {
return '/Users/runner/hostedtoolcache'
} else if (platform.startsWith('windows-')) {
return 'C:\\hostedtoolcache\\windows'
} else {
throw new Error('Unknown platform')
const platform = getOSName()
switch (platform) {
case 'ubuntu':
return '/opt/hostedtoolcache'
case 'macos':
return '/Users/runner/hostedtoolcache'
case 'windows':
return 'C:\\hostedtoolcache\\windows'
}
}

Expand Down
Loading

0 comments on commit 87fa4f5

Please sign in to comment.