Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
shell: bash
run: which -a bundle
# https://github.com/ruby/setup-ruby/issues/658
if: "matrix.ruby != 'mingw' && matrix.ruby != 'mswin' && matrix.ruby != 'ucrt'"
if: "matrix.ruby != 'mingw' && !startsWith(matrix.ruby, 'mswin') && matrix.ruby != 'ucrt'"
- name: which rake
run: which -a rake
if: runner.os != 'Windows'
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ 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 4.1.0-preview1, head, debug, mingw, mswin, ucrt |
| `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 4.1.0-preview1, head, debug, mingw, ucrt |
| `mswin` | 3.4.11 - 4.0.9, head (Windows only) |
| `jruby` | 9.1.17.0 - 10.1.3.0, head |
| `truffleruby` | 19.3.0 - 40.0.0, head |
| `truffleruby+graalvm` | 21.2.0 - 40.0.0, head |
Expand All @@ -29,7 +30,10 @@ Native extensions are automatically compiled with AddressSanitizer when using `r
`ruby-asan` and `asan-release` are currently only available on `ubuntu-24.04` and `ubuntu-26.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.
builds.

`mswin` is CRuby built with MSVC, available on Windows only. `mswin-4.0` resolves to the latest 4.0.x release, and `mswin` and `mswin-head` to the latest master build.
The list of available versions is in [windows-mswin-versions.json](windows-mswin-versions.json).

Preview and RC versions of Ruby might be available too on Ubuntu and macOS (not on Windows).
However, it is recommended to test against `ruby-head` rather than previews,
Expand Down Expand Up @@ -62,7 +66,8 @@ only has builds of CRuby 3.2 and newer, as older CRuby versions do not compile o

The prebuilt releases are generated by [ruby-builder](https://github.com/ruby/ruby-builder)
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).
The `mingw` and `ucrt` builds are generated by [ruby-loco](https://github.com/MSP-Greg/ruby-loco).
The `mswin` builds are published at [cache.ruby-lang.org](https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/) and maintained by [hsbt](https://github.com/hsbt).
`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` and `truffleruby+graalvm-head` are generated by [truffleruby-dev-builder](https://github.com/ruby/truffleruby-dev-builder).
Expand Down
18 changes: 12 additions & 6 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ export async function time(name, block) {

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

// mswin is CRuby built with MSVC, so it follows the same version-dependent defaults
export function isCRuby(engine) {
return engine === 'ruby' || engine === 'mswin'
}

export function isStableVersion(engine, rubyVersion) {
Expand All @@ -86,7 +91,7 @@ export function hasBundlerDefaultGem(engine, rubyVersion) {
}

export function isBundler1Default(engine, rubyVersion) {
if (engine === 'ruby') {
if (isCRuby(engine)) {
return floatVersion(rubyVersion) >= 2.6 && floatVersion(rubyVersion) < 2.7
} else if (engine.startsWith('truffleruby')) {
return floatVersion(rubyVersion) < 21.0
Expand All @@ -98,7 +103,7 @@ export function isBundler1Default(engine, rubyVersion) {
}

export function isBundler2PlusDefault(engine, rubyVersion) {
if (engine === 'ruby') {
if (isCRuby(engine)) {
return floatVersion(rubyVersion) >= 2.7
} else if (engine.startsWith('truffleruby')) {
return floatVersion(rubyVersion) >= 21.0
Expand All @@ -110,7 +115,7 @@ export function isBundler2PlusDefault(engine, rubyVersion) {
}

export function isBundler2dot2PlusDefault(engine, rubyVersion) {
if (engine === 'ruby') {
if (isCRuby(engine)) {
return floatVersion(rubyVersion) >= 3.0
} else if (engine.startsWith('truffleruby')) {
return floatVersion(rubyVersion) >= 22.0
Expand All @@ -130,7 +135,7 @@ export function isBundler4PlusDefault(engine, rubyVersion) {

export function targetRubyVersion(engine, rubyVersion) {
const version = floatVersion(rubyVersion)
if (engine === 'ruby') {
if (isCRuby(engine)) {
return version
} else if (engine === 'jruby') {
if (version === 9.1) {
Expand Down Expand Up @@ -446,6 +451,7 @@ export function isExactCacheKeyMatch(key, cacheKey) {
}

export async function download(url) {
const auth = inputs.token ? `token ${inputs.token}` : undefined
// The token is for github.com, so it must not reach other hosts such as cache.ruby-lang.org
const auth = inputs.token && new URL(url).hostname === 'github.com' ? `token ${inputs.token}` : undefined
return await tc.downloadTool(url, undefined, auth)
}
107 changes: 89 additions & 18 deletions dist/index.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion generate-test-matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def unique_versions(versions, segment_count, *symbolic)
# Versions
ruby_builder_versions = JSON.load(File.read('ruby-builder-versions.json'))
windows_versions = JSON.load(File.read('windows-versions.json'))
windows_mswin_versions = JSON.load(File.read('windows-mswin-versions.json'))

# ruby: each minor release + head
ruby_versions = unique_versions(ruby_builder_versions['ruby'], 2, 'head')
Expand All @@ -59,8 +60,12 @@ def unique_versions(versions, segment_count, *symbolic)
truffleruby_versions = %w[truffleruby truffleruby-head truffleruby+graalvm truffleruby+graalvm-head]
matrix += (macos_arm64_runners + ubuntu_runners).product(truffleruby_versions)

# mswin: each minor release + head
windows_ruby_mswin_versions = unique_versions(windows_mswin_versions.keys, 2, 'head')
matrix += windows_runners.product(windows_ruby_mswin_versions.map { |version| "mswin-#{version}"})

# ruby-loco: head
ruby_loco_versions = %w[mingw mswin ucrt]
ruby_loco_versions = %w[mingw ucrt]
matrix += windows_x64_runners.product(ruby_loco_versions)

# asan: latest release + head
Expand Down
76 changes: 60 additions & 16 deletions generate-windows-versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
%r{\A#{Regexp.escape 'https://github.com/MSP-Greg/ruby-loco/releases/download'}/\w[\w.-]*/\w[\w.-]*\z}
].freeze

MSWIN_VERSIONS_URLS_REGEXPS = [
%r{\A#{Regexp.escape 'https://cache.ruby-lang.org/pub/ruby/binaries/mswin64'}/\w[\w.-]*\.zip\z},
%r{\A#{Regexp.escape 'https://cache.ruby-lang.org/pub/ruby/binaries/index.json'}\z}
].freeze

WINDOWS_TOOLCHAIN_VERSIONS_URLS_REGEXPS = [
%r{\A#{Regexp.escape 'https://github.com/oneclick/rubyinstaller/releases/download/devkit-4.7.2/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe'}\z},
%r{\A#{Regexp.escape 'https://github.com/ruby/setup-msys2-gcc/releases/download'}/\w[\w.-]*/\w[\w@.-]*\z},
Expand Down Expand Up @@ -66,9 +71,6 @@ def validate(versions, allowed_urls_regexps)
versions['mingw'] = {
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z'
}
versions['mswin'] = {
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z'
}
versions['ucrt'] = {
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-ucrt.7z'
}
Expand All @@ -79,6 +81,20 @@ def validate(versions, allowed_urls_regexps)
base_url = 'https://github.com/ruby/setup-msys2-gcc/releases/latest/download/windows-toolchain.json'
windows_toolchain = JSON.parse(URI.open(base_url, &:read), symbolize_names: true)

find_toolchain = -> platform, version {
toolchain = windows_toolchain.select do |pkg|
pkg[:platform] == platform && pkg[:required_ruby_version].any? do |requirement|
Gem::Requirement.new(requirement).satisfied_by?(version)
end
end

unless toolchain.one?
raise "#{toolchain.empty? ? 'no' : 'multiple'} toolchains found for #{platform} #{version}: #{toolchain}"
end

toolchain.first
}

versions.each do |raw_version, archs|
version = Gem::Version.correct?(raw_version) ? Gem::Version.new(raw_version) : head_version

Expand All @@ -91,8 +107,6 @@ def validate(versions, allowed_urls_regexps)
"#{arch}-mingw-ucrt"
when 'mingw'
"#{arch}-mingw32"
when 'mswin'
"#{arch}-mswin64"
else
if version >= Gem::Version.new('3.1.0.dev')
"#{arch}-mingw-ucrt"
Expand All @@ -101,20 +115,50 @@ def validate(versions, allowed_urls_regexps)
end
end

toolchain =
windows_toolchain.select do |pkg|
pkg[:platform] == platform && pkg[:required_ruby_version].any? do |requirement|
Gem::Requirement.new(requirement).satisfied_by?(version)
end
end
toolchain = find_toolchain.(platform, version)

unless toolchain.one?
raise "#{toolchain.empty? ? 'no' : 'multiple'} toolchains found for #{raw_version} #{raw_arch}: #{toolchain}"
end

archs[raw_arch] = URI.join(base_url, toolchain.first[:href]).to_s
archs[raw_arch] = URI.join(base_url, toolchain[:href]).to_s
end
end

validate(versions, WINDOWS_TOOLCHAIN_VERSIONS_URLS_REGEXPS)
File.binwrite 'windows-toolchain-versions.json', "#{JSON.pretty_generate(versions)}\n"

mswin_index_url = 'https://cache.ruby-lang.org/pub/ruby/binaries/index.json'
mswin_builds = JSON.parse(URI.open(mswin_index_url, &:read), symbolize_names: true)[:builds].select { |build|
build[:platform].end_with?('-mswin64_140')
}
mswin_arch = -> build { build[:platform].delete_suffix('-mswin64_140') }

release_builds = mswin_builds.select { |build|
build[:channel] == 'release' && Gem::Version.new(build[:version]) >= Gem::Version.new('3.4')
}
dev_builds = mswin_builds.select { |build| build[:channel] == 'dev' }

mswin_versions = release_builds.group_by { |build|
build[:version]
}.sort_by { |version, _|
Gem::Version.new(version)
}.to_h { |version, builds|
[version, builds.sort_by(&mswin_arch).to_h { |build| [mswin_arch.(build), build[:url]] }]
}

# The latest master build is picked from the index at runtime, see getLatestMswinHeadURL in windows.js
mswin_versions['head'] = dev_builds.map(&mswin_arch).uniq.sort.to_h { |arch| [arch, mswin_index_url] }

mswin_toolchain_versions = mswin_versions.to_h do |raw_version, archs|
version = raw_version == 'head' ? head_version : Gem::Version.new(raw_version)

toolchains = archs.map do |arch, _|
toolchain = find_toolchain.("#{arch}-mswin64", version)

[arch, URI.join(base_url, toolchain[:href]).to_s]
end
[raw_version, toolchains.to_h]
end

validate(mswin_versions, MSWIN_VERSIONS_URLS_REGEXPS)
File.binwrite 'windows-mswin-versions.json', "#{JSON.pretty_generate(mswin_versions)}\n"

validate(mswin_toolchain_versions, WINDOWS_TOOLCHAIN_VERSIONS_URLS_REGEXPS)
File.binwrite 'windows-mswin-toolchain-versions.json', "#{JSON.pretty_generate(mswin_toolchain_versions)}\n"
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function setupRuby(options = {}) {
const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version'])

let installer
if (platform.startsWith('windows-') && engine === 'ruby' && !common.isSelfHostedRunner()) {
if (platform.startsWith('windows-') && common.isCRuby(engine) && !common.isSelfHostedRunner()) {
installer = require('./windows')
} else {
installer = require('./ruby-builder')
Expand Down Expand Up @@ -140,6 +140,9 @@ function parseRubyEngineAndVersion(rubyVersion) {
if (/^(\d+)/.test(rubyVersion) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z
engine = 'ruby'
version = rubyVersion
} else if (rubyVersion === 'mswin') { // mswin has always been the master build
engine = 'mswin'
version = 'head'
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion
engine = rubyVersion
version = '' // Let the logic in validateRubyEngineAndVersion() find the version
Expand Down
2 changes: 1 addition & 1 deletion rubygems.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function compareGemVersion(a, b, rubyPrefix) {
// rubygems-update. See https://github.com/ruby/setup-ruby/pull/551 and
// https://github.com/rubygems/rubygems/issues/7329
async function rubygemsLatest(gem, platform, engine, rubyVersion) {
if (engine === 'ruby') {
if (common.isCRuby(engine)) {
const floatVersion = common.floatVersion(rubyVersion)
if (common.isHeadVersion(rubyVersion)) {
console.log('Ruby master builds use included RubyGems')
Expand Down
23 changes: 23 additions & 0 deletions windows-mswin-toolchain-versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"3.4.11": {
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
},
"3.4.12": {
"arm64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-arm64-windows.7z",
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
},
"4.0.7": {
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
},
"4.0.8": {
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
},
"4.0.9": {
"arm64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-arm64-windows.7z",
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
},
"head": {
"arm64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-arm64-windows.7z",
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
}
}
23 changes: 23 additions & 0 deletions windows-mswin-versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"3.4.11": {
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-3.4.11-x64-mswin64_140.zip"
},
"3.4.12": {
"arm64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-3.4.12-arm64-mswin64_140.zip",
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-3.4.12-x64-mswin64_140.zip"
},
"4.0.7": {
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-4.0.7-x64-mswin64_140.zip"
},
"4.0.8": {
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-4.0.8-x64-mswin64_140.zip"
},
"4.0.9": {
"arm64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-4.0.9-arm64-mswin64_140.zip",
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-4.0.9-x64-mswin64_140.zip"
},
"head": {
"arm64": "https://cache.ruby-lang.org/pub/ruby/binaries/index.json",
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/index.json"
}
}
3 changes: 0 additions & 3 deletions windows-toolchain-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,6 @@
"mingw": {
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/download/v20261024.010459/msys2-mingw64.7z"
},
"mswin": {
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
},
"ucrt": {
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/msys2-ucrt64.7z"
}
Expand Down
3 changes: 0 additions & 3 deletions windows-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,6 @@
"mingw": {
"x64": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z"
},
"mswin": {
"x64": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z"
},
"ucrt": {
"x64": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-ucrt.7z"
}
Expand Down
Loading
Loading