From 33e3b22cadf09abb7300459aaa56fd03da439ab9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Coutable?= <remy@rymai.me>
Date: Thu, 4 Jul 2024 16:20:26 +0200
Subject: [PATCH] ci: Don't use repo from artifacts for critical jobs
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/frontend.gitlab-ci.yml | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/.gitlab/ci/frontend.gitlab-ci.yml b/.gitlab/ci/frontend.gitlab-ci.yml
index 8db7912d589a6..e04e61fd921ec 100644
--- a/.gitlab/ci/frontend.gitlab-ci.yml
+++ b/.gitlab/ci/frontend.gitlab-ci.yml
@@ -11,7 +11,6 @@
     - .default-retry
     - .default-before_script
     - .assets-compile-cache
-    - .repo-from-artifacts
   image: ${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/${BUILD_OS}-${OS_VERSION}-ruby-${RUBY_VERSION}-node-${NODE_VERSION}:rubygems-${RUBYGEMS_VERSION}-git-2.33-lfs-2.9-yarn-1.22-graphicsmagick-1.3.36
   variables:
     SETUP_DB: "false"
@@ -21,6 +20,7 @@
     BROWSERSLIST_IGNORE_OLD_DATA: "true"
     WEBPACK_COMPILE_LOG_PATH: "tmp/webpack-output.log"
   stage: prepare
+  needs: []
   script:
     - yarn_install_script
     - export GITLAB_ASSETS_HASH=$(bin/rake gitlab:assets:hash_sum)
@@ -71,7 +71,6 @@ follow-up:compile-production-assets:
     - compile-production-assets
     - .qa:rules:follow-up-e2e
   needs:
-    - !reference [compile-production-assets, needs]
     - manual:e2e-test-pipeline-generate
 
 compile-test-assets:
@@ -118,9 +117,9 @@ retrieve-frontend-fixtures:
     SETUP_DB: "false"
   extends:
     - .default-retry
-    - .repo-from-artifacts
     - .frontend:rules:default-frontend-jobs
   stage: prepare
+  needs: []
   script:
     - source scripts/utils.sh
     - source scripts/gitlab_component_helpers.sh
@@ -149,6 +148,7 @@ retrieve-frontend-fixtures:
     - "setup-test-env"
     - "retrieve-tests-metadata"
     - "retrieve-frontend-fixtures"
+    # it's ok to wait for the repo artifact as we're waiting for setup-test-env (which takes longer than clone-gitlab-repo) anyway
     - !reference [.repo-from-artifacts, needs]
   variables:
     # Don't add `CRYSTALBALL: "false"` here as we're enabling Crystalball for scheduled pipelines (in `.gitlab-ci.yml`), so that we get coverage data
@@ -196,6 +196,7 @@ upload-frontend-fixtures:
     - .frontend:rules:upload-frontend-fixtures
   stage: fixtures
   needs:
+    # it's ok to wait for the repo artifact as we're waiting for the fixtures (which wait for the repo artifact) anyway
     - !reference [.repo-from-artifacts, needs]
     - !reference [.with-fixtures-needs, needs]
   script:
@@ -212,9 +213,9 @@ graphql-schema-dump:
     - .default-retry
     - .ruby-cache
     - .default-before_script
-    - .repo-from-artifacts
     - .frontend:rules:default-frontend-jobs
   stage: fixtures
+  needs: []
   script:
     - bundle exec rake gitlab:graphql:schema:dump
   artifacts:
@@ -228,7 +229,6 @@ graphql-schema-dump:
   extends:
     - .default-retry
     - .yarn-cache
-    - .repo-from-artifacts
   variables:
     # Disable warnings in browserslist which can break on backports
     # https://github.com/browserslist/browserslist/blob/a287ec6/node.js#L367-L384
@@ -244,6 +244,7 @@ jest-build-cache:
   extends:
     - .frontend-test-base
     - .frontend:rules:jest
+  needs: []
   artifacts:
     name: jest-cache
     expire_in: 12h
@@ -283,7 +284,6 @@ jest:
     - .frontend-test-base
     - .frontend:rules:jest
   needs:
-    - !reference [.frontend-test-base, needs]
     - job: jest-build-cache
       optional: true
   artifacts:
@@ -303,9 +303,12 @@ jest:
 jest-with-fixtures:
   extends:
     - jest
+    - .repo-from-artifacts
     - .frontend:rules:jest
   needs:
     - !reference [jest, needs]
+    # it's ok to wait for the repo artifact as we're waiting for the fixtures (which wait for the repo artifact) anyway
+    - !reference [.repo-from-artifacts, needs]
     - !reference [.with-fixtures-needs, needs]
   parallel: 2
   script:
@@ -317,7 +320,6 @@ jest vue3:
     - .frontend:rules:jest-vue3
     - .vue3
   needs:
-    - !reference [.repo-from-artifacts, needs]
     - !reference [.with-jest-build-cache-vue3-needs, needs]
 
 jest-with-fixtures vue3:
@@ -327,6 +329,8 @@ jest-with-fixtures vue3:
     - .vue3
   needs:
     - !reference ["jest vue3", needs]
+    # it's ok to wait for the repo artifact as we're waiting for the fixtures (which wait for the repo artifact) anyway
+    - !reference [.repo-from-artifacts, needs]
     - !reference [.with-fixtures-needs, needs]
 
 jest predictive:
@@ -352,20 +356,24 @@ jest-with-fixtures predictive:
 jest-integration:
   extends:
     - .frontend-test-base
+    - .repo-from-artifacts
     - .frontend:rules:jest-integration
   script:
     - run_timed_command "yarn jest:integration --ci"
   needs:
-    - !reference [.frontend-test-base, needs]
+    # it's ok to wait for the repo artifact as we're waiting for the fixtures (which wait for the repo artifact) anyway
+    - !reference [.repo-from-artifacts, needs]
     - !reference [.with-fixtures-needs, needs]
     - !reference [.with-graphql-schema-dump-needs, needs]
 
 jest-snapshot-vue3:
   extends:
     - .frontend-test-base
+    - .repo-from-artifacts
     - .frontend:rules:jest-snapshot-vue3
   needs:
-    - !reference [.frontend-test-base, needs]
+    # it's ok to wait for the repo artifact as we're waiting for the fixtures (which wait for the repo artifact) anyway
+    - !reference [.repo-from-artifacts, needs]
     - !reference [.with-fixtures-needs, needs]
   variables:
     VUE_VERSION: 3
@@ -456,9 +464,11 @@ compile-storybook:
   extends:
     - .frontend-test-base
     - .storybook-yarn-cache
+    - .repo-from-artifacts
     - .frontend:rules:compile-storybook
   stage: pages
   needs:
+    # it's ok to wait for the repo artifact as we're waiting for the fixtures (which wait for the repo artifact) anyway
     - !reference [.repo-from-artifacts, needs]
     - !reference [.with-fixtures-needs, needs]
     - !reference [.with-graphql-schema-dump-needs, needs]
-- 
GitLab