Welcome to mirror list, hosted at ThFree Co, Russian Federation.

setup.gitlab-ci.yml « ci « .gitlab - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 47bc73a9558bf399b003cd9bf325ca89b865a945 (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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# Insurance in case a gem needed by one of our releases gets yanked from
# rubygems.org in the future.
cache gems:
  extends:
    - .default-retry
    - .ruby-cache
    - .default-before_script
    - .setup:rules:cache-gems
  stage: prepare
  needs: []
  variables:
    BUNDLE_WITHOUT: ""
    BUNDLE_WITH: "production:development:test"
    SETUP_DB: "false"
  script:
    - 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
    expire_in: 31d

.predictive-job:
  extends:
    - .default-retry
  needs: []

.absolutely-predictive-job:
  extends:
    - .predictive-job
  image: ${GITLAB_DEPENDENCY_PROXY_ADDRESS}alpine:edge
  variables:
    GIT_STRATEGY: none

dont-interrupt-me:
  extends:
    - .absolutely-predictive-job
    - .setup:rules:dont-interrupt-me
  stage: sync
  interruptible: false
  script:
    - echo "This jobs makes sure this pipeline won't be interrupted! See https://docs.gitlab.com/ee/ci/yaml/#interruptible."

clone-gitlab-repo:
  extends:
    - .absolutely-predictive-job
    - .setup:rules:clone-gitlab-repo
  stage: sync
  script:
    - echo OK
  variables:
    GIT_STRATEGY: clone
  artifacts:
    paths:
      - '*'
    expire_in: '12 hours'

gitlab_git_test:
  extends:
    - .predictive-job
    - .setup:rules:gitlab_git_test
  stage: 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
  image: ${GITLAB_DEPENDENCY_PROXY_ADDRESS}ruby:${RUBY_VERSION}-alpine3.16
  stage: test
  needs: []
  script:
    - source scripts/utils.sh
    - install_tff_gem
    - scripts/verify-tff-mapping

verify-approvals:
  extends:
    - .predictive-job
    - .setup:rules:jh-contribution
  script:
    - source scripts/utils.sh
    - install_gitlab_gem
    - tooling/bin/find_app_sec_approval

generate-frontend-fixtures-mapping:
  extends:
    - .setup:rules:generate-frontend-fixtures-mapping
    - .use-pg14
    - .ruby-cache
  needs: ["setup-test-env"]
  stage: prepare
  before_script:
    - !reference [.default-before_script, before_script]
    - source ./scripts/rspec_helpers.sh
    - section_start "gitaly-test-spawn" "Spawning Gitaly"; scripts/gitaly-test-spawn; section_end "gitaly-test-spawn";  # Do not use 'bundle exec' here
  script:
    - generate_frontend_fixtures_mapping
  artifacts:
    expire_in: 7d
    paths:
      - ${FRONTEND_FIXTURES_MAPPING_PATH}

detect-tests:
  extends: .rails:rules:detect-tests
  image: ${GITLAB_DEPENDENCY_PROXY_ADDRESS}ruby:${RUBY_VERSION}-slim
  needs: []
  stage: prepare
  variables:
    RSPEC_TESTS_MAPPING_ENABLED: "true"
  before_script:
    - apt-get update && apt-get install -y curl  # Not present in ruby-slim, so we add it manually
  script:
    - source ./scripts/utils.sh
    - source ./scripts/rspec_helpers.sh
    - install_gitlab_gem
    - install_tff_gem
    - install_activesupport_gem
    - retrieve_tests_mapping
    - retrieve_frontend_fixtures_mapping
    - |
      if [ -n "$CI_MERGE_REQUEST_IID" ]; then
        mkdir -p $(dirname "$RSPEC_CHANGED_FILES_PATH")

        tooling/bin/predictive_tests

        filter_rspec_matched_foss_tests ${RSPEC_MATCHING_TESTS_PATH} ${RSPEC_MATCHING_TESTS_FOSS_PATH};
        filter_rspec_matched_ee_tests ${RSPEC_MATCHING_TESTS_PATH} ${RSPEC_MATCHING_TESTS_EE_PATH};

        echoinfo "Changed files: $(cat $RSPEC_CHANGED_FILES_PATH)";
        echoinfo "Related FOSS RSpec tests: $(cat $RSPEC_MATCHING_TESTS_FOSS_PATH)";
        echoinfo "Related EE RSpec tests: $(cat $RSPEC_MATCHING_TESTS_EE_PATH)";
        echoinfo "Related JS files: $(cat $RSPEC_MATCHING_JS_FILES_PATH)";
      fi
  artifacts:
    expire_in: 7d
    paths:
      - ${FRONTEND_FIXTURES_MAPPING_PATH}
      - ${RSPEC_CHANGED_FILES_PATH}
      - ${RSPEC_MATCHING_JS_FILES_PATH}
      - ${RSPEC_MATCHING_TESTS_EE_PATH}
      - ${RSPEC_MATCHING_TESTS_FOSS_PATH}
      - ${RSPEC_MATCHING_TESTS_PATH}
      - ${RSPEC_VIEWS_INCLUDING_PARTIALS_PATH}

detect-previous-failed-tests:
  extends:
    - detect-tests
    - .rails:rules:detect-previous-failed-tests
  variables:
    PREVIOUS_FAILED_TESTS_DIR: tmp/previous_failed_tests/
  script:
    - source ./scripts/utils.sh
    - source ./scripts/rspec_helpers.sh
    - retrieve_failed_tests "${PREVIOUS_FAILED_TESTS_DIR}" "oneline" "previous"
  artifacts:
    expire_in: 7d
    paths:
      - ${PREVIOUS_FAILED_TESTS_DIR}

e2e-test-pipeline-generate:
  extends:
    - .qa-job-base
    - .predictive-job
    - .qa:rules:determine-e2e-tests
  stage: prepare
  variables:
    ENV_FILE: $CI_PROJECT_DIR/qa_tests_vars.env
    COLORIZED_LOGS: "true"
  script:
    - bundle exec rake "ci:detect_changes[$ENV_FILE]"
    - cd $CI_PROJECT_DIR && scripts/generate-e2e-pipeline
  artifacts:
    expire_in: 1 day
    paths:
      - '*-pipeline.yml'
      - "${CI_PROJECT_DIR}/qa_tests_vars.env"

trigger-omnibus-env:
  stage: prepare
  extends:
    - .qa:rules:trigger-omnibus-env
  needs:
    # We need this job because we need its `cached-assets-hash.txt` artifact, so that we can pass the assets image tag to the downstream omnibus-gitlab pipeline.
    - compile-production-assets
  variables:
    BUILD_ENV: build.env
  before_script:
    - source scripts/utils.sh
  script:
    # Note that OMNIBUS_GITLAB_CACHE_UPDATE is not used in the code, but it is actually used in the 2-hourly maintenance pipeline schedule.
    - |
      SECURITY_SOURCES=$([[ ! "$CI_PROJECT_NAMESPACE" =~ ^gitlab-org\/security ]] || echo "true")
      echo "SECURITY_SOURCES=${SECURITY_SOURCES:-false}" > $BUILD_ENV
      echo "OMNIBUS_GITLAB_CACHE_UPDATE=${OMNIBUS_GITLAB_CACHE_UPDATE:-false}" >> $BUILD_ENV
      for version_file in *_VERSION; do echo "$version_file=$(cat $version_file)" >> $BUILD_ENV; done
      echo "OMNIBUS_GITLAB_BUILD_ON_ALL_OS=${OMNIBUS_GITLAB_BUILD_ON_ALL_OS:-false}" >> $BUILD_ENV
      ruby -e 'puts "FULL_RUBY_VERSION=#{RUBY_VERSION}"' >> $BUILD_ENV
      echo "GITLAB_ASSETS_TAG=$(assets_image_tag)" >> $BUILD_ENV
      echo "EE=$([[ $FOSS_ONLY == '1' ]] && echo 'false' || echo 'true')" >> $BUILD_ENV
      define_trigger_branch_in_build_env
    - |
      echo "Built environment file for omnibus build:"
      cat $BUILD_ENV
  artifacts:
    expire_in: 3 days
    reports:
      dotenv: $BUILD_ENV
    paths:
      - $BUILD_ENV

trigger-omnibus-env as-if-foss:
  extends:
    - trigger-omnibus-env
    - .qa:rules:package-and-test-ce
  needs:
    - compile-production-assets as-if-foss
  variables:
    FOSS_ONLY: "1"