Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6825c76
Clarify
eregon Nov 21, 2024
2e3487c
No more macos-12 runners, minimum for macos-amd64 is now macos-13
eregon Dec 6, 2024
2a18b06
Require macos-13+ for macos-amd64 as builds from now on will be on 13…
eregon Dec 6, 2024
401c19e
Add ruby-3.4.0-rc1
ruby-builder-bot Dec 13, 2024
540484a
Fixes the latest rubygems installation error with Ruby 3.0
Watson1978 Dec 19, 2024
bfefad8
Add ruby-3.4.0,ruby-3.4.1
ruby-builder-bot Dec 26, 2024
4a9ddd6
Update CRuby releases on Windows
ruby-builder-bot Dec 30, 2024
868b3f0
Add ruby-3.3.7
ruby-builder-bot Jan 15, 2025
8e51ba9
Upgrade @actions/cache to 4.0.0
Link- Jan 16, 2025
7a63021
Workaround missing require 'logger' in Rails
eregon Jan 16, 2025
1d54274
yarn.lock - Remove @actions/core 1.10.1, use @actions/core 1.11.1
MSP-Greg Jan 17, 2025
fd2daea
common.js - add windows-2025
MSP-Greg Jan 17, 2025
87b4893
test.yml -add windows-2025
MSP-Greg Jan 16, 2025
f72249c
Update CRuby releases on Windows
ruby-builder-bot Jan 18, 2025
fbaef13
Add support for ubuntu-22.04-arm64 and ubuntu-24.04-arm64
eregon Jan 18, 2025
28c4ded
ubuntu-22.04-arm64 and ubuntu-24.04-arm64 support is complete
eregon Jan 18, 2025
84b14e9
Add jruby-9.4.10.0
ruby-builder-bot Jan 22, 2025
1287d2b
Add truffleruby-24.1.2,truffleruby+graalvm-24.1.2
ruby-builder-bot Jan 27, 2025
2654679
Add jruby-9.4.11.0
ruby-builder-bot Jan 30, 2025
8388f20
Add ruby-3.2.7
ruby-builder-bot Feb 4, 2025
ef45abe
Add support for mise.toml (#700)
hobbypunk90 Feb 5, 2025
8711a86
Shorten to avoid horizontal scrolling
eregon Feb 5, 2025
d781c1b
Update CRuby releases on Windows
ruby-builder-bot Feb 5, 2025
5547c87
Add jruby-9.4.12.0
ruby-builder-bot Feb 12, 2025
f2f42b7
Skip test failing on JRuby on Windows
eregon Feb 12, 2025
28d088d
Add ruby-3.4.2
ruby-builder-bot Feb 15, 2025
32110d4
Update CRuby releases on Windows
ruby-builder-bot Feb 15, 2025
3ad45c5
Improve script for listing versions
eregon Feb 22, 2025
88a8155
Make targetRubyVersion() more complete
eregon Feb 22, 2025
04c2e2b
Expose `3.4-asan` Ruby builds from ruby-dev-builder
ivoanjo Feb 18, 2025
277ba2a
deal with multiple versions in .tool-versions
jtannas Mar 4, 2025
28233a0
bugfix: Fix bug that version cannot be parsed in .tool-versions
Karibash Mar 11, 2025
30755d8
Cleanup matching for .tool-versions and mise and add tests for .ruby-…
eregon Mar 11, 2025
bbda858
Fix .tool-versions and mise.toml tests
eregon Mar 11, 2025
f0a4d6b
Switch JAVA_HOME to 21 for JRuby (#721)
headius Mar 12, 2025
e17c5ea
Handle exec error
headius Mar 13, 2025
6c79f72
Test successful JRuby start without using launcher
headius Mar 13, 2025
922ebc4
Use $JAVA_HOME/bin/java for the check
eregon Mar 15, 2025
1a61595
Add truffleruby-24.2.0,truffleruby+graalvm-24.2.0
ruby-builder-bot Mar 18, 2025
1b2d033
Merge branch 'master' of github.com:ruby/setup-ruby into ruby-master
prajjwaldimri Mar 21, 2025
1efdd43
fixes lock and dist
prajjwaldimri Mar 21, 2025
2956273
Merge branch 'ruby-master' into upstream-sync
prajjwaldimri Mar 21, 2025
129cc29
updates version
prajjwaldimri Mar 21, 2025
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
59 changes: 53 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, macos-13, macos-14, macos-15, windows-2019, windows-2022 ]
os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, ubuntu-22.04-arm, ubuntu-24.04-arm, macos-13, macos-14, macos-15, windows-2019, windows-2022, windows-2025 ]
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', '3.4', ruby-head,
jruby, jruby-head,
Expand All @@ -30,7 +30,11 @@ jobs:
- { os: windows-2022, ruby: mingw }
- { os: windows-2022, ruby: mswin }
- { os: windows-2022, ruby: ucrt }
- { os: windows-2025, ruby: mingw }
- { os: windows-2025, ruby: mswin }
- { os: windows-2025, ruby: ucrt }
- { os: ubuntu-24.04, ruby: asan }
- { os: ubuntu-24.04, ruby: 3.4-asan }
exclude:
# https://github.com/ruby/setup-ruby/issues/496
- { os: ubuntu-22.04, ruby: '2.2' }
Expand All @@ -51,21 +55,34 @@ jobs:
- { os: macos-15, ruby: '2.3' }
- { os: macos-15, ruby: '2.4' }
- { os: macos-15, ruby: '2.5' }
# These old Rubies fail to compile or segfault on Linux arm64
- { os: ubuntu-22.04-arm, ruby: '1.9' }
- { os: ubuntu-22.04-arm, ruby: '2.0' }
- { os: ubuntu-22.04-arm, ruby: '2.1' }
- { os: ubuntu-22.04-arm, ruby: '2.2' }
- { os: ubuntu-24.04-arm, ruby: '1.9' }
- { os: ubuntu-24.04-arm, ruby: '2.0' }
- { os: ubuntu-24.04-arm, ruby: '2.1' }
- { os: ubuntu-24.04-arm, ruby: '2.2' }
# Windows (note: previews are not available on Windows)
- { os: windows-2019, ruby: '1.9' }
- { 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-2025, ruby: '1.9' }
- { os: windows-2019, ruby: debug }
- { os: windows-2022, ruby: debug }
- { os: windows-2025, ruby: debug }
- { os: windows-2019, ruby: truffleruby }
- { os: windows-2022, ruby: truffleruby }
- { os: windows-2025, ruby: truffleruby }
- { os: windows-2019, ruby: truffleruby-head }
- { os: windows-2022, ruby: truffleruby-head }
- { os: windows-2025, ruby: truffleruby-head }
- { os: windows-2019, ruby: truffleruby+graalvm }
- { os: windows-2022, ruby: truffleruby+graalvm }
- { os: windows-2025, ruby: truffleruby+graalvm }
- { os: windows-2019, ruby: truffleruby+graalvm-head }
- { os: windows-2022, ruby: truffleruby+graalvm-head }
- { os: windows-2025, ruby: truffleruby+graalvm-head }

