Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: resync fork #12

Merged
merged 28 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a6b46b8
Update CRuby releases on Windows
ruby-builder-bot Sep 5, 2024
6af8267
README.md - Windows - clarify installed packages, 2022 vs 2019
MSP-Greg Sep 16, 2024
f321cf5
Add truffleruby-24.1.0,truffleruby+graalvm-24.1.0
ruby-builder-bot Sep 17, 2024
0ec4904
Better error for TruffleRuby on Windows
eregon Sep 25, 2024
5496baa
Update macos-release to 3.3.0 so it recognizes macos-15
eregon Sep 25, 2024
17f5c91
Add support for macos-15 and all future macos runners
eregon Sep 25, 2024
c04af2b
Replace macos-release by (parseInt(os.version()) - 9)
eregon Sep 25, 2024
79c01b8
`README.md`: Mention link to supported Ruby versions for GitHub-hoste…
stdedos Oct 2, 2024
727fd4f
Update ruby-builder-versions.json
ioquatix Oct 3, 2024
aac0c64
Add `asan` as a head version of Ruby.
ioquatix Oct 3, 2024
27ceac8
Add asan to the test matrix.
ioquatix Oct 3, 2024
086ffb1
Update the `dist/index.js`.
ioquatix Oct 3, 2024
207a399
Move the link to the list together with other text about builds
eregon Oct 5, 2024
f6e0571
Update README.md
eregon Oct 5, 2024
784fcda
Add ruby-3.4.0-preview2
ruby-builder-bot Oct 7, 2024
f269373
Test the last 3.4 preview in CI
eregon Oct 7, 2024
bea2fb9
Add some details about using asan build.
ioquatix Oct 6, 2024
1d9686e
Mention the new ruby-asan under Supported Versions
eregon Oct 11, 2024
4d521ea
Fix exclusion
eregon Oct 11, 2024
7bae1d0
Add truffleruby-24.1.1,truffleruby+graalvm-24.1.1
ruby-builder-bot Oct 17, 2024
98aefb3
Add ruby-3.2.6
ruby-builder-bot Oct 30, 2024
7d3497f
Update CRuby releases on Windows
ruby-builder-bot Oct 31, 2024
8c27ea3
Add jruby-9.4.9.0
ruby-builder-bot Nov 5, 2024
c6d4d2a
Add ruby-3.3.6
ruby-builder-bot Nov 5, 2024
217c988
Skip `which bundle` test on mingw, mswin and ucrt
eregon Nov 5, 2024
46ca53b
Update CRuby releases on Windows
ruby-builder-bot Nov 7, 2024
a2bbe5b
Update CRuby releases on Windows
ruby-builder-bot Nov 9, 2024
993f449
*: merge upstream main into ruby
adityamaru Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading