From 6c2c0ecf80a1bf4f917c3177b63ac8f1020f05c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Coutable?= <remy@rymai.me>
Date: Thu, 2 May 2024 17:18:37 +0200
Subject: [PATCH] Run merge requests in Ruby 3.2 by default
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                     | 32 ++++++------------------------
 .gitlab/ci/rules.gitlab-ci.yml     |  7 -------
 .gitlab/ci/setup.gitlab-ci.yml     |  9 ---------
 doc/development/pipelines/index.md | 16 ++-------------
 4 files changed, 8 insertions(+), 56 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4bb4cb4dba284..7778e196571fe 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -27,10 +27,6 @@ default:
   # Default job timeout doesn't work: https://gitlab.com/gitlab-org/gitlab/-/issues/387528
   timeout: 90m
 
-.old-ruby-variables: &old-ruby-variables
-  RUBY_VERSION: "3.0"
-  OMNIBUS_GITLAB_CACHE_EDITION: "GITLAB_RUBY3_0"
-
 .default-ruby-variables: &default-ruby-variables
   RUBY_VERSION: "3.1"
   OMNIBUS_GITLAB_CACHE_EDITION: "GITLAB_RUBY3_1"
@@ -45,6 +41,7 @@ default:
   CREATE_RAILS_TEST_FAILURE_ISSUES: "true"
 
 .default-merge-request-variables: &default-merge-request-variables
+  NO_SOURCEMAPS: "true"
   ADD_SLOW_TEST_NOTE_TO_MERGE_REQUEST: "true"
 
 .if-merge-request-security-canonical-sync: &if-merge-request-security-canonical-sync
@@ -76,27 +73,15 @@ workflow:
     # they serve no purpose and will run anyway when the changes are merged.
     - if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^release-tools\/\d+\.\d+\.\d+-rc\d+$/ && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^[\d-]+-stable(-ee)?$/ && $CI_PROJECT_PATH == "gitlab-org/gitlab"'
       when: never
-    - if: '$CI_MERGE_REQUEST_LABELS =~ /pipeline:run-in-ruby3_0/'
-      variables:
-        <<: *old-ruby-variables
-        PIPELINE_NAME: 'Ruby $RUBY_VERSION MR'
-        NO_SOURCEMAPS: 'true'
     - if: '$CI_MERGE_REQUEST_LABELS =~ /pipeline:run-in-ruby3_1/'
       variables:
-        <<: *default-ruby-variables
-        PIPELINE_NAME: 'Ruby $RUBY_VERSION MR'
-        NO_SOURCEMAPS: 'true'
-    - if: '$CI_MERGE_REQUEST_LABELS =~ /pipeline:run-in-ruby3_2/'
-      variables:
-        <<: *next-ruby-variables
+        <<: [*default-ruby-variables, *default-merge-request-variables]
         PIPELINE_NAME: 'Ruby $RUBY_VERSION MR'
-        NO_SOURCEMAPS: 'true'
     - if: '$CI_MERGE_REQUEST_LABELS =~ /Community contribution/'
       variables:
-        <<: *default-ruby-variables
+        <<: [*next-ruby-variables, *default-merge-request-variables]
         GITLAB_DEPENDENCY_PROXY_ADDRESS: ""
         PIPELINE_NAME: 'Ruby $RUBY_VERSION MR (community contribution)'
-        NO_SOURCEMAPS: 'true'
     # This work around https://gitlab.com/gitlab-org/gitlab/-/issues/332411 which prevents usage of dependency proxy
     # when pipeline is triggered by a project access token.
     # Example of project bot usernames (the format changed over time):
@@ -104,30 +89,25 @@ workflow:
     # - project_278964_bot_7fb4d1cca8242cb399a0b8f483783120
     - if: '$CI_MERGE_REQUEST_IID && $GITLAB_USER_LOGIN =~ /project_\d+_bot/'
       variables:
-        <<: *default-ruby-variables
+        <<: [*next-ruby-variables, *default-merge-request-variables]
         GITLAB_DEPENDENCY_PROXY_ADDRESS: ""
         PIPELINE_NAME: 'Ruby $RUBY_VERSION MR (triggered by a project token)'
     - <<: *if-merge-request-security-canonical-sync
       variables:
-        <<: *default-ruby-variables
+        <<: [*next-ruby-variables, *default-merge-request-variables]
         PIPELINE_NAME: '$CI_DEFAULT_BRANCH security->canonical sync'
         SKIP_MESSAGE: 'MR only contains changes from the security mirror, which have already been reviewed, tested and deployed.'
     # For (detached) merge request pipelines.
     - if: '$CI_MERGE_REQUEST_IID'
       variables:
-        <<: [*default-ruby-variables, *default-merge-request-variables]
+        <<: [*next-ruby-variables, *default-merge-request-variables]
         PIPELINE_NAME: 'Ruby $RUBY_VERSION MR'
