Skip to content

Commit

Permalink
Use downloadAndExtract() for truffleruby+graalvm too
Browse files Browse the repository at this point in the history
* Simpler and more consistent that way.
* Avoids rerunning the post-install hook every time.
  • Loading branch information
eregon committed May 21, 2024
1 parent 7dc18ff commit 943103c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 42 deletions.
27 changes: 6 additions & 21 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 6 additions & 21 deletions ruby-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ export async function install(platform, engine, version) {

if (!inToolCache) {
await io.mkdirP(rubyPrefix)
if (engine === 'truffleruby+graalvm') {
await installWithRubyBuild(engine, version, rubyPrefix)
} else {
await downloadAndExtract(platform, engine, version, rubyPrefix)
}
await downloadAndExtract(platform, engine, version, rubyPrefix)
}

// https://github.com/oracle/truffleruby/issues/3390
Expand All @@ -67,21 +63,6 @@ export async function install(platform, engine, version) {
return rubyPrefix
}

async function installWithRubyBuild(engine, version, rubyPrefix) {
const tmp = process.env['RUNNER_TEMP'] || os.tmpdir()
const rubyBuildDir = path.join(tmp, 'ruby-build-for-setup-ruby')
await common.measure('Cloning ruby-build', async () => {
await exec.exec('git', ['clone', 'https://github.com/rbenv/ruby-build.git', rubyBuildDir])
})

const rubyName = `${engine}-${version === 'head' ? 'dev' : version}`
await common.measure(`Installing ${engine}-${version} with ruby-build`, async () => {
await exec.exec(`${rubyBuildDir}/bin/ruby-build`, [rubyName, rubyPrefix])
})

await io.rmRF(rubyBuildDir)
}

async function downloadAndExtract(platform, engine, version, rubyPrefix) {
const parentDir = path.dirname(rubyPrefix)

Expand Down Expand Up @@ -125,5 +106,9 @@ function getDownloadURL(platform, engine, version) {
}

function getLatestHeadBuildURL(platform, engine, version) {
return `https://github.com/ruby/${engine}-dev-builder/releases/latest/download/${engine}-${version}-${platform}.tar.gz`
var repo = `${engine}-dev-builder`
if (engine === 'truffleruby+graalvm') {
repo = 'truffleruby-dev-builder'
}
return `https://github.com/ruby/${repo}/releases/latest/download/${engine}-${version}-${platform}.tar.gz`
}

0 comments on commit 943103c

Please sign in to comment.