Repository navigation
Add mswin engine with builds from cache.ruby-lang.org #971
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
base: master
Are you sure you want to change the base?
Changes from all commits
e34fb3e
7c7ec70
db08eaf
f943b83
a3fa02d
08daae3
69f3287
0b0e3f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { | ||
|
|
@@ -86,7 +91,7 @@ export function hasBundlerDefaultGem(engine, rubyVersion) { | |
| } | ||
|
|
||
| export function isBundler1Default(engine, rubyVersion) { | ||
| if (engine === 'ruby') { | ||
| if (isCRuby(engine)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is quite error-prone as
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another approach I can think of that is potentially less error-prone is to make this more object oriented. E.g. introduce a class RubyVersion {
constructor(rubyVersion) {
...
}
get engine() {
...
}
get isCRuby() {
...
}
get version() {
...
}
get floatVersion() {
...
}
} |
||
| return floatVersion(rubyVersion) >= 2.6 && floatVersion(rubyVersion) < 2.7 | ||
| } else if (engine.startsWith('truffleruby')) { | ||
| return floatVersion(rubyVersion) < 21.0 | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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) { | ||
|
|
@@ -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) | ||
| } | ||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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[\[email protected]]*\z}, | ||
|
|
@@ -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' | ||
| } | ||
|
|
@@ -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 | ||
|
|
||
|
|
@@ -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" | ||
|
|
@@ -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" | ||
| 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" | ||
| } | ||
| } |
| 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" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mswinisn't really an interpreter so this reads a bit strange.