Improve dependency caching in CI pipelines

Problem

Current dependency caching setup is sub optimal and it creates a lot of cache misses. This is especially true for pipelines running in stable branches or other forks like security. This is due to a flaw in design that couples cache population to specific scheduled pipelines that only runs on master branch of gitlab-org/gitlab project

Proposal

Update caching setup so it is completely decoupled from branches or projects and is only dependant on the files that can affect cache state (for example dependency lockfiles).

All changes should be implemented in master branch and then backported to stable branches

Tasks

  • Have a cache for the compile-test-assets job, as it's currently not using any cache (takes ~20min instead of 4min) (1,2,3)
  • Have a cache for ruby gems, as it's currently not using any (example, result)
  • Have a cache for node packages, as it's currently not using any (example)
  • Verify the cache is found as much as in non-backports pipelines in the following environments:
    • canonical
    • FOSS
    • Security
Edited by andrey