Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bc1d550
Update testFixedBundlerVersionForOldRuby to 2.3 since 2.2 is known to…
eregon Apr 24, 2025
7200295
Update to Rails 7.2 and 8 in tests
eregon Apr 24, 2025
2e00740
Remove support for ubuntu-20.04
eregon Apr 24, 2025
dffc446
Support windows-11-arm
ntkme Apr 18, 2025
e69d1ea
Update README example
eregon Apr 26, 2025
afda160
Improve exclude reasons
eregon Apr 26, 2025
f41e084
Add truffleruby-24.2.1,truffleruby+graalvm-24.2.1
ruby-builder-bot Apr 30, 2025
eaecf78
Handle win2019 gcc issue
MSP-Greg Apr 30, 2025
e34163c
Add jruby-9.4.12.1,jruby-10.0.0.1
ruby-builder-bot May 7, 2025
84684c0
Add ruby-3.4.4
ruby-builder-bot May 14, 2025
a871308
Rewrite ruby/setup-msys2-gcc
ntkme May 3, 2025
2f55240
Apply review feedbacks
ntkme May 15, 2025
1a0ff44
Switch to ruby/setup-msys2-gcc
ntkme May 15, 2025
bb0f760
Fix a regression where MAKE on windows has an extra space at the end
ntkme May 16, 2025
cb0fda5
Update CRuby releases on Windows
ruby-builder-bot May 18, 2025
c95ae37
Upgrade @actions/cache
JoeDupuis May 18, 2025
308b219
package.json - update @actions/io, semver, ncc
MSP-Greg May 20, 2025
2deba9e
yarn.lock update
MSP-Greg May 20, 2025
13e7a03
run `yarn run package`
MSP-Greg May 20, 2025
a4effe4
Add jruby-9.4.13.0
ruby-builder-bot Jun 11, 2025
e851ebd
Remove unused platform args from computeBaseKey
wt-l00 Jun 20, 2025
d4ef88e
Add ruby-3.4.5
ruby-builder-bot Jul 15, 2025
a4f8389
Remove windows-2019 support
eregon Jul 15, 2025
a0d0824
Add workaround for Ruby 3.1 after RubyGems 3.7.0 release
deivid-rodriguez Jul 16, 2025
f66e112
Don't use `--force` flag on Windows
deivid-rodriguez Jul 16, 2025
4727905
Try also removing the other case where `--force` is used
deivid-rodriguez Jul 16, 2025
a9bfc2e
Add jruby-10.0.1.0
ruby-builder-bot Jul 18, 2025
6593790
Add ruby-3.2.9,ruby-3.3.9
ruby-builder-bot Jul 24, 2025
223e443
Update CRuby releases on Windows
ruby-builder-bot Jul 25, 2025
bd6859c
Use core.group() instead of startGroup/endGroup
eregon Jul 25, 2025
e8621f0
Add printing of the lockfile after installation
Fryguy Jul 24, 2025
0ecad18
Revert "Add printing of the lockfile after installation"
eregon Jul 25, 2025
ba9e71c
Add printing of the lockfile after installation
Fryguy Jul 24, 2025
bb6434c
Add non-null check
eregon Jul 26, 2025
45dc484
Bump form-data from 2.5.3 to 2.5.5
dependabot[bot] Jul 22, 2025
3ec1ec0
Bump brace-expansion from 1.1.11 to 1.1.12
dependabot[bot] Jul 15, 2025
78876b7
Use case-insensitive key comparsion for cache keys
BytewaveMLP Oct 21, 2024
2a7b300
Rename to `isExactCacheKeyMatch`
BytewaveMLP Oct 21, 2024
595828d
Update ruby version in `README.md`
fkmy Aug 5, 2025
2973a4b
Merge pull request #794 from fkmy/update-readme
hsbt Aug 6, 2025
76da337
Update GitHub-hosted runners link
eregon Aug 6, 2025
f4b5b3a
Merge branch 'master' of github.com:ruby/setup-ruby into ruby-master
prajjwaldimri Aug 8, 2025
6219a56
commits index
prajjwaldimri Aug 8, 2025
0e27c42
Merge branch 'master' into ruby-master
prajjwaldimri Aug 8, 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
58 changes: 40 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ 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 ]
os: [ ubuntu-22.04, ubuntu-24.04, ubuntu-22.04-arm, ubuntu-24.04-arm, macos-13, macos-14, macos-15, windows-2022, windows-2025, windows-11-arm ]
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,
truffleruby, truffleruby-head,
truffleruby+graalvm, truffleruby+graalvm-head
]
include:
- { os: windows-2019, ruby: mingw }
- { os: windows-2019, ruby: mswin }
- { os: windows-2022, ruby: mingw }
- { os: windows-2022, ruby: mswin }
- { os: windows-2022, ruby: ucrt }
Expand Down Expand Up @@ -64,25 +62,39 @@ jobs:
- { 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' }
# RubyInstaller windows-arm64 builds only exist for Ruby 3.4+
- { os: windows-11-arm, ruby: '2.0' }
- { os: windows-11-arm, ruby: '2.1' }
- { os: windows-11-arm, ruby: '2.2' }
- { os: windows-11-arm, ruby: '2.3' }
- { os: windows-11-arm, ruby: '2.4' }
- { os: windows-11-arm, ruby: '2.5' }
- { os: windows-11-arm, ruby: '2.6' }
- { os: windows-11-arm, ruby: '2.7' }
- { os: windows-11-arm, ruby: '3.0' }
- { os: windows-11-arm, ruby: '3.1' }
- { os: windows-11-arm, ruby: '3.2' }
- { os: windows-11-arm, ruby: '3.3' }
# https://github.com/ruby/jruby-dev-builder/pull/14#issuecomment-2829841247
- { os: windows-11-arm, ruby: jruby }
- { os: windows-11-arm, ruby: jruby-head }
# RubyInstaller has no 64-bit builds of 1.9 on Windows
- { os: windows-2022, ruby: '1.9' }
- { 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-11-arm, ruby: '1.9' }
# TruffleRuby does not support Windows
- { os: windows-2022, ruby: truffleruby }
- { os: windows-2025, ruby: truffleruby }
- { os: windows-2019, ruby: truffleruby-head }
- { os: windows-11-arm, ruby: truffleruby }
- { os: windows-2022, ruby: truffleruby-head }
- { os: windows-2025, ruby: truffleruby-head }
- { os: windows-2019, ruby: truffleruby+graalvm }
- { os: windows-11-arm, ruby: truffleruby-head }
- { os: windows-2022, ruby: truffleruby+graalvm }
- { os: windows-2025, ruby: truffleruby+graalvm }
- { os: windows-2019, ruby: truffleruby+graalvm-head }
- { os: windows-11-arm, ruby: truffleruby+graalvm }
- { os: windows-2022, ruby: truffleruby+graalvm-head }
- { os: windows-2025, ruby: truffleruby+graalvm-head }
- { os: windows-11-arm, ruby: truffleruby+graalvm-head }

name: ${{ matrix.os }} ${{ matrix.ruby }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -115,7 +127,7 @@ jobs:
echo 'ridk is unavailable'
}
} elseif ($plat.Contains('mswin')) {
&"$env:VCPKG_INSTALLATION_ROOT\vcpkg" list
Get-ChildItem "$env:VCPKG_INSTALLATION_ROOT\installed\vcpkg\info"
}
- name: RbConfig::CONFIG
run: ruby -rrbconfig -rpp -e 'pp RbConfig::CONFIG'
Expand Down Expand Up @@ -228,6 +240,18 @@ jobs:
ruby-version: '2.6'
- run: ruby -v

