Skip to content

Commit 0481980

Browse files
Earlopaineregon
authored andcommitted
Print lockfile contents earlier
Currently, the lockfile gets printed after `bundle install` finished. This could be too late when `bundle install` fails for whatever reason. I have a workflow that failed like this: <details><summary>Logs</summary> <p> ``` 55s Run ruby/setup-ruby@v1 Modifying PATH Downloading Ruby Extracting Ruby Print Ruby version Installing Bundler > bundle install /opt/hostedtoolcache/Ruby/2.7.8/x64/bin/bundle config --local path /home/runner/work/rubocop/rubocop/vendor/bundle /opt/hostedtoolcache/Ruby/2.7.8/x64/bin/bundle lock Fetching source index from https://rubygems.org/ Network error while fetching https://rubygems.org/quick/Marshal.4.8/asciidoctor-0.0.1.gemspec.rz (Connection reset by peer - SSL_connect) Error: The process '/opt/hostedtoolcache/Ruby/2.7.8/x64/bin/bundle' failed with exit code 17 Run ruby/setup-ruby@v1 Modifying PATH Downloading Ruby Extracting Ruby Print Ruby version Installing Bundler > bundle install /opt/hostedtoolcache/Ruby/2.7.8/x64/bin/bundle config --local path /home/runner/work/rubocop/rubocop/vendor/bundle /opt/hostedtoolcache/Ruby/2.7.8/x64/bin/bundle lock Fetching source index from https://rubygems.org/ Network error while fetching https://rubygems.org/quick/Marshal.4.8/asciidoctor-0.0.1.gemspec.rz (Connection reset by peer - SSL_connect) Error: The process '/opt/hostedtoolcache/Ruby/2.7.8/x64/bin/bundle' failed with exit code 17 ``` </p> </details> It would help to print the lockfile for this I think. It fetching version 0.0.1 confused me but probably the lockfile looks ok. New output: ``` Run ./ Modifying PATH Print Ruby version Installing Bundler > bundle install /opt/hostedtoolcache/Ruby/3.2.9/x64/bin/bundle config --local path /home/runner/work/setup-ruby/setup-ruby/vendor/bundle /opt/hostedtoolcache/Ruby/3.2.9/x64/bin/bundle lock Fetching gem metadata from https://rubygems.org/........... Resolving dependencies... Writing lockfile to /home/runner/work/setup-ruby/setup-ruby/gemfiles/rails8.gemfile.lock Print lockfile Cache key: setup-ruby-bundler-cache-v6-ubuntu-24.04-x64-ruby-3.2.9-wd-/home/runner/work/setup-ruby/setup-ruby-with--without--only--/home/runner/work/setup-ruby/setup-ruby/gemfiles/rails8.gemfile.lock-cb69172094f71f01e5207070d9af8d465d9aa9c386ecbad22b1b6e8e43523fd2 /opt/hostedtoolcache/Ruby/3.2.9/x64/bin/bundle install --jobs 4 ... ``` So it's relatively at the top and not hidden somewhere. Also removes the need to check for the lockfile again.
1 parent cf7216d commit 0481980

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

bundler.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
165165
await exec.exec('bundle', ['lock'], envOptions)
166166
}
167167

168+
await core.group(`Print lockfile`, async () =>
169+
await exec.exec('cat', [lockFile]))
170+
168171
// cache key
169172
const paths = [cachePath]
170173
const baseKey = await computeBaseKey(engine, rubyVersion, lockFile, cacheVersion)

dist/index.js

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

index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ export async function setupRuby(options = {}) {
9999
if (inputs['bundler-cache'] === 'true') {
100100
await common.time('bundle install', async () =>
101101
bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version']))
102-
103-
if (lockFile !== null && fs.existsSync(lockFile)) {
104-
await core.group(`Print lockfile`, async () =>
105-
await exec.exec('cat', [lockFile]))
106-
}
107102
}
108103

109104
core.setOutput('ruby-prefix', rubyPrefix)

0 commit comments

Comments
 (0)