Read about our upcoming Code of Conduct on this issue

rails.gitlab-ci.yml 7.94 KB
Newer Older
1
.only-master:
Kamil Trzciński's avatar
Kamil Trzciński committed
2
  only:
Stan Hu's avatar
Stan Hu committed
3
    refs:
4
      - master
5

Stan Hu's avatar
Stan Hu committed
6
.rake-exec:
Philippe Lafoucrière's avatar
Philippe Lafoucrière committed
7
  extends:
Stan Hu's avatar
Stan Hu committed
8
9
10
    - .default-tags
    - .default-retry
    - .default-cache
11
    - .default-only
Stan Hu's avatar
Stan Hu committed
12
    - .default-before_script
Kamil Trzciński's avatar
Kamil Trzciński committed
13
14
15
16
17
  variables:
    SETUP_DB: "false"
  script:
    - bundle exec rake $CI_JOB_NAME

18
19
20
21
22
23
24
.only-code-rails-job-base:
  extends:
    - .default-tags
    - .default-retry
    - .default-cache
    - .default-only
    - .default-before_script
25
    - .only:changes-code-backstage
26
27

.only-code-qa-rails-job-base:
Philippe Lafoucrière's avatar
Philippe Lafoucrière committed
28
  extends:
Stan Hu's avatar
Stan Hu committed
29
30
31
    - .default-tags
    - .default-retry
    - .default-cache
32
    - .default-only
Stan Hu's avatar
Stan Hu committed
33
    - .default-before_script
34
    - .only:changes-code-backstage-qa
35

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
setup-test-env:
  extends:
    - .only-code-qa-rails-job-base
    - .use-pg9
  stage: prepare
  script:
    - bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init'
    - scripts/gitaly-test-build  # Do not use 'bundle exec' here
  artifacts:
    expire_in: 7d
    paths:
      - tmp/tests
      - config/secrets.yml
      - vendor/gitaly-ruby
  cache:
    policy: pull-push

53
54
.rspec-base:
  extends: .only-code-rails-job-base
Kamil Trzciński's avatar
Kamil Trzciński committed
55
  stage: test
56
57
  needs: ["setup-test-env", "retrieve-tests-metadata", "compile-assets pull-cache"]
  dependencies: ["setup-test-env", "retrieve-tests-metadata", "compile-assets pull-cache"]
Kamil Trzciński's avatar
Kamil Trzciński committed
58
  script:
59
60
    - source scripts/rspec_helpers.sh
    - rspec_paralellized_job "--tag ~quarantine --tag ~geo"
Kamil Trzciński's avatar
Kamil Trzciński committed
61
62
63
64
65
66
67
68
69
  artifacts:
    expire_in: 31d
    when: always
    paths:
      - coverage/
      - knapsack/
      - rspec_flaky/
      - rspec_profiling/
      - tmp/capybara/
70
      - tmp/memory_test/
Steve Azzopardi's avatar
Steve Azzopardi committed
71
72
    reports:
      junit: junit_rspec.xml
Kamil Trzciński's avatar
Kamil Trzciński committed
73

74
75
76
77
78
.rspec-base-foss:
  extends: [".rspec-base", ".only-ee-as-if-foss"]
  needs: ["setup-test-env", "retrieve-tests-metadata", "compile-assets pull-cache foss"]
  dependencies: ["setup-test-env", "retrieve-tests-metadata", "compile-assets pull-cache foss"]

79
.rspec-base-pg9:
Stan Hu's avatar
Stan Hu committed
80
81
  extends:
    - .rspec-base
82
    - .use-pg9
Kamil Trzciński's avatar
Kamil Trzciński committed
83

84
85
.rspec-base-pg9-foss:
  extends:
86
    - .rspec-base-foss
87
88
    - .use-pg9

89
.rspec-base-pg10:
Stan Hu's avatar
Stan Hu committed
90
91
  extends:
    - .rspec-base
92
93
    - .use-pg10
    - .only-master
Kamil Trzciński's avatar
Kamil Trzciński committed
94

95
96
97
98
99
100
101
102
rspec migration pg9:
  extends: .rspec-base-pg9
  parallel: 4

rspec migration pg9-foss:
  extends: .rspec-base-pg9-foss
  parallel: 4

103
104
rspec unit pg9:
  extends: .rspec-base-pg9
105
  parallel: 20
106

107
108
rspec unit pg9-foss:
  extends: .rspec-base-pg9-foss
109
  parallel: 20
110

111
112
113
rspec integration pg9:
  extends: .rspec-base-pg9
  parallel: 6
Kamil Trzciński's avatar
Kamil Trzciński committed
114

115
116
117
118
rspec integration pg9-foss:
  extends: .rspec-base-pg9-foss
  parallel: 6

119
120
121
122
rspec system pg9:
  extends: .rspec-base-pg9
  parallel: 24

123
124
125
rspec system pg9-foss:
  extends: .rspec-base-pg9-foss
  parallel: 24
126

127
128
rspec unit pg10:
  extends: .rspec-base-pg10
129
  parallel: 20
