Add an optional extra fallback build cache

What does this MR do?

Adds EXTRA_FALLBACK_CACHE_REF_SLUG, an optional build cache that builds read from but never write to. When it's set, build.sh adds --cache-from for cache:<job>-<slug>, after the branch and default branch caches. When it isn't set, nothing changes.

Since gitlab-org/gitlab!264448 (merged), GitLab MR pipelines build the E2E CNG images on Ruby 3.4, while the scheduled master pipeline that writes cache:gitlab-rails-ee-master still builds on Ruby 3.3. Every layer sits on a different gitlab-ruby base image, so MR builds can't reuse any of it, and gitlab-rails-ee takes about 4-5 minutes longer when the MR has no branch cache yet. The ruby-next schedule already writes a Ruby 3.4 cache (cache:gitlab-rails-ee-ruby-next) every two hours, so GitLab can pass EXTRA_FALLBACK_CACHE_REF_SLUG=ruby-next to use it.

Follow-up

A gitlab-org/gitlab MR that sets EXTRA_FALLBACK_CACHE_REF_SLUG: ruby-next on build-cng and bumps GITLAB_CNG_MIRROR_REF to a CNG commit that includes this change.

How to verify

Once the GitLab change is in, the gitlab-rails-ee log of a Ruby 3.4 MR build shows importing cache manifest from ...cache:gitlab-rails-ee-ruby-next, and its builder-base steps show CACHED.

Edited by Heinrich Lee Yu

Merge request reports

Loading
Loading