testNoGemfileWithBundlerCache:
name: "Test with no Gemfile but with bundler-cache"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rm Gemfile
- uses: ./
with:
ruby-version: '2.6'
bundler-cache: true
- run: ruby -v

testLatestRubygemsVersion:
name: "Test rubygems: latest on ${{ matrix.ruby }}"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -291,7 +315,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./
with:
ruby-version: '2.2'
ruby-version: '2.3'
bundler: 1.16.6
- run: bundle --version | grep -F "1.16.6" # And not 1.17.x from ~> 1

Expand Down Expand Up @@ -369,7 +393,7 @@ jobs:
strategy:
fail-fast: false
matrix:
gemfile: [ rails5, rails6 ]
gemfile: [ rails7, rails8 ]
name: "Test with ${{ matrix.gemfile }} gemfile"
runs-on: ubuntu-latest
env:
Expand All @@ -378,11 +402,9 @@ jobs:
- uses: actions/checkout@v4
- uses: ./
with:
ruby-version: '2.6'
ruby-version: '3.2'
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: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ 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.5.0-preview1, head, debug, mingw, mswin, ucrt |
| `jruby` | 9.1.17.0 - 10.0.0.0, head |
| `truffleruby` | 19.3.0 - 24.2.0, head |
| `truffleruby+graalvm` | 21.2.0 - 24.2.0, head |
| `jruby` | 9.1.17.0 - 10.0.1.0, head |
| `truffleruby` | 19.3.0 - 24.2.1, head |
| `truffleruby+graalvm` | 21.2.0 - 24.2.1, head |

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