-        NO_SOURCEMAPS: 'true'
     # For the scheduled pipelines, we set specific variables.
     - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "schedule"'
       variables:
         <<: [*default-ruby-variables, *default-branch-pipeline-failure-variables]
         CRYSTALBALL: "true"
         PIPELINE_NAME: 'Scheduled Ruby $RUBY_VERSION $CI_COMMIT_BRANCH branch'
-    - if: '$CI_COMMIT_BRANCH == "ruby3_0" && $CI_PIPELINE_SOURCE == "schedule"'
-      variables:
-        <<: *old-ruby-variables
-        PIPELINE_NAME: 'Scheduled Ruby $RUBY_VERSION $CI_COMMIT_BRANCH branch'
     - if: '$CI_COMMIT_BRANCH == "ruby3_2" && $CI_PIPELINE_SOURCE == "schedule"'
       variables:
         <<: *next-ruby-variables
diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml
index 557885950fe24..767cfd5a8fcb9 100644
--- a/.gitlab/ci/rules.gitlab-ci.yml
+++ b/.gitlab/ci/rules.gitlab-ci.yml
@@ -62,9 +62,6 @@
 .if-merge-request-targeting-stable-branch: &if-merge-request-targeting-stable-branch
   if: '($CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" || $CI_MERGE_REQUEST_EVENT_TYPE == "detached") && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^[\d-]+-stable(-ee|-jh)?$/'
 
-.if-merge-request-labels-run-in-ruby: &if-merge-request-labels-run-in-ruby
-  if: '$CI_MERGE_REQUEST_LABELS =~ /pipeline:run-in-ruby\d+(_\d)*/'
-
 .if-merge-request-labels-as-if-foss: &if-merge-request-labels-as-if-foss
   if: '$CI_MERGE_REQUEST_LABELS =~ /pipeline:run-as-if-foss/'
 
@@ -2924,10 +2921,6 @@
     - <<: *if-default-refs
       changes: *code-backstage-patterns
 
-.setup:rules:verify-default-ruby:
-  rules:
-    - <<: *if-merge-request-labels-run-in-ruby
-
 .setup:rules:set-pipeline-name:
   rules:
     - <<: *if-not-merge-request  # This is only designed to run in a merge request
diff --git a/.gitlab/ci/setup.gitlab-ci.yml b/.gitlab/ci/setup.gitlab-ci.yml
index a515b90b9a3f5..c3cc646ba5885 100644
--- a/.gitlab/ci/setup.gitlab-ci.yml
+++ b/.gitlab/ci/setup.gitlab-ci.yml
@@ -88,15 +88,6 @@ gitlab_git_test:
   script:
     - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes
 
-verify-default-ruby:
-  extends:
-    - .absolutely-predictive-job
-    - .setup:rules:verify-default-ruby
-  stage: prepare
-  script:
-    - echo 'Please remove label ~"pipeline:run-in-ruby3_2" or ~"pipeline:run-in-ruby3_0" so we do test against default Ruby version before merging the merge request'
-    - exit 1
-
 verify-tests-yml:
   extends:
     - .setup:rules:verify-tests-yml
diff --git a/doc/development/pipelines/index.md b/doc/development/pipelines/index.md
index 0f919c0fd3b42..538500d57163d 100644
--- a/doc/development/pipelines/index.md
+++ b/doc/development/pipelines/index.md
@@ -648,8 +648,8 @@ Exceptions to this general guideline should be motivated and documented.
 ### Ruby versions testing
 
 We're running Ruby 3.1 on GitLab.com, as well as for the default branch.
-To prepare for the next Ruby version, we will run merge requests in Ruby 3.2,
-starting on February 2024. Please see the roadmap at
+To prepare for the next Ruby version, we run merge requests in Ruby 3.2.
+Please see the roadmap at
 [Ruby 3.2 epic](https://gitlab.com/groups/gitlab-org/-/epics/9684#plan)
 for more details.
 
@@ -659,19 +659,7 @@ suite on dedicated 2-hourly scheduled pipelines for each supported versions.
 For merge requests, you can add the following labels to run the respective
 Ruby version only:
 
-- `pipeline:run-in-ruby3_0`
 - `pipeline:run-in-ruby3_1`
-- `pipeline:run-in-ruby3_2`
-
-Note that when you do this, the test suite will no longer run in the default
-Ruby version for merge requests. In this case, an additional job
-`verify-default-ruby` will also run and always fail to remind us to remove
-the label and run in default Ruby before merging the merge request.
-
-This should let us:
-
-- Test changes for any supported Ruby versions
-- Make sure it will not break anything when it's merged into the default branch
 
 ### PostgreSQL versions testing
 
-- 
GitLab