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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ 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, and `mswin` is a MSVC build.

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 +62,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` build is the daily master build published at [cache.ruby-lang.org](https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/).
`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
3 changes: 2 additions & 1 deletion common.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,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)
}
59 changes: 51 additions & 8 deletions dist/index.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion generate-test-matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ def unique_versions(versions, segment_count, *symbolic)
matrix += (macos_arm64_runners + ubuntu_runners).product(truffleruby_versions)

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

# mswin: head
matrix += windows_runners.product(%w[mswin])

# asan: latest release + head
asan_versions = %w[asan-release asan]
matrix += asan_runners.sort.last(1).product(asan_versions)
Expand Down
9 changes: 6 additions & 3 deletions generate-windows-versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
WINDOWS_VERSIONS_URLS_REGEXPS = [
%r{\A#{Regexp.escape 'https://github.com/oneclick/rubyinstaller/releases/download'}/\w[\w.-]*/\w[\w.-]*\z},
%r{\A#{Regexp.escape 'https://github.com/oneclick/rubyinstaller2/releases/download'}/\w[\w.-]*/\w[\w.-]*\z},
%r{\A#{Regexp.escape 'https://github.com/MSP-Greg/ruby-loco/releases/download'}/\w[\w.-]*/\w[\w.-]*\z}
%r{\A#{Regexp.escape 'https://github.com/MSP-Greg/ruby-loco/releases/download'}/\w[\w.-]*/\w[\w.-]*\z},
%r{\A#{Regexp.escape 'https://cache.ruby-lang.org/pub/ruby/binaries/index.json'}\z}
].freeze

WINDOWS_TOOLCHAIN_VERSIONS_URLS_REGEXPS = [
Expand Down Expand Up @@ -66,8 +67,10 @@ def validate(versions, allowed_urls_regexps)
versions['mingw'] = {
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z'
}
# The latest master build is picked from the index at runtime, see getLatestMswinURL in windows.js
versions['mswin'] = {
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z'
'arm64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/index.json',
'x64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/index.json'
}
versions['ucrt'] = {
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-ucrt.7z'
Expand All @@ -92,7 +95,7 @@ def validate(versions, allowed_urls_regexps)
when 'mingw'
"#{arch}-mingw32"
when 'mswin'
"#{arch}-mswin64"
"#{raw_arch}-mswin64"
else
if version >= Gem::Version.new('3.1.0.dev')
"#{arch}-mingw-ucrt"
Expand Down
1 change: 1 addition & 0 deletions windows-toolchain-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/download/v20261024.010459/msys2-mingw64.7z"
},
"mswin": {
"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"
},
"ucrt": {
Expand Down
3 changes: 2 additions & 1 deletion windows-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@
"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"
"arm64": "https://cache.ruby-lang.org/pub/ruby/binaries/index.json",
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/index.json"
},
"ucrt": {
"x64": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-ucrt.7z"
Expand Down
52 changes: 47 additions & 5 deletions windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ export function getAvailableVersions(_platform, engine) {
}

export async function install(platform, engine, version) {
const url = rubyInstallerVersions[version][os.arch()]
let url = rubyInstallerVersions[version][os.arch()]
if (version === 'mswin') {
url = await getLatestMswinURL(url)
}

if (!url.endsWith('.7z')) {
throw new Error(`URL should end in .7z: ${url}`)
const ext = path.posix.extname(url)
if (ext !== '.7z' && ext !== '.zip') {
throw new Error(`URL should end in .7z or .zip: ${url}`)
}
const base = path.posix.basename(url, '.7z')
const base = path.posix.basename(url, ext)

let rubyPrefix, inToolCache
if (common.shouldUseToolCache(engine, version)) {
Expand All @@ -43,6 +47,10 @@ export async function install(platform, engine, version) {
await downloadAndExtract(engine, version, url, base, rubyPrefix);
}

if (version === 'mswin') {
exportEnv({ SSL_CERT_FILE: findGitCertFile() })
}

const paths = [`${rubyPrefix}\\bin`]
const windowsToolchain = core.getInput('windows-toolchain')
if (windowsToolchain === 'none') {
Expand Down Expand Up @@ -77,6 +85,33 @@ export async function install(platform, engine, version) {
return rubyPrefix
}

// mswin master builds are published daily under dated names, so pick the latest one from the index
async function getLatestMswinURL(indexURL) {
// Retry like tc.downloadTool does for the archive, so a transient failure of the index does not fail the job
let response
for (let attempt = 1; attempt <= 3; attempt++) {
try {
response = await fetch(indexURL, { signal: AbortSignal.timeout(30000) })
if (response.ok) break
} catch (error) {
if (attempt === 3) throw error
}
if (attempt < 3) await new Promise(resolve => setTimeout(resolve, 5000))
}
if (!response.ok) {
throw new Error(`Failed to fetch ${indexURL}: ${response.status} ${response.statusText}`)
}

const platform = `${os.arch()}-mswin64_140`
const builds = (await response.json()).builds.filter(build => build.channel === 'dev' && build.platform === platform)
if (builds.length === 0) {
throw new Error(`No mswin build for ${platform} in ${indexURL}`)
}

// The index is sorted by name, and the date in the name can differ from the date it was published
return builds.reduce((latest, build) => build.published_at > latest.published_at ? build : latest).url
}

async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
const downloadPath = await common.measure('Downloading Ruby', async () => {
console.log(url)
Expand Down Expand Up @@ -148,15 +183,22 @@ async function installMSYS2(url, rubyPrefix = process.env.RUNNER_TEMP) {
return [`${msys2Path}\\${msys2Type}\\bin`, `${msys2Path}\\usr\\bin`]
}

async function installMSYS1(url) {
// DevKit and mswin Rubies have no usable CA certificates on runners, so they use the bundle of Git for Windows
function findGitCertFile() {
const certFile = [
'C:\\Program Files\\Git\\ucrt64\\etc\\ssl\\cert.pem',
'C:\\Program Files\\Git\\mingw64\\etc\\ssl\\cert.pem',
'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem',
'C:\\Program Files\\Git\\clangarm64\\etc\\ssl\\cert.pem',
].find(file => fs.existsSync(file))
if (certFile === undefined) {
throw new Error("Cannot find Git's cert file")
}
return certFile
}

async function installMSYS1(url) {
const certFile = findGitCertFile()

const downloadPath = await common.measure('Downloading msys1 build tools', async () => {
console.log(url)
Expand Down
Loading