summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: afb2e2e88c634c0180ba5266e067b5a2f0520d53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
stages:
  - sync
  - preflight
  - prepare
  - build-images
  - fixtures
  - lint
  - test
  - post-test
  - review
  - qa
  - post-qa
  - pages
  - notify
  - release-environments

# always use `gitlab-org` runners, however
# in cases where jobs require Docker-in-Docker, the job
# definition must be extended with `.use-docker-in-docker`
default:
  image: $DEFAULT_CI_IMAGE
  tags:
    - gitlab-org
  # All jobs are interruptible by default
  interruptible: true
  # Default job timeout set to 90m https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/10520
  timeout: 90m

.ruby3-variables: &ruby3-variables
  RUBY_VERSION: "3.0"
  OMNIBUS_GITLAB_RUBY3_BUILD: "true"
  OMNIBUS_GITLAB_CACHE_EDITION: "GITLAB_RUBY3"

.ruby2-variables: &ruby2-variables
  RUBY_VERSION: "2.7"
  OMNIBUS_GITLAB_RUBY2_BUILD: "true"
  OMNIBUS_GITLAB_CACHE_EDITION: "GITLAB_RUBY2"

.default-branch-pipeline-failure-variables: &default-branch-pipeline-failure-variables
  CREATE_INCIDENT_FOR_PIPELINE_FAILURE: "true"
  NOTIFY_PIPELINE_FAILURE_CHANNEL: "master-broken"
  BROKEN_BRANCH_INCIDENTS_PROJECT: "gitlab-org/quality/engineering-productivity/master-broken-incidents"
  BROKEN_BRANCH_INCIDENTS_PROJECT_TOKEN: "${BROKEN_MASTER_INCIDENTS_PROJECT_TOKEN}"
  CREATE_ISSUES_FOR_FAILING_TESTS: "true"

