From 6c6bf61962010eb9e725aa280a76e6e3c0977af8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Coutable?= <remy@rymai.me>
Date: Thu, 1 Sep 2022 16:14:02 +0200
Subject: [PATCH] ci: Don't install gems quietly
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Rémy Coutable <remy@rymai.me>
---
 .gitlab-ci.yml                 |  2 +-
 .gitlab/ci/rules.gitlab-ci.yml |  4 ++++
 .gitlab/ci/setup.gitlab-ci.yml | 14 +++++++++-----
 scripts/utils.sh               |  6 +++++-
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f832b88b82187..9c6b84d393153 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -67,7 +67,7 @@ variables:
   RAILS_ENV: "test"
   NODE_ENV: "test"
   BUNDLE_WITHOUT: "production:development"
-  BUNDLE_INSTALL_FLAGS: "--jobs=$(nproc) --retry=3 --quiet"
+  BUNDLE_INSTALL_FLAGS: "--jobs=$(nproc) --retry=3"
   BUNDLE_FROZEN: "true"
   # we override the max_old_space_size to prevent OOM errors
   NODE_OPTIONS: --max_old_space_size=3584
diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml
index 6fc381fc7c2f1..6f18a76a21c8a 100644
--- a/.gitlab/ci/rules.gitlab-ci.yml
+++ b/.gitlab/ci/rules.gitlab-ci.yml
@@ -1792,6 +1792,10 @@
       when: never
     - <<: *if-default-branch-or-tag
       changes: *code-backstage-qa-patterns
+    - <<: *if-dot-com-gitlab-org-merge-request
+      changes: [".gitlab/ci/setup.gitlab-ci.yml"]
+      when: manual
+      allow_failure: true
 
 .setup:rules:dont-interrupt-me:
   rules:
diff --git a/.gitlab/ci/setup.gitlab-ci.yml b/.gitlab/ci/setup.gitlab-ci.yml
index 2631bae0c9a84..63ee02d3143d8 100644
--- a/.gitlab/ci/setup.gitlab-ci.yml
+++ b/.gitlab/ci/setup.gitlab-ci.yml
@@ -3,16 +3,20 @@
 cache gems:
   extends:
     - .default-retry
-    - .rails-cache
+    - .ruby-cache
     - .default-before_script
     - .setup:rules:cache-gems
-  stage: test
-  needs: ["setup-test-env"]
+  stage: prepare
+  needs: []
   variables:
-    BUNDLE_INSTALL_FLAGS: --with=production --with=development --with=test --jobs=2 --path=vendor --retry=3 --quiet
+    BUNDLE_WITHOUT: ""
+    BUNDLE_WITH: "production:development:test"
     SETUP_DB: "false"
   script:
-    - bundle package --all --all-platforms
+    - echo -e "\e[0Ksection_start:`date +%s`:bundle-package[collapsed=true]\r\e[0KPackaging gems"
+    - bundle config set cache_all true
+    - run_timed_command "bundle package --all-platforms"
+    - echo -e "\e[0Ksection_end:`date +%s`:bundle-package\r\e[0K"
   artifacts:
     paths:
       - vendor/cache
diff --git a/scripts/utils.sh b/scripts/utils.sh
index 8db525abc933b..10b7f856ee64d 100644
--- a/scripts/utils.sh
+++ b/scripts/utils.sh
@@ -38,6 +38,8 @@ function bundle_install_script() {
     exit 1;
   fi;
 
+  echo -e "section_start:`date +%s`:bundle-install[collapsed=true]\r\e[0KInstalling gems"
+
   gem --version
   bundle --version
   gem install bundler --no-document --conservative --version 2.3.15
@@ -48,7 +50,7 @@ function bundle_install_script() {
   echo "${BUNDLE_WITHOUT}"
   bundle config
 
-  run_timed_command "bundle install ${BUNDLE_INSTALL_FLAGS} ${extra_install_args} && bundle check"
+  run_timed_command "bundle install ${BUNDLE_INSTALL_FLAGS} ${extra_install_args}"
 
   if [[ $(bundle info pg) ]]; then
     # When we test multiple versions of PG in the same pipeline, we have a single `setup-test-env`
@@ -56,6 +58,8 @@ function bundle_install_script() {
     # Uncomment the following line if multiple versions of PG are tested in the same pipeline.
     run_timed_command "bundle pristine pg"
   fi
+
+  echo -e "section_end:`date +%s`:bundle-install\r\e[0K"
 }
 
 function setup_db_user_only() {
-- 
GitLab