Kamil Trzciński's avatar
Kamil Trzciński committed
130

131
132
rspec integration pg10:
  extends: .rspec-base-pg10
133
134
  parallel: 6

135
136
rspec system pg10:
  extends: .rspec-base-pg10
137
138
  parallel: 24

139
140
141
142
143
144
145
146
147
148
149
150
.rspec-ee-base-pg9:
  extends:
    - .rspec-base
    - .only-ee
    - .use-pg9-ee

.rspec-ee-base-pg10:
  extends:
    - .rspec-base
    - .only-ee
    - .use-pg10-ee

151
152
153
154
rspec-ee migration pg9:
  extends: .rspec-ee-base-pg9
  parallel: 2

155
156
rspec-ee unit pg9:
  extends: .rspec-ee-base-pg9
157
  parallel: 5
158
159
160
161
162
163
164
165
166

rspec-ee integration pg9:
  extends: .rspec-ee-base-pg9
  parallel: 3

rspec-ee system pg9:
  extends: .rspec-ee-base-pg9
  parallel: 5

167
168
169
170
171
172
rspec-ee migration pg10:
  extends:
    - .rspec-ee-base-pg10
    - .only-master
  parallel: 2

173
rspec-ee unit pg10:
Stan Hu's avatar
Stan Hu committed
174
  extends:
175
    - .rspec-ee-base-pg10
176
    - .only-master
177
  parallel: 5
178

179
rspec-ee integration pg10:
Stan Hu's avatar
Stan Hu committed
180
  extends:
181
    - .rspec-ee-base-pg10
182
    - .only-master
183
  parallel: 3
184

185
rspec-ee system pg10:
Stan Hu's avatar
Stan Hu committed
186
  extends:
187
    - .rspec-ee-base-pg10
188
    - .only-master
189
  parallel: 5
190

191
192
193
194
.rspec-ee-base-geo:
  extends:
    - .rspec-base
    - .only-ee
Kamil Trzciński's avatar
Kamil Trzciński committed
195
  script:
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
    - source scripts/rspec_helpers.sh
    - scripts/prepare_postgres_fdw.sh
    - rspec_paralellized_job "--tag ~quarantine --tag geo"

.rspec-ee-base-geo-pg9:
  extends:
    - .rspec-ee-base-geo
    - .use-pg9-ee

.rspec-ee-base-geo-pg10:
  extends:
    - .rspec-ee-base-geo
    - .use-pg10-ee

rspec-ee unit pg9 geo:
  extends: .rspec-ee-base-geo-pg9
  parallel: 2

rspec-ee integration pg9 geo:
  extends: .rspec-ee-base-geo-pg9
Kamil Trzciński's avatar
Kamil Trzciński committed
216

217
218
219
220
221
222
223
224
225
226
227
228
229
230
rspec-ee system pg9 geo:
  extends: .rspec-ee-base-geo-pg9

rspec-ee unit pg10 geo:
  extends: .rspec-ee-base-geo-pg10
  parallel: 2

rspec-ee integration pg10 geo:
  extends: .rspec-ee-base-geo-pg10

rspec-ee system pg10 geo:
  extends: .rspec-ee-base-geo-pg10

rspec quarantine pg9:
Stan Hu's avatar
Stan Hu committed
231
  extends:
232
    - .rspec-base-pg9
233
    - .only-master
234
235
  variables:
    RSPEC_OPTS: "--tag quarantine -- spec/"
Kamil Trzciński's avatar
Kamil Trzciński committed
236
  script:
237
238
    - source scripts/rspec_helpers.sh
    - rspec_simple_job "${RSPEC_OPTS}"
Kamil Trzciński's avatar
Kamil Trzciński committed
239
240
  allow_failure: true

241
242
243
244
245
246
247
248
249
250
251
252
rspec-ee quarantine pg9:
  extends:
    - rspec quarantine pg9
    - .only-ee
  variables:
    RSPEC_OPTS: "--tag quarantine -- ee/spec/"

rspec fast_spec_helper:
  extends: .rspec-base-pg9
  script:
    - bin/rspec spec/fast_spec_helper.rb

Kamil Trzciński's avatar
Kamil Trzciński committed
253
static-analysis:
254
  extends: .only-code-qa-rails-job-base
255
256
257
  stage: test
  needs: ["setup-test-env", "compile-assets pull-cache"]
  dependencies: ["setup-test-env", "compile-assets pull-cache"]
Stan Hu's avatar
Stan Hu committed
258
259
  variables:
    SETUP_DB: "false"
260
  parallel: 2
Kamil Trzciński's avatar
Kamil Trzciński committed
261
262
263
  script:
    - scripts/static-analysis
  cache:
Stan Hu's avatar
Stan Hu committed
264
    key: "debian-stretch-ruby-2.6.3-and-rubocop"
Kamil Trzciński's avatar
Kamil Trzciński committed
265
266
267
268
269
270
    paths:
      - vendor/ruby
      - tmp/rubocop_cache
    policy: pull-push

downtime_check:
271
272
  extends:
    - .rake-exec