workflow:
  name: '$PIPELINE_NAME'
  rules:
    # If `$FORCE_GITLAB_CI` is set, create a pipeline.
    - if: '$FORCE_GITLAB_CI'
      variables:
        <<: *ruby3-variables
        PIPELINE_NAME: 'Ruby 3 forced pipeline'
    # As part of the process of creating RCs automatically, we update stable
    # branches with the changes of the most recent production deployment. The
    # merge requests used for this merge a branch release-tools/X into a stable
    # branch. For these merge requests we don't want to run any pipelines, as
    # 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
    # For merge requests running exclusively in Ruby 2.7
    - if: '$CI_MERGE_REQUEST_LABELS =~ /pipeline:run-in-ruby2/'
      variables:
        <<: *ruby2-variables
        PIPELINE_NAME: 'Ruby 2 $CI_MERGE_REQUEST_EVENT_TYPE MR pipeline'
        NO_SOURCEMAPS: 'true'
    - if: '$CI_MERGE_REQUEST_LABELS =~ /Community contribution/'
      variables:
        <<: *ruby3-variables
        GITLAB_DEPENDENCY_PROXY_ADDRESS: ""
        PIPELINE_NAME: 'Ruby 3 $CI_MERGE_REQUEST_EVENT_TYPE MR pipeline (community contribution)'
        NO_SOURCEMAPS: 'true'
    # For (detached) merge request pipelines.
    - if: '$CI_MERGE_REQUEST_IID'
      variables:
        <<: *ruby3-variables
        PIPELINE_NAME: 'Ruby 3 $CI_MERGE_REQUEST_EVENT_TYPE MR pipeline'
        NO_SOURCEMAPS: 'true'
    # For the scheduled pipelines, we set specific variables.
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "schedule"'
      variables:
        <<: *ruby3-variables
        <<: *default-branch-pipeline-failure-variables
        CRYSTALBALL: "true"
        PIPELINE_NAME: 'Scheduled Ruby 3 $CI_COMMIT_BRANCH branch pipeline'
    # Run pipelines for ruby2 branch
    - if: '$CI_COMMIT_BRANCH == "ruby2" && $CI_PIPELINE_SOURCE == "schedule"'
      variables:
        <<: *ruby2-variables
        NOTIFY_PIPELINE_FAILURE_CHANNEL: "f_ruby3"
        PIPELINE_NAME: 'Scheduled Ruby 2 $CI_COMMIT_BRANCH branch pipeline'
    # This work around https://gitlab.com/gitlab-org/gitlab/-/issues/332411 whichs prevents usage of dependency proxy
    # when pipeline is triggered by a project access token.
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $GITLAB_USER_LOGIN =~ /project_\d+_bot\d*/'
      variables:
        <<: *ruby3-variables
        <<: *default-branch-pipeline-failure-variables
        GITLAB_DEPENDENCY_PROXY_ADDRESS: ""
        PIPELINE_NAME: 'Ruby 3 $CI_COMMIT_BRANCH branch pipeline (triggered by a project token)'
    # For `$CI_DEFAULT_BRANCH` branch, create a pipeline (this includes on schedules, pushes, merges, etc.).
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      variables:
        <<: *ruby3-variables
        <<: *default-branch-pipeline-failure-variables
        PIPELINE_NAME: 'Ruby 3 $CI_COMMIT_BRANCH branch pipeline'
    # For tags, create a pipeline.
    - if: '$CI_COMMIT_TAG'
      variables:
        <<: *ruby3-variables
        PIPELINE_NAME: 'Ruby 3 $CI_COMMIT_TAG tag pipeline'
    # If `$GITLAB_INTERNAL` isn't set, don't create a pipeline.
    - if: '$GITLAB_INTERNAL == null'
      when: never
    # For stable, auto-deploy, and security branches, create a pipeline.
    - if: '$CI_COMMIT_BRANCH =~ /^[\d-]+-stable(-ee)?$/'
      variables:
        <<: *ruby3-variables
        NOTIFY_PIPELINE_FAILURE_CHANNEL: "releases"
        PIPELINE_NAME: 'Ruby 3 $CI_COMMIT_BRANCH branch pipeline'
        CREATE_INCIDENT_FOR_PIPELINE_FAILURE: "true"
        BROKEN_BRANCH_INCIDENTS_PROJECT: "gitlab-org/release/tasks"
        BROKEN_BRANCH_INCIDENTS_PROJECT_TOKEN: "${BROKEN_STABLE_INCIDENTS_PROJECT_TOKEN}"
    - if: '$CI_COMMIT_BRANCH =~ /^\d+-\d+-auto-deploy-\d+$/'
      variables:
        <<: *ruby3-variables
        PIPELINE_NAME: 'Ruby 3 $CI_COMMIT_BRANCH branch pipeline'
    - if: '$CI_COMMIT_BRANCH =~ /^security\//'
      variables:
        <<: *ruby3-variables
        PIPELINE_NAME: 'Ruby 3 $CI_COMMIT_BRANCH branch pipeline'

