Skip to content

Commit ae9cb3b

Browse files
committed
Add Ruby 1.9 on Linux and macOS
* On Windows there are no 64-bit builds of Ruby 1.9. * Fix floatVersion() for head versions. * Use floatVersion() in more cases instead of regexps. * Rely on ~/.gemrc to not install gem docs.
1 parent 77d7ca9 commit ae9cb3b

File tree

8 files changed

+43
-24
lines changed

8 files changed

+43
-24
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
os: [ ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11.0, windows-2016, windows-2019 ]
19-
ruby: [ '2.0', 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, '3.0', ruby-head, jruby, jruby-head, truffleruby, truffleruby-head ]
19+
ruby: [ 1.9, '2.0', 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, '3.0', ruby-head, jruby, jruby-head, truffleruby, truffleruby-head ]
2020
include:
2121
- { os: windows-2016, ruby: mingw }
2222
- { os: windows-2019, ruby: mingw }
2323
- { os: windows-2019, ruby: mswin }
2424
exclude:
25+
- { os: windows-2016, ruby: 1.9 }
2526
- { os: windows-2016, ruby: debug }
2627
- { os: windows-2016, ruby: truffleruby }
2728
- { os: windows-2016, ruby: truffleruby-head }
29+
- { os: windows-2019, ruby: 1.9 }
2830
- { os: windows-2019, ruby: debug }
2931
- { os: windows-2019, ruby: truffleruby }
3032
- { os: windows-2019, ruby: truffleruby-head }
@@ -67,14 +69,17 @@ jobs:
6769

6870
- name: Subprocess test
6971
run: ruby test_subprocess.rb
70-
- name: OpenSSL version
72+
- name: OpenSSL compiled version
73+
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
74+
- name: OpenSSL loaded version
7175
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
76+
if: matrix.ruby != '1.9'
7277
- name: OpenSSL test
7378
run: ruby -ropen-uri -e 'puts URI.send(:open, %{https://rubygems.org/}) { |f| f.read(1024) }'
7479

7580
- run: gem env
7681
- name: C extension test
77-
run: gem install json:2.2.0 --no-document
82+
run: gem install json -v 2.2.0
7883
- run: bundle --version
7984
# This step is redundant with `bundler-cache: true` but is there to check a redundant `bundle install` still works
8085
- run: bundle install

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
1414

1515
| Interpreter | Versions |
1616
| ----------- | -------- |
17-
| `ruby` | 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.0.2, head, debug, mingw, mswin |
17+
| `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.0.2, head, debug, mingw, mswin |
1818
| `jruby` | 9.1.17.0, 9.2.9.0 - 9.2.19.0, head |
1919
| `truffleruby` | 19.3.0 - 21.2.0, head |
2020

bundler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
7171
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
7272
}
7373

74-
if (engine === 'ruby' && rubyVersion.match(/^2\.[012]/)) {
74+
if (engine === 'ruby' && common.floatVersion(rubyVersion) <= 2.2) {
7575
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2')
7676
bundlerVersion = '1'
7777
} else if (engine === 'ruby' && rubyVersion.match(/^2\.3\.[01]/)) {
@@ -91,7 +91,7 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
9191
} else {
9292
const gem = path.join(rubyPrefix, 'bin', 'gem')
9393
const bundlerVersionConstraint = bundlerVersion.match(/^\d+\.\d+\.\d+/) ? bundlerVersion : `~> ${bundlerVersion}`
94-
await exec.exec(gem, ['install', 'bundler', '-v', bundlerVersionConstraint, '--no-document'])
94+
await exec.exec(gem, ['install', 'bundler', '-v', bundlerVersionConstraint])
9595
}
9696

9797
return bundlerVersion

common.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ export function isBundler1Default(engine, rubyVersion) {
6161

6262
export function isBundler2Default(engine, rubyVersion) {
6363
if (engine === 'ruby') {
64-
return isHeadVersion(rubyVersion) || floatVersion(rubyVersion) >= 2.7
64+
return floatVersion(rubyVersion) >= 2.7
6565
} else if (engine === 'truffleruby') {
66-
return isHeadVersion(rubyVersion) || floatVersion(rubyVersion) >= 21.0
66+
return floatVersion(rubyVersion) >= 21.0
6767
} else if (engine === 'jruby') {
68-
return isHeadVersion(rubyVersion) || floatVersion(rubyVersion) >= 9.3
68+
return floatVersion(rubyVersion) >= 9.3
6969
} else {
7070
return false
7171
}
@@ -75,8 +75,10 @@ export function floatVersion(rubyVersion) {
7575
const match = rubyVersion.match(/^\d+\.\d+/)
7676
if (match) {
7777
return parseFloat(match[0])
78+
} else if (isHeadVersion(rubyVersion)) {
79+
return 999.999
7880
} else {
79-
return 0.0
81+
throw new Error(`Could not convert version ${rubyVersion} to a float`)
8082
}
8183
}
8284

dist/index.js

Lines changed: 17 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function setupRuby(options = {}) {
4848
const engineVersions = installer.getAvailableVersions(platform, engine)
4949
const version = validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion)
5050

51-
createGemRC()
51+
createGemRC(engine, version)
5252
envPreInstall()
5353

5454
const rubyPrefix = await installer.install(platform, engine, version)
@@ -138,10 +138,14 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe
138138
return version
139139
}
140140

141-
function createGemRC() {
141+
function createGemRC(engine, version) {
142142
const gemrc = path.join(os.homedir(), '.gemrc')
143143
if (!fs.existsSync(gemrc)) {
144-
fs.writeFileSync(gemrc, `gem: --no-document${os.EOL}`)
144+
if (engine === 'ruby' && common.floatVersion(version) < 2.0) {
145+
fs.writeFileSync(gemrc, `install: --no-rdoc --no-ri${os.EOL}update: --no-rdoc --no-ri${os.EOL}`)
146+
} else {
147+
fs.writeFileSync(gemrc, `gem: --no-document${os.EOL}`)
148+
}
145149
}
146150
}
147151

ruby-builder-versions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export function getVersions(platform) {
22
const versions = {
33
"ruby": [
4+
"1.9.3-p551",
45
"2.0.0-p648",
56
"2.1.9",
67
"2.2.10",

windows.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
8282
async function setupMingw(version) {
8383
core.exportVariable('MAKE', 'make.exe')
8484

85-
if (version.match(/^2\.[0123]/)) {
85+
if (common.floatVersion(version) <= 2.3) {
8686
core.exportVariable('SSL_CERT_FILE', certFile)
8787
await common.measure('Installing MSYS', async () => installMSYS(version))
8888
return msysPathEntries

0 commit comments

Comments
 (0)