Skip to content

Commit 7edf159

Browse files
committed
Add support for truffleruby+graalvm
* Using ruby-build to avoid duplicating too much logic.
1 parent d9a8687 commit 7edf159

File tree

7 files changed

+77
-15
lines changed

7 files changed

+77
-15
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ 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: [ 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 ]
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, truffleruby+graalvm, truffleruby+graalvm-head ]
2020
include:
2121
- { os: windows-2016, ruby: mingw }
2222
- { os: windows-2019, ruby: mingw }
@@ -26,10 +26,14 @@ jobs:
2626
- { os: windows-2016, ruby: debug }
2727
- { os: windows-2016, ruby: truffleruby }
2828
- { os: windows-2016, ruby: truffleruby-head }
29+
- { os: windows-2016, ruby: truffleruby+graalvm }
30+
- { os: windows-2016, ruby: truffleruby+graalvm-head }
2931
- { os: windows-2019, ruby: 1.9 }
3032
- { os: windows-2019, ruby: debug }
3133
- { os: windows-2019, ruby: truffleruby }
3234
- { os: windows-2019, ruby: truffleruby-head }
35+
- { os: windows-2019, ruby: truffleruby+graalvm }
36+
- { os: windows-2019, ruby: truffleruby+graalvm-head }
3337

3438
name: ${{ matrix.os }} ${{ matrix.ruby }}
3539
runs-on: ${{ matrix.os }}

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
1717
| `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.1, head |
20+
| `truffleruby+graalvm` | 21.2.0, head |
2021

2122
`ruby-debug` is the same as `ruby-head` but with assertions enabled (`-DRUBY_DEBUG=1`).
2223
On Windows, `mingw` and `mswin` are `ruby-head` builds using the MSYS2/MinGW and the MSVC toolchains respectively.
@@ -46,8 +47,9 @@ The prebuilt releases are generated by [ruby-builder](https://github.com/ruby/ru
4647
and on Windows by [RubyInstaller2](https://github.com/oneclick/rubyinstaller2).
4748
`mingw` and `mswin` builds are generated by [ruby-loco](https://github.com/MSP-Greg/ruby-loco).
4849
`ruby-head` is generated by [ruby-dev-builder](https://github.com/ruby/ruby-dev-builder),
49-
`jruby-head` is generated by [jruby-dev-builder](https://github.com/ruby/jruby-dev-builder)
50-
and `truffleruby-head` is generated by [truffleruby-dev-builder](https://github.com/ruby/truffleruby-dev-builder).
50+
`jruby-head` is generated by [jruby-dev-builder](https://github.com/ruby/jruby-dev-builder),
51+
`truffleruby-head` is generated by [truffleruby-dev-builder](https://github.com/ruby/truffleruby-dev-builder)
52+
and `truffleruby+graalvm` is generated by [graalvm-ce-dev-builds](https://github.com/graalvm/graalvm-ce-dev-builds).
5153
The full list of available Ruby versions can be seen in [ruby-builder-versions.js](ruby-builder-versions.js)
5254
for Ubuntu and macOS and in [windows-versions.js](windows-versions.js) for Windows.
5355

bundler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function readBundledWithFromGemfileLock(lockFile) {
4141
}
4242

4343
async function afterLockFile(lockFile, platform, engine) {
44-
if (engine === 'truffleruby' && platform.startsWith('ubuntu-')) {
44+
if (engine.startsWith('truffleruby') && platform.startsWith('ubuntu-')) {
4545
const contents = fs.readFileSync(lockFile, 'utf8')
4646
if (contents.includes('nokogiri')) {
4747
await common.measure('Installing libxml2-dev libxslt-dev, required to install nokogiri on TruffleRuby', async () =>
@@ -86,7 +86,7 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
8686
// Avoid installing a newer Bundler version for head versions as it might not work.
8787
// For releases, even if they ship with Bundler 2 we install the latest Bundler.
8888
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
89-
} else if (engine === 'truffleruby' && common.isBundler1Default(engine, rubyVersion) && bundlerVersion.startsWith('1')) {
89+
} else if (engine.startsWith('truffleruby') && common.isBundler1Default(engine, rubyVersion) && bundlerVersion.startsWith('1')) {
9090
console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`)
9191
} else {
9292
const gem = path.join(rubyPrefix, 'bin', 'gem')

common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function isBundler1Default(engine, rubyVersion) {
6262
export function isBundler2Default(engine, rubyVersion) {
6363
if (engine === 'ruby') {
6464
return floatVersion(rubyVersion) >= 2.7
65-
} else if (engine === 'truffleruby') {
65+
} else if (engine.startsWith('truffleruby')) {
6666
return floatVersion(rubyVersion) >= 21.0
6767
} else if (engine === 'jruby') {
6868
return floatVersion(rubyVersion) >= 9.3

dist/index.js

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

ruby-builder-versions.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function getVersions(platform) {
1111
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6", "2.6.7", "2.6.8",
1212
"2.7.0", "2.7.1", "2.7.2", "2.7.3", "2.7.4",
1313
"3.0.0-preview1", "3.0.0-preview2", "3.0.0-rc1", "3.0.0", "3.0.1", "3.0.2",
14-
"head", "debug",
14+
"head", "debug"
1515
],
1616
"jruby": [
1717
"9.1.17.0",
@@ -23,6 +23,10 @@ export function getVersions(platform) {
2323
"20.0.0", "20.1.0", "20.2.0", "20.3.0",
2424
"21.0.0", "21.1.0", "21.2.0", "21.2.0.1",
2525
"head"
26+
],
27+
"truffleruby+graalvm": [
28+
"21.2.0",
29+
"head"
2630
]
2731
}
2832

ruby-builder.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,43 @@ export async function install(platform, engine, version) {
3535
common.setupPath([path.join(rubyPrefix, 'bin')])
3636

3737
if (!inToolCache) {
38-
await downloadAndExtract(platform, engine, version, rubyPrefix);
38+
await preparePrefix(rubyPrefix)
39+
if (engine === 'truffleruby+graalvm') {
40+
await installWithRubyBuild(engine, version, rubyPrefix)
41+
} else {
42+
await downloadAndExtract(platform, engine, version, rubyPrefix)
43+
}
3944
}
4045

4146
return rubyPrefix
4247
}
4348

44-
async function downloadAndExtract(platform, engine, version, rubyPrefix) {
49+
async function preparePrefix(rubyPrefix) {
4550
const parentDir = path.dirname(rubyPrefix)
4651

4752
await io.rmRF(rubyPrefix)
4853
if (!(fs.existsSync(parentDir) && fs.statSync(parentDir).isDirectory())) {
4954
await io.mkdirP(parentDir)
5055
}
56+
}
57+
58+
async function installWithRubyBuild(engine, version, rubyPrefix) {
59+
const tmp = process.env['RUNNER_TEMP'] || os.tmpdir()
60+
const rubyBuildDir = path.join(tmp, 'ruby-build-for-setup-ruby')
61+
await common.measure('Cloning ruby-build', async () => {
62+
await exec.exec('git', ['clone', 'https://github.com/rbenv/ruby-build.git', rubyBuildDir])
63+
})
64+
65+
const rubyName = `${engine}-${version === 'head' ? 'dev' : version}`
66+
await common.measure(`Installing ${engine}-${version} with ruby-build`, async () => {
67+
await exec.exec(`${rubyBuildDir}/bin/ruby-build`, [rubyName, rubyPrefix])
68+
})
69+
70+
await io.rmRF(rubyBuildDir)
71+
}
72+
73+
async function downloadAndExtract(platform, engine, version, rubyPrefix) {
74+
const parentDir = path.dirname(rubyPrefix)
5175

5276
const downloadPath = await common.measure('Downloading Ruby', async () => {
5377
const url = getDownloadURL(platform, engine, version)

0 commit comments

Comments
 (0)