variables:
  PG_VERSION: "12"
  DEFAULT_CI_IMAGE: "${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}.patched-golang-${GO_VERSION}-rust-${RUST_VERSION}-node-16.14-postgresql-${PG_VERSION}:rubygems-${RUBYGEMS_VERSION}-git-2.36-lfs-2.9-chrome-${CHROME_VERSION}-yarn-1.22-graphicsmagick-1.3.36"
  # We set $GITLAB_DEPENDENCY_PROXY to another variable (since it's set at the group level and has higher precedence than .gitlab-ci.yml)
  # so that we can override $GITLAB_DEPENDENCY_PROXY_ADDRESS in workflow rules.
  GITLAB_DEPENDENCY_PROXY_ADDRESS: "${GITLAB_DEPENDENCY_PROXY}"
  RAILS_ENV: "test"
  NODE_ENV: "test"
  BUNDLE_WITHOUT: "production:development"
  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=4096
  GIT_DEPTH: "20"
  # 'GIT_STRATEGY: clone' optimizes the pack-objects cache hit ratio
  GIT_STRATEGY: "clone"
  GIT_SUBMODULE_STRATEGY: "none"
  GET_SOURCES_ATTEMPTS: "3"
  DEBIAN_VERSION: "bullseye"
  CHROME_VERSION: "109"
  DOCKER_VERSION: "23.0.1"
  RUBY_VERSION: "2.7"
  RUBYGEMS_VERSION: "3.4"
  GO_VERSION: "1.18"
  RUST_VERSION: "1.65"

  FLAKY_RSPEC_SUITE_REPORT_PATH: rspec/flaky/report-suite.json
  FRONTEND_FIXTURES_MAPPING_PATH: crystalball/frontend_fixtures_mapping.json
  GITLAB_WORKHORSE_FOLDER: "gitlab-workhorse"
  JUNIT_RESULT_FILE: rspec/junit_rspec.xml
  JUNIT_RETRY_FILE: rspec/junit_rspec-retry.xml
  KNAPSACK_RSPEC_SUITE_REPORT_PATH: knapsack/report-master.json
  RSPEC_CHANGED_FILES_PATH: rspec/changed_files.txt
  RSPEC_FOSS_IMPACT_PIPELINE_TEMPLATE_YML: .gitlab/ci/rails/rspec-foss-impact.gitlab-ci.yml.erb
  RSPEC_LAST_RUN_RESULTS_FILE: rspec/rspec_last_run_results.txt
  RSPEC_MATCHING_JS_FILES_PATH: rspec/js_matching_files.txt
  RSPEC_MATCHING_TESTS_PATH: rspec/matching_tests.txt
  RSPEC_MATCHING_TESTS_FOSS_PATH: rspec/matching_tests-foss.txt
  RSPEC_MATCHING_TESTS_EE_PATH: rspec/matching_tests-ee.txt
  RSPEC_PACKED_TESTS_MAPPING_PATH: crystalball/packed-mapping.json
  RSPEC_PROFILING_FOLDER_PATH: rspec/profiling
  RSPEC_TESTS_MAPPING_PATH: crystalball/mapping.json
  TMP_TEST_FOLDER: "${CI_PROJECT_DIR}/tmp/tests"
  TMP_TEST_GITLAB_WORKHORSE_PATH: "${TMP_TEST_FOLDER}/${GITLAB_WORKHORSE_FOLDER}"

  ES_JAVA_OPTS: "-Xms256m -Xmx256m"
  ELASTIC_URL: "http://elastic:changeme@elasticsearch:9200"
  CACHE_CLASSES: "true"
  CHECK_PRECOMPILED_ASSETS: "true"
  FF_USE_FASTZIP: "true"
  SKIP_FLAKY_TESTS_AUTOMATICALLY: "false"
  RETRY_FAILED_TESTS_IN_NEW_PROCESS: "true"
  # Run with decomposed databases by default
  DECOMPOSED_DB: "true"

  DOCS_REVIEW_APPS_DOMAIN: "docs.gitlab-review.app"
  DOCS_GITLAB_REPO_SUFFIX: "ee"

  REVIEW_APPS_IMAGE: "${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/ruby-3.0:gcloud-383-kubectl-1.23-helm-3.5"
  REVIEW_APPS_DOMAIN: "gitlab-review.app"
  REVIEW_APPS_GCP_PROJECT: "gitlab-review-apps"
  REVIEW_APPS_GCP_REGION: "us-central1"

  BUILD_ASSETS_IMAGE: "true"  # Set it to "false" to disable assets image building, used in `build-assets-image`
  SIMPLECOV: "true"

  REGISTRY_HOST: "registry.gitlab.com"
  REGISTRY_GROUP: "gitlab-org"

  # Disable useless network connections when installing some NPM packages.
  # See https://gitlab.com/gitlab-com/gl-security/engineering-and-research/inventory/-/issues/827#note_1203181407
  DISABLE_OPENCOLLECTIVE: "true"

  # This is set at the gitlab-org level, but we set it here for forks
  DANGER_DO_NOT_POST_INVALID_DANGERFILE_ERROR: "1"

include:
  - local: .gitlab/ci/*.gitlab-ci.yml
  - remote: 'https://gitlab.com/gitlab-org/frontend/untamper-my-lockfile/-/raw/main/templates/merge_request_pipelines.yml'