Expand All @@ -45,13 +45,13 @@ which means Ruby ≤ 2.4 is unmaintained and considered insecure.

### Supported Platforms

The action works on these [GitHub-hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources) images. Runner images not listed below are not supported yet. `$OS-latest` just alias to one of these images.
The action works on these [GitHub-hosted runners](https://docs.github.com/en/actions/reference/runners/github-hosted-runners) images. Runner images not listed below are not supported yet. `$OS-latest` just alias to one of these images.

| Operating System | Supported |
| ---------------- | --------- |
| Ubuntu | `ubuntu-20.04`, `ubuntu-22.04`, `ubuntu-24.04`, `ubuntu-22.04-arm`, `ubuntu-24.04-arm` |
| Ubuntu | `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` |
| Windows | `windows-2022`, `windows-2025`, `windows-11-arm` |

Not all combinations of runner images and versions are supported.
The list of available Ruby versions can be seen in [ruby-builder-versions.json](ruby-builder-versions.json) for Ubuntu and macOS
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3' # Not needed with a .ruby-version, .tool-versions or mise.toml
ruby-version: '3.4' # 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 All @@ -98,7 +98,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', head, jruby, jruby-head, truffleruby, truffleruby-head]
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', head, jruby, jruby-head, truffleruby, truffleruby-head]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -119,15 +119,15 @@ jobs:
strategy:
fail-fast: false
matrix:
gemfile: [ rails5, rails6 ]
gemfile: [ rails7, rails8 ]
runs-on: ubuntu-latest
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
ruby-version: '3.4'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: bundle exec rake
```
Expand Down Expand Up @@ -243,7 +243,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.
* When compiling extension code, note that the packages required to build Ruby are included when using Windows 2022. Additional packages can be installed 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 stdlib extension gems.

## Versioning

Expand Down
11 changes: 4 additions & 7 deletions bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,11 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
}

const gem = path.join(rubyPrefix, 'bin', 'gem')
// Workaround for https://github.com/rubygems/rubygems/issues/5245
// and for https://github.com/oracle/truffleruby/issues/2780
const force = ((platform.startsWith('windows-') && engine === 'ruby' && floatVersion >= 3.1) || (engine === 'truffleruby')) ? ['--force'] : []

const versionParts = [...bundlerVersion.matchAll(/\d+/g)].length
const bundlerVersionConstraint = versionParts >= 3 ? bundlerVersion : `~> ${bundlerVersion}.0`

await exec.exec(gem, ['install', 'bundler', ...force, '-v', bundlerVersionConstraint])
await exec.exec(gem, ['install', 'bundler', '-v', bundlerVersionConstraint])

return bundlerVersion
}
Expand Down Expand Up @@ -182,7 +179,7 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer

// cache key
const paths = [cachePath]
const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile, cacheVersion)
const baseKey = await computeBaseKey(engine, rubyVersion, lockFile, cacheVersion)
const key = `${baseKey}-${await common.hashFile(lockFile)}`
// If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below
const restoreKeys = [`${baseKey}-`]
Expand All @@ -209,7 +206,7 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
await exec.exec('bundle', ['install', '--jobs', '4'])

// @actions/cache only allows to save for non-existing keys
if (cachedKey !== key) {
if (!common.isExactCacheKeyMatch(key, cachedKey)) {
if (cachedKey) { // existing cache but Gemfile.lock differs, clean old gems
await exec.exec('bundle', ['clean'])
}
Expand All @@ -232,7 +229,7 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
return true
}

async function computeBaseKey(platform, engine, version, lockFile, cacheVersion) {
async function computeBaseKey(engine, version, lockFile, cacheVersion) {
const cwd = process.cwd()
const bundleWith = process.env['BUNDLE_WITH'] || ''
const bundleWithout = process.env['BUNDLE_WITHOUT'] || ''
Expand Down
74 changes: 31 additions & 43 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const linuxOSInfo = require('linux-os-info')

export const windows = (os.platform() === 'win32')
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
export const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined)
export const drive = (windows ? (process.env['RUNNER_TEMP'] || 'C')[0] : undefined)

export const inputs = {
selfHosted: undefined
Expand Down Expand Up @@ -171,14 +171,13 @@ export async function hashFile(file) {

// macos is not listed explicitly, see below
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',
'windows-11-arm64'
]

// Precisely: whether we have builds for that platform and there are GitHub-hosted runners to test it
Expand Down Expand Up @@ -271,7 +270,7 @@ export function getOSNameVersionArch() {

function findWindowsVersion() {
const version = os.version()
const match = version.match(/^Windows Server (\d+) Datacenter/)
const match = version.match(/^Windows(?: Server)? (\d+) (?:Datacenter|Enterprise)/)
if (match) {
return match[1]
} else {
Expand Down Expand Up @@ -334,7 +333,7 @@ function engineToToolCacheName(engine) {
}[engine]
}

export function getToolCacheRubyPrefix(platform, engine, version) {
export function getToolCacheRubyPrefix(_platform, engine, version) {
const toolCache = getToolCachePath()
return path.join(toolCache, engineToToolCacheName(engine), version, os.arch())
}
Expand All @@ -356,53 +355,30 @@ export function win2nix(path) {
return path.replace(/\\/g, '/').replace(/ /g, '\\ ')
}

// JRuby is installed after setupPath is called, so folder doesn't exist
function rubyIsUCRT(path) {
return !!(fs.existsSync(path) &&
fs.readdirSync(path, { withFileTypes: true }).find(dirent =>
dirent.isFile() && dirent.name.match(/^x64-(ucrt|vcruntime\d{3})-ruby\d{3}\.dll$/)))
}

export function setupPath(newPathEntries) {
let msys2Type = null
const envPath = windows ? 'Path' : 'PATH'
const originalPath = process.env[envPath].split(path.delimiter)
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))

core.startGroup(`Modifying ${envPath}`)

// First remove the conflicting path entries
if (cleanPath.length !== originalPath.length) {
console.log(`Entries removed from ${envPath} to avoid conflicts with default Ruby:`)
for (const entry of originalPath) {
if (!cleanPath.includes(entry)) {
console.log(` ${entry}`)
core.group(`Modifying ${envPath}`, async () => {
// First remove the conflicting path entries
if (cleanPath.length !== originalPath.length) {
console.log(`Entries removed from ${envPath} to avoid conflicts with default Ruby:`)
for (const entry of originalPath) {
if (!cleanPath.includes(entry)) {
console.log(` ${entry}`)
}
}
core.exportVariable(envPath, cleanPath.join(path.delimiter))
}
core.exportVariable(envPath, cleanPath.join(path.delimiter))
}

// Then add new path entries using core.addPath()
let newPath
const windowsToolchain = core.getInput('windows-toolchain')
if (windows && windowsToolchain !== 'none') {
// main Ruby dll determines whether mingw or ucrt build
msys2Type = rubyIsUCRT(newPathEntries[0]) ? 'ucrt64' : 'mingw64'

// add MSYS2 in path for all Rubies on Windows, as it provides a better bash shell and a native toolchain
const msys2 = [`C:\\msys64\\${msys2Type}\\bin`, 'C:\\msys64\\usr\\bin']
newPath = [...newPathEntries, ...msys2]
} else {
newPath = newPathEntries
}
console.log(`Entries added to ${envPath} to use selected Ruby:`)
for (const entry of newPath) {
console.log(` ${entry}`)
}
core.endGroup()
console.log(`Entries added to ${envPath} to use selected Ruby:`)
for (const entry of newPathEntries) {
console.log(` ${entry}`)
}
})

core.addPath(newPath.join(path.delimiter))
return msys2Type
core.addPath(newPathEntries.join(path.delimiter))
}

export async function setupJavaHome(rubyPrefix) {
Expand Down Expand Up @@ -436,3 +412,15 @@ export async function setupJavaHome(rubyPrefix) {
}
})
}

// Determines if two keys are an exact match for the purposes of cache matching
// Specifically, this is a case-insensitive match that ignores accents
// From actions/cache@v3 src/utils/actionUtils.ts (MIT)
export function isExactCacheKeyMatch(key, cacheKey) {
return !!(
cacheKey &&
cacheKey.localeCompare(key, undefined, {
sensitivity: 'accent'
}) === 0
);
}
Loading
Loading