# HG changeset patch
# User Georges Racinet <georges.racinet@octobus.net>
# Date 1674911955 -3600
#      Sat Jan 28 14:19:15 2023 +0100
# Branch heptapod-stable
# Node ID ec22cf4dc85d048b4b0f6cae37adae606ecf9274
# Parent  9d8396feaaa43b006a6c3cff2d6a719e3e72ed55
CI/CD: fixing outdated comment

We've precisely used the rubocop job as a first multi-cache attempt

diff --git a/heptapod-ci.yml b/heptapod-ci.yml
--- a/heptapod-ci.yml
+++ b/heptapod-ci.yml
@@ -224,10 +224,7 @@
     - run_timed_command "bundle exec rubocop --parallel"
   cache:
     # RuboCop has a LRU system (currently configured in .rubocop.yml to 18000
-    # entries).
-    # We currently can't use multiple caches, later on we'll reuse
-    # the .heptapod-rails-cache for the ruby gems and add the rubocop cache
-    # on top of it.
+    # entries), referencing it as a CI/CD cache for persistence
     - key:
         files:
           - VERSION
# HG changeset patch
# User Georges Racinet <georges.racinet@octobus.net>
# Date 1674912578 -3600
#      Sat Jan 28 14:29:38 2023 +0100
# Branch heptapod-stable
# Node ID 319c704e9f229ca6b65975e3e4bdc5ee9aff71e5
# Parent  ec22cf4dc85d048b4b0f6cae37adae606ecf9274
CI/CD: separating Go packages cache

It is useful in the gitlab-prebuild job only, and takes about 20%
of the extracted size (1.4G over 6.4G).

This brings in the splitting of the main cache and the more flexible way to use
it (YaML repetitions instead of `extends`, pretty much like upstream is doing)

diff --git a/heptapod-ci.yml b/heptapod-ci.yml
--- a/heptapod-ci.yml
+++ b/heptapod-ci.yml
@@ -64,8 +64,7 @@
   - local: .gitlab/ci/global.gitlab-ci.yml
   - local: .gitlab/ci/workhorse.gitlab-ci.yml
 
-.heptapod-rails-cache:
-  cache:
+.heptapod-rails-cache: &heptapod-rails-cache
     # default value for jobs using the cache
     policy: pull
     key:
@@ -90,8 +89,6 @@
       # separate them into those useful for downstream jobs and those
       # useful for `gitlab-prebuilds`
       - tmp/tests/gitaly/_build
-      # from go-pkg-cache
-      - .go/pkg/mod/
       # from node-modules-cache
       - node_modules/
       - tmp/cache/webpack-dlls/
@@ -120,6 +117,20 @@
       - tmp/tests/gitlab-workhorse/config.toml
       - tmp/tests/gitlab-workhorse/WORKHORSE_TREE
 
+.heptapod-rails-cache-update: &heptapod-rails-cache-update
+  <<: *heptapod-rails-cache
+  policy: pull-push
+
+# Similar to upstream's go-pkg-cache-push except that
+# - we're happy enough to restart from scratch when VERSION changes only
+.go-pkg-cache-update: &go-pkg-cache-update
+  policy: pull-push
+  key:
+    files:
+      - VERSION
+    prefix: "go-pkg"
+  paths:
+    - .go/pkg/mod/
 
 # this plays the role of the setup-test-env and compile-test-assets jobs
 # of upstream GitLab. The main difference is that it is "colder" a single
@@ -142,14 +153,14 @@
       when: always
     - when: never
   cache:
-    policy: pull-push
+    - *go-pkg-cache-update
+    - *heptapod-rails-cache-update
   tags:
     - clever
   extends:
     - .use-pg12  # base image and services
     # shell functions and some environment vars and bundle install for Rails
     - .default-before_script
-    - .heptapod-rails-cache
   stage: prepare
   variables:
     GITLAB_TEST_EAGER_LOAD: "0"
@@ -254,7 +265,8 @@
   extends:
     - .use-pg12  # base image and services
     - .default-before_script # shell functions and some environment vars
-    - .heptapod-rails-cache
+  cache:
+    - *heptapod-rails-cache
   artifacts:
     when: always
     paths:
# HG changeset patch
# User Georges Racinet <georges.racinet@octobus.net>
# Date 1674916108 -3600
#      Sat Jan 28 15:28:28 2023 +0100
# Branch heptapod-stable
# Node ID 2d7e960b8322624cd86b7bc1e558ec506b8cf991
# Parent  319c704e9f229ca6b65975e3e4bdc5ee9aff71e5
CI/CD: proper use of main cache in rubocop job

Because of lack of prefix, it was actually rebundling

diff --git a/heptapod-ci.yml b/heptapod-ci.yml
--- a/heptapod-ci.yml
+++ b/heptapod-ci.yml
@@ -239,16 +239,11 @@
     - key:
         files:
           - VERSION
-      policy: pull
-      paths:
-        - vendor/ruby
-    - key:
-        files:
-          - VERSION
         prefix: "rubocop"
       policy: pull-push
       paths:
         - tmp/rubocop_cache/
+    - *heptapod-rails-cache
 
 .rspec:
   # sharding (automatically sets the CI_NODE_{INDEX,TOTAL} expected by knapsack)
# HG changeset patch
# User Georges Racinet <georges.racinet@octobus.net>
# Date 1674916187 -3600
#      Sat Jan 28 15:29:47 2023 +0100
# Branch heptapod-stable
# Node ID f891261e677c8e5d91ffbd8cc249ed75b4084497
# Parent  2d7e960b8322624cd86b7bc1e558ec506b8cf991
CI/CD: removing Gitaly/Git/libgit2 intermediate objects from main cache

It is good enough to have them in the prebuild cache, and we don't
feel the need to have separate ones for go packages, object files etc
hence the renaming.

diff --git a/heptapod-ci.yml b/heptapod-ci.yml
--- a/heptapod-ci.yml
+++ b/heptapod-ci.yml
@@ -74,6 +74,8 @@
       prefix: "gitlab-upstream"
     paths:
       # from .gitaly-binaries-cache
+      - tmp/tests/gitaly/_build/bin
+      - tmp/tests/gitaly/_build/deps/git/install/
       - tmp/tests/gitaly/config.toml
       - tmp/tests/gitaly/gitaly2.config.toml
       - tmp/tests/gitaly/internal/
@@ -81,14 +83,8 @@
       - tmp/tests/gitaly/run2/
       - tmp/tests/gitaly/Makefile
       - tmp/tests/gitaly/praefect.config.toml
+      - tmp/tests/gitaly/praefect-db.config.toml
       - tmp/tests/gitaly/ruby/
-      # cache the entire Gitaly build dir so that subsequent runs are
-      # much faster. The drawback is that it is only useful for the
-      # `gitlab-prebuilds` job, the other ones only use `_build/bin`
-      # when we can have several caches, it would be a good idea to
-      # separate them into those useful for downstream jobs and those
-      # useful for `gitlab-prebuilds`
-      - tmp/tests/gitaly/_build
       # from node-modules-cache
       - node_modules/
       - tmp/cache/webpack-dlls/
@@ -121,16 +117,17 @@
   <<: *heptapod-rails-cache
   policy: pull-push
 
-# Similar to upstream's go-pkg-cache-push except that
-# - we're happy enough to restart from scratch when VERSION changes only
-.go-pkg-cache-update: &go-pkg-cache-update
+# Similar to upstream's go-pkg-cache-push and similar except that
+# we're happy enough to restart from scratch when VERSION changes only
+.prebuild-cache-update: &prebuild-cache-update
   policy: pull-push
   key:
     files:
       - VERSION
-    prefix: "go-pkg"
+    prefix: "prebuild"
   paths:
-    - .go/pkg/mod/
+    - .go/pkg/mod/  # 1.4G extracted size
+    - tmp/tests/gitaly/_build  # 2G extracted size
 
 # this plays the role of the setup-test-env and compile-test-assets jobs
 # of upstream GitLab. The main difference is that it is "colder" a single
@@ -153,7 +150,7 @@
       when: always
     - when: never
   cache:
-    - *go-pkg-cache-update
+    - *prebuild-cache-update
     - *heptapod-rails-cache-update
   tags:
     - clever