name: ${{ matrix.os }} ${{ matrix.ruby }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -169,9 +186,37 @@ jobs:
shell: bash
run: echo ~ && bundle install
- name: Windows JRuby
if: startsWith(matrix.os, 'windows') && startsWith(matrix.ruby, 'jruby')
# Should be startsWith(matrix.ruby, 'jruby') but broken on jruby-head: https://github.com/jruby/jruby/issues/8623
if: startsWith(matrix.os, 'windows') && matrix.ruby == 'jruby'
run: gem install sassc

testDotRubyVersion:
name: "Test .ruby-version"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "ruby-3.4.0" > .ruby-version
- uses: ./
- run: ruby -v | grep -F "ruby 3.4.0"

testToolVersions:
name: "Test .tool-versions"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo -e "nodejs 16.0.0\nruby 3.4.0" > .tool-versions
- uses: ./
- run: ruby -v | grep -F "ruby 3.4.0"

testMise:
name: "Test mise.toml"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo -e "[tools]\nnode = '18'\nruby = '3.4.0'" > mise.toml
- uses: ./
- run: ruby -v | grep -F "ruby 3.4.0"

testNoGemfile:
name: "Test with no Gemfile"
runs-on: ubuntu-latest
Expand All @@ -190,8 +235,8 @@ jobs:
fail-fast: false
matrix:
include:
- { ruby: '3.2', expected_rubygems_version: '3.5.3' }
- { ruby: '3.0', expected_rubygems_version: '3.5.3' }
- { ruby: '3.2', expected_rubygems_version: '3.6.1' }
- { ruby: '3.0', expected_rubygems_version: '3.5.23' }
- { ruby: '2.7', expected_rubygems_version: '3.4.22' }
- { ruby: '2.6', expected_rubygems_version: '3.4.22' }
- { ruby: '2.5', expected_rubygems_version: '3.3.27' }
Expand Down Expand Up @@ -336,6 +381,8 @@ jobs:
ruby-version: '2.6'
bundler-cache: true
- run: bundle exec rails --version
env:
RUBYOPT: '-rlogger' # Rails 6 is missing a require 'logger' in active_support/logger_thread_safe_level.rb

testTruffleRubyNokogiri:
name: "Test installing a Gemfile with nokogiri on TruffleRuby"
Expand Down
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ 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-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` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.4.2, head, debug, mingw, mswin, ucrt |
| `jruby` | 9.1.17.0 - 9.4.12.0, head |
| `truffleruby` | 19.3.0 - 24.2.0, head |
| `truffleruby+graalvm` | 21.2.0 - 24.2.0, 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`.

`ruby-3.4-asan` is similar to `ruby-asan` but built from the latest stable 3.4 release tag.
Like `ruby-asan`, it's 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 All @@ -46,8 +49,8 @@ The action works on these [GitHub-hosted runners](https://docs.github.com/en/act

| Operating System | Supported |
| ---------------- | --------- |
| Ubuntu | `ubuntu-20.04`, `ubuntu-22.04`, `ubuntu-24.04` |
| macOS | `macos-12+` |
| Ubuntu | `ubuntu-20.04`, `ubuntu-22.04`, `ubuntu-24.04`, `ubuntu-22.04-arm`, `ubuntu-24.04-arm` |
| macOS | `macos-13` and newer versions |
| Windows | `windows-2019`, `windows-2022` |

The prebuilt releases are generated by [ruby-builder](https://github.com/ruby/ruby-builder)
Expand All @@ -74,7 +77,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3' # Not needed with a `.ruby-version` or `.tool-versions`
ruby-version: '3.3' # Not needed with a .ruby-version, .tool-versions or mise.toml
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: bundle exec rake
```
Expand Down Expand Up @@ -139,11 +142,12 @@ and the [condition and expression syntax](https://help.github.com/en/actions/ref
* engine only like `ruby` and `truffleruby`, uses the latest stable release of that implementation
* `.ruby-version` reads from the project's `.ruby-version` file
* `.tool-versions` reads from the project's `.tool-versions` file
* If the `ruby-version` input is not specified, `.ruby-version` is tried first, followed by `.tool-versions`
* `mise.toml` reads from the project's `mise.toml` file
* If the `ruby-version` input is not specified, `.ruby-version` is tried first, followed by `.tool-versions`, followed by `mise.toml`

### Working Directory

The `working-directory` input can be set to resolve `.ruby-version`, `.tool-versions` and `Gemfile.lock`
The `working-directory` input can be set to resolve `.ruby-version`, `.tool-versions`, `mise.toml` and `Gemfile.lock`
if they are not at the root of the repository, see [action.yml](action.yml) for details.

### RubyGems
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ branding:
icon: download
inputs:
ruby-version:
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version or .tool-versions if unset.'
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version, .tool-versions or mise.toml if unset.'
default: 'default'
rubygems:
description: |
Expand All @@ -26,7 +26,7 @@ inputs:
description: 'Run "bundle install", and cache the result automatically. Either true or false.'
default: 'false'
working-directory:
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions and Gemfile.lock.'
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions, mise.toml and Gemfile.lock.'
cache-version:
description: |
Arbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need
Expand Down
47 changes: 45 additions & 2 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const stream = require('stream')
const crypto = require('crypto')
const core = require('@actions/core')
const tc = require('@actions/tool-cache')
const exec = require('@actions/exec')
const { performance } = require('perf_hooks')
const linuxOSInfo = require('linux-os-info')

Expand Down Expand Up @@ -66,7 +67,8 @@ export async function time(name, block) {
}

export function isHeadVersion(rubyVersion) {
return ['head', 'debug', 'mingw', 'mswin', 'ucrt', 'asan'].includes(rubyVersion)
// 3.4-asan counts as "head" because the version cannot be selected -- you can only get whatever's latest
return ['head', 'debug', 'mingw', 'mswin', 'ucrt', 'asan', '3.4-asan'].includes(rubyVersion)
}

export function isStableVersion(engine, rubyVersion) {
Expand Down Expand Up @@ -128,6 +130,8 @@ export function targetRubyVersion(engine, rubyVersion) {
return 2.5
} else if (version === 9.3) {
return 2.6
} else if (version === 9.4) {
return 3.1
}
} else if (engine.startsWith('truffleruby')) {
if (version < 21.0) {
Expand All @@ -136,6 +140,10 @@ export function targetRubyVersion(engine, rubyVersion) {
return 2.7
} else if (version < 23.0) {
return 3.0
} else if (version < 23.1) {
return 3.1
} else if (version < 24.2) {
return 3.2
}
}

Expand Down Expand Up @@ -165,9 +173,12 @@ export async function hashFile(file) {
const GitHubHostedPlatforms = [
'ubuntu-20.04-x64',
'ubuntu-22.04-x64',
'ubuntu-22.04-arm64',
'ubuntu-24.04-x64',
'ubuntu-24.04-arm64',
'windows-2019-x64',
'windows-2022-x64',
'windows-2025-x64',
]

// Precisely: whether we have builds for that platform and there are GitHub-hosted runners to test it
Expand All @@ -179,7 +190,7 @@ function isSupportedPlatform() {
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) ||
return (os.arch() === 'x64' && parseInt(getOSVersion()) >= 13) ||
(os.arch() === 'arm64' && parseInt(getOSVersion()) >= 13)
case 'windows':
return GitHubHostedPlatforms.includes(getOSNameVersionArch())
Expand Down Expand Up @@ -393,3 +404,35 @@ export function setupPath(newPathEntries) {
core.addPath(newPath.join(path.delimiter))
return msys2Type
}

export async function setupJavaHome(rubyPrefix) {
await measure("Modifying JAVA_HOME for JRuby", async () => {
console.log("attempting to run with existing JAVA_HOME")

const javaHome = process.env['JAVA_HOME']
let java = javaHome ? path.join(javaHome, 'bin/java') : 'java'
let ret = await exec.exec(java, ['-jar', path.join(rubyPrefix, 'lib/jruby.jar'), '--version'], {ignoreReturnCode: true})

if (ret === 0) {
console.log("JRuby successfully starts, using existing JAVA_HOME")
} else {
console.log("JRuby failed to start, try Java 21 envs")

let arch = os.arch()
if (arch === "x64" || os.platform() !== "darwin") {
arch = "X64"
}

let newHomeVar = `JAVA_HOME_21_${arch}`
let newHome = process.env[newHomeVar]

if (newHome === "undefined") {
throw new Error(`JAVA_HOME is not Java 21+ needed for JRuby and \$${newHomeVar} is not defined`)
}

console.log(`Setting JAVA_HOME to ${newHomeVar} path ${newHome}`)

core.exportVariable("JAVA_HOME", newHome)
}
})
}
Loading
Loading