diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 40e6526..15c3eb2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -142,6 +142,19 @@ jobs: bundler-cache: true - run: bundle exec rails --version + testTruffleRubyNokogiri: + name: "Test installing a Gemfile with nokogiri on TruffleRuby" + runs-on: ubuntu-latest + env: + BUNDLE_GEMFILE: gemfiles/nokogiri.gemfile + steps: + - uses: actions/checkout@v2 + - uses: ./ + with: + ruby-version: truffleruby-head + bundler-cache: true + - run: bundle list | grep nokogiri + lint: runs-on: ubuntu-20.04 steps: diff --git a/bundler.js b/bundler.js index a67f2ed..7905f5c 100644 --- a/bundler.js +++ b/bundler.js @@ -38,6 +38,16 @@ function readBundledWithFromGemfileLock(lockFile) { return null } +async function afterLockFile(lockFile, platform, engine) { + if (engine === 'truffleruby' && platform.startsWith('ubuntu-')) { + const contents = fs.readFileSync(lockFile, 'utf8') + if (contents.includes('nokogiri')) { + await common.measure('Installing libxml2-dev libxslt-dev, required to install nokogiri on TruffleRuby', async () => + exec.exec('sudo', ['apt-get', '-yqq', 'install', 'libxml2-dev', 'libxslt-dev'], { silent: true })) + } + } +} + export async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefix, engine, rubyVersion) { let bundlerVersion = bundlerVersionInput @@ -112,6 +122,8 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer await exec.exec('bundle', ['lock'], envOptions) } + await afterLockFile(lockFile, platform, engine) + // cache key const paths = [cachePath] const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile) diff --git a/common.js b/common.js index de7293c..1f18809 100644 --- a/common.js +++ b/common.js @@ -19,8 +19,10 @@ export function partition(string, separator) { return [string.slice(0, i), string.slice(i + separator.length, string.length)] } +let inGroup = false + export async function measure(name, block) { - return await core.group(name, async () => { + const body = async () => { const start = performance.now() try { return await block() @@ -29,7 +31,20 @@ export async function measure(name, block) { const duration = (end - start) / 1000.0 console.log(`Took ${duration.toFixed(2).padStart(6)} seconds`) } - }) + } + + if (inGroup) { + // Nested groups are not yet supported on GitHub Actions + console.log(`> ${name}`) + return await body() + } else { + inGroup = true + try { + return await core.group(name, body) + } finally { + inGroup = false + } + } } export function isHeadVersion(rubyVersion) { diff --git a/dist/index.js b/dist/index.js index 164b481..a1181b6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -32811,8 +32811,10 @@ function partition(string, separator) { return [string.slice(0, i), string.slice(i + separator.length, string.length)] } +let inGroup = false + async function measure(name, block) { - return await core.group(name, async () => { + const body = async () => { const start = performance.now() try { return await block() @@ -32821,7 +32823,20 @@ async function measure(name, block) { const duration = (end - start) / 1000.0 console.log(`Took ${duration.toFixed(2).padStart(6)} seconds`) } - }) + } + + if (inGroup) { + // Nested groups are not yet supported on GitHub Actions + console.log(`> ${name}`) + return await body() + } else { + inGroup = true + try { + return await core.group(name, body) + } finally { + inGroup = false + } + } } function isHeadVersion(rubyVersion) { @@ -44559,6 +44574,16 @@ function readBundledWithFromGemfileLock(lockFile) { return null } +async function afterLockFile(lockFile, platform, engine) { + if (engine === 'truffleruby' && platform.startsWith('ubuntu-')) { + const contents = fs.readFileSync(lockFile, 'utf8') + if (contents.includes('nokogiri')) { + await common.measure('Installing libxml2-dev libxslt-dev, required to install nokogiri on TruffleRuby', async () => + exec.exec('sudo', ['apt-get', '-yqq', 'install', 'libxml2-dev', 'libxslt-dev'], { silent: true })) + } + } +} + async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefix, engine, rubyVersion) { let bundlerVersion = bundlerVersionInput @@ -44633,6 +44658,8 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b await exec.exec('bundle', ['lock'], envOptions) } + await afterLockFile(lockFile, platform, engine) + // cache key const paths = [cachePath] const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile) diff --git a/gemfiles/nokogiri.gemfile b/gemfiles/nokogiri.gemfile new file mode 100644 index 0000000..26a4f14 --- /dev/null +++ b/gemfiles/nokogiri.gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gem "nokogiri"