Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bundler-cache to bundle install and cache gems #9400

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

joshcooper
Copy link
Contributor

@joshcooper joshcooper commented Jun 19, 2024

The setup-ruby action makes it trivial to bundle install gems from a cache and update the cache when the run completes.

When using bundler-cache, we can't use bundle config commands, but we can achieve the same effect specifying BUNDLE_SET as an env variable.

See https://github.com/ruby/setup-ruby for details

On Ubuntu 22.04:

> bundle install
/opt/hostedtoolcache/Ruby/3.2.4/x64/bin/bundle config --local path /home/runner/work/puppet/puppet/vendor/bundle
/opt/hostedtoolcache/Ruby/3.2.4/x64/bin/bundle lock
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Writing lockfile to /home/runner/work/puppet/puppet/Gemfile.lock
Cache key: setup-ruby-bundler-cache-v6-ubuntu-22.04-x64-ruby-3.2.4-wd-/home/runner/work/puppet/puppet-with--without--only--Gemfile.lock-6185088470ded95016515539e14e1cd5f8944fabbb2851ece3a74dcc8e02f5f9
Cache Size: ~[24](https://github.com/puppetlabs/puppet/actions/runs/9574586858/job/26398059207?pr=9400#step:3:30) MB (24880861 B)
/usr/bin/tar -xf /home/runner/work/_temp/77788843-aafe-4128-b8ba-72781e8e961e/cache.tzst -P -C /home/runner/work/puppet/puppet --use-compress-program unzstd
Cache restored successfully
Found cache for key: setup-ruby-bundler-cache-v6-ubuntu-22.04-x64-ruby-3.2.4-wd-/home/runner/work/puppet/puppet-with--without--only--Gemfile.lock-6185088470ded95016515539e14e1cd5f8944fabbb[28](https://github.com/puppetlabs/puppet/actions/runs/9574586858/job/26398059207?pr=9400#step:3:34)51ece3a74dcc8e02f5f9
/opt/hostedtoolcache/Ruby/3.2.4/x64/bin/bundle install --jobs 4
Bundle complete! 34 Gemfile dependencies, 94 gems now installed.
Bundled gems are installed into `./vendor/bundle`
Took   3.36 seconds

Previously the "install ruby 3.2" and "update rubygems and install gems" steps took 1+17=18 seconds. Now the combined "install ruby 3.2" step took 4 seconds.

The setup-ruby action makes it trivial to bundle install gems from a
cache and update the cache when the run completes.

When using `bundler-cache`, we can't use `bundle config` commands, but
we can achieve the same effect specifying BUNDLE_SET as an env variable.

See https://github.com/ruby/setup-ruby for details
@joshcooper joshcooper added the maintenance Maintenance chores are excluded from changelogs label Jun 19, 2024
@joshcooper joshcooper marked this pull request as ready for review June 19, 2024 01:51
@joshcooper joshcooper requested a review from a team as a code owner June 19, 2024 01:51
@AriaXLi AriaXLi merged commit 1a0ec94 into puppetlabs:main Jun 20, 2024
10 checks passed
@joshcooper joshcooper deleted the bundler-cache branch June 20, 2024 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance chores are excluded from changelogs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants