Skip to content

Commit 20324f7

Browse files
MSP-Gregeregon
authored andcommitted
Add ruby-loco mingw and mswin
1. Add ruby-loco mingw and mswin 2. Split workflow jobs into common and specials 3. Adjust workflow for mswin - 'ridk version' & 'c extension' steps
1 parent 7f508b5 commit 20324f7

File tree

6 files changed

+141
-22
lines changed

6 files changed

+141
-22
lines changed

.github/workflows/test.yml

+72-11
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,103 @@ on:
99
paths-ignore:
1010
- README.md
1111
jobs:
12-
test:
12+
common:
1313
strategy:
1414
fail-fast: false
1515
matrix:
1616
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
1717
# Use various version syntaxes here for testing
18-
ruby: [ .ruby-version, .tool-versions, 2.2, 2.3, ruby-head, jruby, jruby-head, truffleruby, truffleruby-head, rubinius ]
18+
ruby: [ .ruby-version, .tool-versions, 2.2, 2.3, ruby-head, jruby, jruby-head, truffleruby, truffleruby-head ]
1919
exclude:
2020
- os: windows-latest
2121
ruby: truffleruby
2222
- os: windows-latest
2323
ruby: truffleruby-head
24-
- os: ubuntu-16.04
25-
ruby: rubinius
26-
- os: macos-latest
27-
ruby: rubinius
28-
- os: windows-latest
29-
ruby: rubinius
3024
name: ${{ matrix.os }} ${{ matrix.ruby }}
3125
runs-on: ${{ matrix.os }}
3226
steps:
3327
- uses: actions/checkout@v2
3428
- uses: ./
3529
with:
3630
ruby-version: ${{ matrix.ruby }}
37-
- run: ruby --version
38-
- run: ridk version
39-
if: matrix.os == 'windows-latest' && !startsWith(matrix.ruby, 'jruby') && !startsWith(matrix.ruby, '2.3') && !startsWith(matrix.ruby, '2.2')
31+
- name: ruby version and gcc
32+
run: |
33+
ruby --version
34+
ruby -e "puts 'build gcc: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown')[/[^\n]+/]"
35+
- name: ridk version (mingw)
36+
if: matrix.os == 'windows-latest'
37+
run: |
38+
# run 'ridk version'
39+
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
40+
if (($abi -ge '2.4') -and $plat.Contains('mingw')) {
41+
ridk version
42+
} else {
43+
echo 'ridk is unavailable'
44+
}
45+
- name: Subprocess test
46+
run: ruby test_subprocess.rb
47+
- name: OpenSSL version
48+
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
49+
- name: OpenSSL test
50+
run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(1024) }'
51+
- name: C extension test
52+
run: gem install json:2.2.0 --no-document
53+
- run: bundle --version
54+
- run: bundle install
55+
- run: bundle exec rake --version
56+
57+
specials:
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
cfg:
62+
- { ruby: rubinius, os: ubuntu-18.04 }
63+
- { ruby: mingw , os: windows-latest }
64+
- { ruby: mswin , os: windows-latest }
65+
name: ${{ matrix.cfg.os }} ${{ matrix.cfg.ruby }}
66+
runs-on: ${{ matrix.cfg.os }}
67+
steps:
68+
- uses: actions/checkout@v2
69+
- uses: ./
70+
with:
71+
ruby-version: ${{ matrix.cfg.ruby }}
72+
- name: ruby version and gcc
73+
run: |
74+
ruby --version
75+
ruby -e "puts 'build gcc: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown')[/[^\n]+/]"
76+
- name: ridk version (mingw)
77+
if: matrix.cfg.os == 'windows-latest'
78+
run: |
79+
# run 'ridk version'
80+
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
81+
if (($abi -ge '2.4') -and $plat.Contains('mingw')) {
82+
ridk version
83+
} else {
84+
echo 'ridk is unavailable'
85+
}
4086
- name: Subprocess test
4187
run: ruby test_subprocess.rb
4288
- name: OpenSSL version
4389
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
4490
- name: OpenSSL test
4591
run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(1024) }'
4692
- name: C extension test
93+
if: endsWith(matrix.cfg.ruby, 'mswin') == false
4794
run: gem install json:2.2.0 --no-document
95+
- name: C extension test (mswin cmd)
96+
if: endsWith(matrix.cfg.ruby, 'mswin')
97+
shell: cmd
98+
run: |
99+
call %VCVARS%
100+
gem install json:2.2.0 --no-document
101+
- name: C extension test (mswin ps1)
102+
if: endsWith(matrix.cfg.ruby, 'mswin')
103+
run: |
104+
cmd.exe /c "$env:VCVARS && set" | Foreach-Object {
105+
$p, $v = $_.split('=')
106+
Set-Item -path env:$p -value $v
107+
}
108+
gem install json:2.2.0 --no-document
48109
- run: bundle --version
49110
- run: bundle install
50111
- run: bundle exec rake --version

