From 40b78682aa2bf62e5e146fe6850f3a01fcc64831 Mon Sep 17 00:00:00 2001
From: Jennifer Li <jli@gitlab.com>
Date: Mon, 10 Mar 2025 12:37:58 -0700
Subject: [PATCH] Update test metadata jobs with custom exit code

---
 .gitlab/ci/test-metadata.gitlab-ci.yml | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/.gitlab/ci/test-metadata.gitlab-ci.yml b/.gitlab/ci/test-metadata.gitlab-ci.yml
index 44e6bd2f0f015..14a820e5267bf 100644
--- a/.gitlab/ci/test-metadata.gitlab-ci.yml
+++ b/.gitlab/ci/test-metadata.gitlab-ci.yml
@@ -23,7 +23,7 @@ retrieve-tests-metadata:
     - apk add --no-cache --update curl  # Not present in ruby-alpine, so we add it manually
     - !reference [".fast-no-clone-job", before_script]
   script:
-    - ruby scripts/setup/tests-metadata.rb retrieve
+    - run_with_custom_exit_code ruby scripts/setup/tests-metadata.rb retrieve
 
 update-tests-metadata:
   extends:
@@ -49,10 +49,15 @@ update-tests-metadata:
   script:
     - source scripts/utils.sh
     - source scripts/rspec_helpers.sh
-    - test -f "${FLAKY_RSPEC_SUITE_REPORT_PATH}" || echo -e "\e[31m" 'Consider add ~"pipeline:run-all-rspec" to run full rspec jobs' "\e[0m"
-    - run_timed_command "retry gem install fog-aws mime-types activesupport rspec_profiling postgres-copy --no-document"
-    - update_tests_metadata
-    - update_tests_mapping
+    - |
+      function update_metadata() {
+        test -f "${FLAKY_RSPEC_SUITE_REPORT_PATH}" || echo -e "\e[31m" 'Consider add ~"pipeline:run-all-rspec" to run full rspec jobs' "\e[0m"
+        run_timed_command "retry gem install fog-aws mime-types activesupport rspec_profiling postgres-copy --no-document"
+        update_tests_metadata
+        update_tests_mapping
+      }
+
+      run_with_custom_exit_code update_metadata
 
 verify-tests-metadata:
   extends:
@@ -66,4 +71,4 @@ verify-tests-metadata:
     - source scripts/utils.sh
     - install_activesupport_gem
   script:
-    - scripts/setup/tests-metadata.rb verify
+    - run_with_custom_exit_code scripts/setup/tests-metadata.rb verify
-- 
GitLab