273
    - .only:changes-code-backstage
274
    - .except:refs-master-tags-stable-deploy
275
276
  stage: test
  needs: ["setup-test-env"]
277
  dependencies: ["setup-test-env"]
Kamil Trzciński's avatar
Kamil Trzciński committed
278

279
.db-job-base:
Stan Hu's avatar
Stan Hu committed
280
  extends:
281
    - .only-code-rails-job-base
282
    - .use-pg9
283
284
  stage: test
  needs: ["setup-test-env"]
285
  dependencies: ["setup-test-env"]
286
287
288
289

# DB migration, rollback, and seed jobs
db:migrate:reset:
  extends: .db-job-base
Stan Hu's avatar
Stan Hu committed
290
291
  script:
    - bundle exec rake db:migrate:reset
Kamil Trzciński's avatar
Kamil Trzciński committed
292

Stan Hu's avatar
Stan Hu committed
293
db:check-schema:
294
  extends: .db-job-base
Kamil Trzciński's avatar
Kamil Trzciński committed
295
296
297
  script:
    - source scripts/schema_changed.sh

Stan Hu's avatar
Stan Hu committed
298
db:migrate-from-v11.11.0:
299
  extends: .db-job-base
Stan Hu's avatar
Stan Hu committed
300
301
302
  variables:
    SETUP_DB: "false"
  script:
303
304
305
306
307
    - export PROJECT_TO_CHECKOUT="gitlab-foss"
    - export TAG_TO_CHECKOUT="v11.11.0"
    - '[[ ! -d "ee/" ]] || export PROJECT_TO_CHECKOUT="gitlab"'
    - '[[ ! -d "ee/" ]] || export TAG_TO_CHECKOUT="v11.11.0-ee"'
    - git fetch https://gitlab.com/gitlab-org/$PROJECT_TO_CHECKOUT.git $TAG_TO_CHECKOUT
Stan Hu's avatar
Stan Hu committed
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
    - git checkout -f FETCH_HEAD
    - sed -i "s/gem 'oj', '~> 2.17.4'//" Gemfile
    - sed -i "s/gem 'bootsnap', '~> 1.0.0'/gem 'bootsnap'/" Gemfile
    - bundle update google-protobuf grpc bootsnap
    - bundle install $BUNDLE_INSTALL_FLAGS
    - date
    - cp config/gitlab.yml.example config/gitlab.yml
    - bundle exec rake db:drop db:create db:schema:load db:seed_fu
    - date
    - git checkout -f $CI_COMMIT_SHA
    - bundle install $BUNDLE_INSTALL_FLAGS
    - date
    - . scripts/prepare_build.sh
    - date
    - bundle exec rake db:migrate
Kamil Trzciński's avatar
Kamil Trzciński committed
323

Stan Hu's avatar
Stan Hu committed
324
db:rollback:
325
  extends: .db-job-base
Kamil Trzciński's avatar
Kamil Trzciński committed
326
  script:
327
    - bundle exec rake db:migrate VERSION=20180101160629
328
    - bundle exec rake db:migrate SKIP_SCHEMA_VERSION_CHECK=true
Kamil Trzciński's avatar
Kamil Trzciński committed
329

Stan Hu's avatar
Stan Hu committed
330
gitlab:setup:
331
  extends: .db-job-base
Stan Hu's avatar
Stan Hu committed
332
333
334
335
336
337
338
339
340
341
342
343
344
345
  variables:
    SETUP_DB: "false"
  script:
    # Manually clone gitlab-test and only seed this project in
    # db/fixtures/development/04_project.rb thanks to SIZE=1 below
    - git clone https://gitlab.com/gitlab-org/gitlab-test.git
       /home/git/repositories/gitlab-org/gitlab-test.git
    - scripts/gitaly-test-spawn
    - force=yes SIZE=1 FIXTURE_PATH="db/fixtures/development" bundle exec rake gitlab:setup
  artifacts:
    when: on_failure
    expire_in: 1d
    paths:
      - log/development.log
Kamil Trzciński's avatar
Kamil Trzciński committed
346
347

coverage:
348
  extends: .only-code-rails-job-base
Kamil Trzciński's avatar
Kamil Trzciński committed
349
350
351
352
353
354
355
  cache:
    policy: pull
  variables:
    SETUP_DB: "false"
  stage: post-test
  script:
    - bundle exec scripts/merge-simplecov
356
    - bundle exec scripts/gather-test-memory-data
Kamil Trzciński's avatar
Kamil Trzciński committed
357
358
359
360
361
  coverage: '/LOC \((\d+\.\d+%)\) covered.$/'
  artifacts:
    name: coverage
    expire_in: 31d
    paths:
Kamil Trzciński's avatar
Kamil Trzciński committed
362
363
      - coverage/index.html
      - coverage/assets/
364
      - tmp/memory_test/
365
366
367
368

db:rollback geo:
  extends:
    - db:rollback
369
    - .only-ee
370
371
372
  script:
    - bundle exec rake geo:db:migrate VERSION=20170627195211
    - bundle exec rake geo:db:migrate