dist/index.js

+33-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generate-windows-versions.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
[version, entry[:href]]
2525
}.to_h
2626

27-
versions['head'] = 'https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-head-x64.7z'
27+
versions['head'] = 'https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-head-x64.7z'
28+
versions['mingw'] = 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z'
29+
versions['mswin'] = 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z'
2830

2931
js = "export const versions = #{JSON.pretty_generate(versions)}\n"
3032
File.write 'windows-versions.js', js

index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function parseRubyEngineAndVersion(rubyVersion) {
4646
}
4747

4848
let engine, version
49-
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
49+
if (rubyVersion.match(/^(\d+|head|mingw|mswin)/)) { // X.Y.Z => ruby-X.Y.Z
5050
engine = 'ruby'
5151
version = rubyVersion
5252
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion
@@ -55,7 +55,6 @@ function parseRubyEngineAndVersion(rubyVersion) {
5555
} else { // engine-X.Y.Z
5656
[engine, version] = rubyVersion.split('-', 2)
5757
}
58-
5958
return [engine, version]
6059
}
6160

windows-versions.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ export const versions = {
2424
"2.6.4": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.4-1/rubyinstaller-2.6.4-1-x64.7z",
2525
"2.6.5": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.5-1/rubyinstaller-2.6.5-1-x64.7z",
2626
"2.7.0": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.0-1/rubyinstaller-2.7.0-1-x64.7z",
27-
"head": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-head-x64.7z"
27+
"head": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-head-x64.7z",
28+
"mingw": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z",
29+
"mswin": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z"
2830
}

windows.js

+29-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ export async function install(platform, ruby) {
3333
const rubyPrefix = `${drive}:\\${base}`
3434

3535
const [hostedRuby, msys2] = await linkMSYS2()
36-
setupPath(msys2, rubyPrefix)
36+
setupPath((ruby === 'ruby-mswin' ? null : msys2), rubyPrefix)
3737

3838
if (version.startsWith('2.2') || version.startsWith('2.3')) {
3939
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`)
40+
} else if (version === 'mswin') {
41+
setupMSWin(hostedRuby)
4042
}
4143

4244
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
@@ -46,6 +48,29 @@ export async function install(platform, ruby) {
4648
return rubyPrefix
4749
}
4850

51+
// all standard msvc OpenSSL builds use C:\Program Files\Common Files\SSL
52+
// as per openssl/openssl
53+
function setupMSWin(hostedRuby) {
54+
// create cert dir
55+
const msCertDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
56+
if (!fs.existsSync(msCertDir)) {
57+
fs.mkdirSync(msCertDir, { recursive: true })
58+
}
59+
60+
// Copy cert file
61+
const msCert = 'C:\\Program Files\\Common Files\\SSL\\cert.pem'
62+
if (!fs.existsSync(msCert)) {
63+
const ri2Cert = `${hostedRuby}\\ssl\\cert.pem`
64+
if (fs.existsSync(ri2Cert)) {
65+
fs.copyFileSync(ri2Cert, msCert)
66+
}
67+
}
68+
69+
// add convenience VCVARS env variable for msvc use
70+
// depends on single Visual Studio version being available in Actions image
71+
core.exportVariable('VCVARS', '"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat"')
72+
}
73+
4974
async function linkMSYS2() {
5075
const toolCacheVersions = tc.findAllVersions('Ruby')
5176
toolCacheVersions.sort()
@@ -57,7 +82,9 @@ async function linkMSYS2() {
5782

5883
const hostedMSYS2 = `${latestHostedRuby}\\msys64`
5984
const msys2 = 'C:\\msys64'
60-
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedMSYS2}`)
85+
if (!fs.existsSync(msys2)) {
86+
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedMSYS2}`)
87+
}
6188
return [latestHostedRuby, msys2]
6289
}
6390

0 commit comments

Comments
 (0)