Skip to content

Improve rubygems cache for verify step

Gabriel Mazetto requested to merge brodock/cache-all-the-gems into main

What does this merge request do and why?

Current approach of setting up GEM_HOME and GEM_PATH is not working. The gems are "cached" but bundler is not using them. We can see that by looking at any install job:

--------------------------------------------------------------------------------
Installing gitlab-org/gitlab Ruby gems
--------------------------------------------------------------------------------
Fetching gem metadata from https://rubygems.org/.......
Fetching rake 13.0.6
Installing rake 13.0.6
Fetching rexml 3.2.5
Fetching RedCloth 4.3.2
Installing rexml 3.2.5
Fetching faraday-em_http 1.0.0
Installing RedCloth 4.3.2 with native extensions
Installing faraday-em_http 1.0.0
Fetching faraday-em_synchrony 1.0.0

If you see "Fetching" it means either it's missing from the cache, or the cache is being completely ignored.

A different/better approach is to use what is going to be the default in Bundler 3: the Global Cache.

To do that, you need to set a feature flag + customize the BUNDLE_USER_PATH to point to somewhere we can cache/restore.

This is also a portable version, as it adds prefix for multiple folders which is what we want when installing gems in multiple projects in the same pipeline.

How to set up and validate locally

Retry any job in verify stage. It should only display "Installing" instead of "Fetching" when bundle is running.

Impacted categories

The following categories relate to this merge request:

Merge request checklist

  • This change is backward compatible. If not, please include steps to communicate to our users.
  • Tests added for new functionality. If not, please raise an issue to follow-up.
  • Documentation added/updated, if needed.
  • Announcement added, if change is notable.
  • gdk doctor test added, if needed.
  • Add the ~highlight label if this MR should be included in the CHANGELOG.md.

Merge request reports