.gitlab-ci.yml 23.8 KB
Newer Older
1
image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.7-golang-1.9-git-2.17-chrome-65.0-node-8.x-yarn-1.2-postgresql-9.6"
2

3 4 5 6 7
.dedicated-runner: &dedicated-runner
  retry: 1
  tags:
    - gitlab-org

8
.default-cache: &default-cache
9
  key: "ruby-2.3.7-with-yarn"
10
  paths:
11 12 13 14 15 16 17 18 19 20 21 22
    - vendor/ruby
    - .yarn-cache/

.push-cache: &push-cache
  cache:
    <<: *default-cache
    policy: push

.pull-cache: &pull-cache
  cache:
    <<: *default-cache
    policy: pull
23

24 25
variables:
  MYSQL_ALLOW_EMPTY_PASSWORD: "1"
Kamil Trzcinski's avatar
Kamil Trzcinski committed
26
  RAILS_ENV: "test"
Mike Greiling's avatar
Mike Greiling committed
27
  NODE_ENV: "test"
Kamil Trzcinski's avatar
Kamil Trzcinski committed
28
  SIMPLECOV: "true"
29
  GIT_DEPTH: "20"
30
  GIT_SUBMODULE_STRATEGY: "none"
31
  GET_SOURCES_ATTEMPTS: "3"
32
  KNAPSACK_RSPEC_SUITE_REPORT_PATH: knapsack/${CI_PROJECT_NAME}/rspec_report-master.json
33
  FLAKY_RSPEC_SUITE_REPORT_PATH: rspec_flaky/report-suite.json
34

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
35
before_script:
Kamil Trzcinski's avatar
Test  
Kamil Trzcinski committed
36
  - bundle --version
37
  - date
38
  - source scripts/utils.sh
39
  - date
40
  - source scripts/prepare_build.sh
41 42 43 44
  - date

after_script:
  - date
45

Kamil Trzcinski's avatar
Kamil Trzcinski committed
46
stages:
47 48 49 50 51
  - build
  - prepare
  - test
  - post-test
  - pages
52
  - post-cleanup
53

54
# Predefined scopes
55
.tests-metadata-state: &tests-metadata-state
56
  <<: *dedicated-runner
57
  variables:
58
    TESTS_METADATA_S3_BUCKET: "gitlab-ce-cache"
59 60
  before_script:
    - source scripts/utils.sh
61 62 63
  artifacts:
    expire_in: 31d
    paths:
64
      - knapsack/
65
      - rspec_flaky/
66

67 68
.use-pg: &use-pg
  services:
69 70 71
    # As of Jan 2018, we don't have a strong reason to upgrade to 9.6 for CI yet,
    # so using the least common denominator ensures backwards compatibility
    # (as many users are still using 9.2).
72
    - postgres:9.2
73 74 75
    - redis:alpine

.use-mysql: &use-mysql
76
  services:
77
    - mysql:5.7
78
    - redis:alpine
79

80 81 82 83 84 85 86 87 88 89 90 91 92
.rails5-variables: &rails5-variables
  script:
    - export RAILS5=${RAILS5}
    - export BUNDLE_GEMFILE=${BUNDLE_GEMFILE}

.rails5: &rails5
  allow_failure: true
  only:
    - /rails5/
  variables:
    BUNDLE_GEMFILE: "Gemfile.rails5"
    RAILS5: "true"

93 94 95
# Skip all jobs except the ones that begin with 'docs/'.
# Used for commits including ONLY documentation changes.
# https://docs.gitlab.com/ce/development/writing_documentation.html#testing
96 97
.except-docs: &except-docs
  except:
98
    - /(^docs[\/-].*|.*-docs$)/
99

100 101 102 103
.except-qa: &except-qa
  except:
    - /(^qa[\/-].*|.*-qa$)/

104 105 106 107 108
.except-docs-and-qa: &except-docs-and-qa
  except:
    - /(^docs[\/-].*|.*-docs$)/
    - /(^qa[\/-].*|.*-qa$)/

109 110 111
# Jobs that only need to pull cache
.dedicated-no-docs-pull-cache-job: &dedicated-no-docs-pull-cache-job
  <<: *dedicated-runner
112
  <<: *except-docs
113 114 115 116 117 118 119 120 121 122 123
  <<: *pull-cache
  dependencies:
    - setup-test-env
  stage: test

# Jobs that do not need a DB
.dedicated-no-docs-no-db-pull-cache-job: &dedicated-no-docs-no-db-pull-cache-job
  <<: *dedicated-no-docs-pull-cache-job
  variables:
    SETUP_DB: "false"

124 125 126 127
.dedicated-no-docs-and-no-qa-pull-cache-job: &dedicated-no-docs-and-no-qa-pull-cache-job
  <<: *dedicated-no-docs-pull-cache-job
  <<: *except-docs-and-qa

128 129 130 131 132
.rake-exec: &rake-exec
  <<: *dedicated-no-docs-no-db-pull-cache-job
  script:
    - bundle exec rake $CI_JOB_NAME

133
.rspec-metadata: &rspec-metadata
134
  <<: *dedicated-runner
135
  <<: *except-docs-and-qa
136
  <<: *pull-cache
137
  <<: *rails5-variables
138
  stage: test
139
  script:
140
    - JOB_NAME=( $CI_JOB_NAME )
141 142
    - export CI_NODE_INDEX=${JOB_NAME[-2]}
    - export CI_NODE_TOTAL=${JOB_NAME[-1]}
143
    - export KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/${JOB_NAME[0]}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
144
    - export KNAPSACK_GENERATE_REPORT=true
145 146 147
    - export SUITE_FLAKY_RSPEC_REPORT_PATH=${FLAKY_RSPEC_SUITE_REPORT_PATH}
    - export FLAKY_RSPEC_REPORT_PATH=rspec_flaky/all_${JOB_NAME[0]}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
    - export NEW_FLAKY_RSPEC_REPORT_PATH=rspec_flaky/new_${JOB_NAME[0]}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
148
    - export FLAKY_RSPEC_GENERATE_REPORT=true
149
    - export CACHE_CLASSES=true
150
    - cp ${KNAPSACK_RSPEC_SUITE_REPORT_PATH} ${KNAPSACK_REPORT_PATH}
151
    - '[[ -f $FLAKY_RSPEC_REPORT_PATH ]] || echo "{}" > ${FLAKY_RSPEC_REPORT_PATH}'
152
    - '[[ -f $NEW_FLAKY_RSPEC_REPORT_PATH ]] || echo "{}" > ${NEW_FLAKY_RSPEC_REPORT_PATH}'
Jacob Vosmaer's avatar
Jacob Vosmaer committed
153
    - scripts/gitaly-test-spawn
154 155 156
    - knapsack rspec "--color --format documentation"
  artifacts:
    expire_in: 31d
157
    when: always
158
    paths:
159 160
      - coverage/
      - knapsack/
161
      - rspec_flaky/
162
      - tmp/capybara/
163

164 165
.rspec-metadata-pg: &rspec-metadata-pg
  <<: *rspec-metadata
166 167
  <<: *use-pg

168 169 170 171
.rspec-metadata-pg-rails5: &rspec-metadata-pg-rails5
  <<: *rspec-metadata-pg
  <<: *rails5

172 173
.rspec-metadata-mysql: &rspec-metadata-mysql
  <<: *rspec-metadata
174 175
  <<: *use-mysql

176 177 178 179
.rspec-metadata-mysql-rails5: &rspec-metadata-mysql-rails5
  <<: *rspec-metadata-mysql
  <<: *rails5

180 181 182 183 184 185 186
.only-canonical-masters: &only-canonical-masters
  only:
    - master@gitlab-org/gitlab-ce
    - master@gitlab-org/gitlab-ee
    - master@gitlab/gitlabhq
    - master@gitlab/gitlab-ee

187
.gitlab-setup: &gitlab-setup
188
  <<: *dedicated-no-docs-and-no-qa-pull-cache-job
189 190 191
  <<: *use-pg
  variables:
    CREATE_DB_USER: "true"
192
  script:
193 194 195 196 197 198 199 200 201 202 203
    # 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
204

205 206
# Review docs base
.review-docs: &review-docs
207
  <<: *dedicated-runner
208
  <<: *except-qa
209
  image: ruby:2.4-alpine
210 211
  before_script:
    - gem install gitlab --no-doc
212 213 214 215 216 217 218 219
    # We need to download the script rather than clone the repo since the
    # review-docs-cleanup job will not be able to run when the branch gets
    # deleted (when merging the MR).
    - apk add --update openssl
    - wget https://gitlab.com/gitlab-org/gitlab-ce/raw/master/scripts/trigger-build-docs
    - chmod 755 trigger-build-docs
  cache: {}
  dependencies: []
220
  variables:
221
    GIT_STRATEGY: none
222 223 224 225
  when: manual
  only:
    - branches

226 227
# DB migration, rollback, and seed jobs
.db-migrate-reset: &db-migrate-reset
228
  <<: *dedicated-no-docs-and-no-qa-pull-cache-job
229 230 231 232
  script:
    - bundle exec rake db:migrate:reset

.migration-paths: &migration-paths
233
  <<: *dedicated-no-docs-and-no-qa-pull-cache-job
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
  variables:
    CREATE_DB_USER: "true"
  script:
    - git fetch https://gitlab.com/gitlab-org/gitlab-ce.git v9.3.0
    - git checkout -f FETCH_HEAD
    - 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 $CI_COMMIT_SHA
    - bundle install $BUNDLE_INSTALL_FLAGS
    - date
    - . scripts/prepare_build.sh
    - date
    - bundle exec rake db:migrate

##
# Trigger a package build in omnibus-gitlab repository
#
254
package-and-qa:
255 256 257 258 259
  image: ruby:2.4-alpine
  before_script: []
  stage: build
  cache: {}
  when: manual
260 261
  variables:
    GIT_STRATEGY: none
262
  retry: 0
263 264 265 266 267
  before_script:
    # We need to download the script rather than clone the repo since the
    # package-and-qa job will not be able to run when the branch gets
    # deleted (when merging the MR).
    - apk add --update openssl
268
    - wget https://gitlab.com/$CI_PROJECT_PATH/raw/$CI_COMMIT_SHA/scripts/trigger-build-omnibus
269
    - chmod 755 trigger-build-omnibus
270
  script:
271
    - ./trigger-build-omnibus
272 273 274 275
  only:
    - //@gitlab-org/gitlab-ce
    - //@gitlab-org/gitlab-ee

276 277 278 279 280 281 282
# Trigger a docs build in gitlab-docs
# Useful to preview the docs changes live
review-docs-deploy:
  <<: *review-docs
  stage: build
  environment:
    name: review-docs/$CI_COMMIT_REF_NAME
283 284
    # DOCS_REVIEW_APPS_DOMAIN and DOCS_GITLAB_REPO_SUFFIX are secret variables
    # Discussion: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14236/diffs#note_40140693
285
    url: http://$DOCS_GITLAB_REPO_SUFFIX-$CI_COMMIT_REF_SLUG.$DOCS_REVIEW_APPS_DOMAIN/$DOCS_GITLAB_REPO_SUFFIX
286 287
    on_stop: review-docs-cleanup
  script:
288
    - ./trigger-build-docs deploy
289 290 291 292 293 294 295 296 297

# Cleanup remote environment of gitlab-docs
review-docs-cleanup:
  <<: *review-docs
  stage: post-cleanup
  environment:
    name: review-docs/$CI_COMMIT_REF_NAME
    action: stop
  script:
298
    - ./trigger-build-docs cleanup
299

300 301 302
# Retrieve knapsack and rspec_flaky reports
retrieve-tests-metadata:
  <<: *tests-metadata-state
303
  <<: *except-docs-and-qa
304
  stage: prepare
305
  cache:
306
    key: tests_metadata
307
    policy: pull
308
  script:
309
    - mkdir -p knapsack/${CI_PROJECT_NAME}/
310
    - wget -O $KNAPSACK_RSPEC_SUITE_REPORT_PATH http://${TESTS_METADATA_S3_BUCKET}.s3.amazonaws.com/$KNAPSACK_RSPEC_SUITE_REPORT_PATH || rm $KNAPSACK_RSPEC_SUITE_REPORT_PATH
311
    - '[[ -f $KNAPSACK_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_RSPEC_SUITE_REPORT_PATH}'
312
    - mkdir -p rspec_flaky/
313 314
    - wget -O $FLAKY_RSPEC_SUITE_REPORT_PATH http://${TESTS_METADATA_S3_BUCKET}.s3.amazonaws.com/$FLAKY_RSPEC_SUITE_REPORT_PATH || rm $FLAKY_RSPEC_SUITE_REPORT_PATH
    - '[[ -f $FLAKY_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${FLAKY_RSPEC_SUITE_REPORT_PATH}'
315

316 317
update-tests-metadata:
  <<: *tests-metadata-state
318
  <<: *only-canonical-masters
319
  stage: post-test
320
  cache:
321
    key: tests_metadata
322 323
    paths:
      - knapsack/
324
      - rspec_flaky/
325
    policy: push
326
  script:
327
    - retry gem install fog-aws mime-types activesupport
328
    - scripts/merge-reports ${KNAPSACK_RSPEC_SUITE_REPORT_PATH} knapsack/${CI_PROJECT_NAME}/rspec-pg_node_*.json
329
    - scripts/merge-reports ${FLAKY_RSPEC_SUITE_REPORT_PATH} rspec_flaky/all_*_*.json
330
    - FLAKY_RSPEC_GENERATE_REPORT=1 scripts/prune-old-flaky-specs ${FLAKY_RSPEC_SUITE_REPORT_PATH}
blackst0ne's avatar
blackst0ne committed
331
    - '[[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $KNAPSACK_RSPEC_SUITE_REPORT_PATH'
332
    - '[[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $FLAKY_RSPEC_SUITE_REPORT_PATH'
333
    - rm -f knapsack/${CI_PROJECT_NAME}/*_node_*.json
334
    - rm -f rspec_flaky/all_*.json rspec_flaky/new_*.json
335 336 337

flaky-examples-check:
  <<: *dedicated-runner
338
  image: ruby:2.4-alpine
339 340 341 342 343
  services: []
  before_script: []
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "false"
344
    NEW_FLAKY_SPECS_REPORT: rspec_flaky/report-new.json
345
  stage: post-test
346
  allow_failure: true
347
  retry: 0
348 349 350 351
  only:
    - branches
  except:
    - master
352
    - /(^docs[\/-].*|.*-docs$)/
353
    - /(^qa[\/-].*|.*-qa$)/
354 355 356 357 358 359
  artifacts:
    expire_in: 30d
    paths:
      - rspec_flaky/
  script:
    - '[[ -f $NEW_FLAKY_SPECS_REPORT ]] || echo "{}" > ${NEW_FLAKY_SPECS_REPORT}'
360
    - scripts/merge-reports ${NEW_FLAKY_SPECS_REPORT} rspec_flaky/new_*_*.json
361
    - scripts/detect-new-flaky-examples $NEW_FLAKY_SPECS_REPORT
362

363
compile-assets:
364
  <<: *dedicated-runner
365
  <<: *except-docs
366
  <<: *use-pg
367
  stage: prepare
368 369
  cache:
    <<: *default-cache
370
  script:
371
    - node --version
372
    - date
373
    - yarn install --frozen-lockfile --cache-folder .yarn-cache
374
    - date
Mike Greiling's avatar
Mike Greiling committed
375
    - bundle exec rake gitlab:assets:compile
376 377 378
  artifacts:
    expire_in: 7d
    paths:
379
      - node_modules
380
      - public/assets
381 382 383 384 385 386 387 388 389 390 391 392 393 394

setup-test-env:
  <<: *dedicated-runner
  <<: *except-docs
  <<: *use-pg
  stage: prepare
  cache:
    <<: *default-cache
  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:
395
      - tmp/tests
396
      - config/secrets.yml
397

398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
rspec-pg 0 28: *rspec-metadata-pg
rspec-pg 1 28: *rspec-metadata-pg
rspec-pg 2 28: *rspec-metadata-pg
rspec-pg 3 28: *rspec-metadata-pg
rspec-pg 4 28: *rspec-metadata-pg
rspec-pg 5 28: *rspec-metadata-pg
rspec-pg 6 28: *rspec-metadata-pg
rspec-pg 7 28: *rspec-metadata-pg
rspec-pg 8 28: *rspec-metadata-pg
rspec-pg 9 28: *rspec-metadata-pg
rspec-pg 10 28: *rspec-metadata-pg
rspec-pg 11 28: *rspec-metadata-pg
rspec-pg 12 28: *rspec-metadata-pg
rspec-pg 13 28: *rspec-metadata-pg
rspec-pg 14 28: *rspec-metadata-pg
rspec-pg 15 28: *rspec-metadata-pg
rspec-pg 16 28: *rspec-metadata-pg
rspec-pg 17 28: *rspec-metadata-pg
rspec-pg 18 28: *rspec-metadata-pg
rspec-pg 19 28: *rspec-metadata-pg
rspec-pg 20 28: *rspec-metadata-pg
rspec-pg 21 28: *rspec-metadata-pg
rspec-pg 22 28: *rspec-metadata-pg
rspec-pg 23 28: *rspec-metadata-pg
rspec-pg 24 28: *rspec-metadata-pg
rspec-pg 25 28: *rspec-metadata-pg
rspec-pg 26 28: *rspec-metadata-pg
rspec-pg 27 28: *rspec-metadata-pg

rspec-mysql 0 28: *rspec-metadata-mysql
rspec-mysql 1 28: *rspec-metadata-mysql
rspec-mysql 2 28: *rspec-metadata-mysql
rspec-mysql 3 28: *rspec-metadata-mysql
rspec-mysql 4 28: *rspec-metadata-mysql
rspec-mysql 5 28: *rspec-metadata-mysql
rspec-mysql 6 28: *rspec-metadata-mysql
rspec-mysql 7 28: *rspec-metadata-mysql
rspec-mysql 8 28: *rspec-metadata-mysql
rspec-mysql 9 28: *rspec-metadata-mysql
rspec-mysql 10 28: *rspec-metadata-mysql
rspec-mysql 11 28: *rspec-metadata-mysql
rspec-mysql 12 28: *rspec-metadata-mysql
rspec-mysql 13 28: *rspec-metadata-mysql
rspec-mysql 14 28: *rspec-metadata-mysql
rspec-mysql 15 28: *rspec-metadata-mysql
rspec-mysql 16 28: *rspec-metadata-mysql
rspec-mysql 17 28: *rspec-metadata-mysql
rspec-mysql 18 28: *rspec-metadata-mysql
rspec-mysql 19 28: *rspec-metadata-mysql
rspec-mysql 20 28: *rspec-metadata-mysql
rspec-mysql 21 28: *rspec-metadata-mysql
rspec-mysql 22 28: *rspec-metadata-mysql
rspec-mysql 23 28: *rspec-metadata-mysql
rspec-mysql 24 28: *rspec-metadata-mysql
rspec-mysql 25 28: *rspec-metadata-mysql
rspec-mysql 26 28: *rspec-metadata-mysql
rspec-mysql 27 28: *rspec-metadata-mysql

456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
rspec-pg-rails5 0 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 1 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 2 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 3 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 4 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 5 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 6 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 7 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 8 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 9 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 10 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 11 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 12 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 13 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 14 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 15 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 16 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 17 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 18 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 19 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 20 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 21 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 22 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 23 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 24 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 25 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 26 28: *rspec-metadata-pg-rails5
rspec-pg-rails5 27 28: *rspec-metadata-pg-rails5

rspec-mysql-rails5 0 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 1 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 2 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 3 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 4 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 5 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 6 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 7 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 8 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 9 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 10 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 11 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 12 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 13 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 14 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 15 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 16 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 17 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 18 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 19 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 20 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 21 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 22 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 23 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 24 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 25 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 26 28: *rspec-metadata-mysql-rails5
rspec-mysql-rails5 27 28: *rspec-metadata-mysql-rails5

514
static-analysis:
515 516 517 518
  <<: *dedicated-no-docs-no-db-pull-cache-job
  dependencies:
    - compile-assets
    - setup-test-env
519
  script:
520
    - scripts/static-analysis
Lin Jen-Shin's avatar
Lin Jen-Shin committed
521
  cache:
522
    key: "ruby-2.3.7-with-yarn-and-rubocop"
Lin Jen-Shin's avatar
Lin Jen-Shin committed
523 524 525 526
    paths:
      - vendor/ruby
      - .yarn-cache/
      - tmp/rubocop_cache
527

528 529 530 531
# Documentation checks:
# - Check validity of relative links
# - Make sure cURL examples in API docs use the full switches
docs lint:
532
  <<: *dedicated-runner
533
  <<: *except-qa
534 535 536 537 538 539
  image: "registry.gitlab.com/gitlab-org/gitlab-build-images:nanoc-bootstrap-ruby-2.4-alpine"
  stage: test
  cache: {}
  dependencies: []
  before_script: []
  script:
540
    - scripts/lint-doc.sh
541
    - scripts/lint-changelog-yaml
542 543 544 545 546 547 548
    - mv doc/ /nanoc/content/
    - cd /nanoc
    # Build HTML from Markdown
    - bundle exec nanoc
    # Check the internal links
    - bundle exec nanoc check internal_links

549 550
downtime_check:
  <<: *rake-exec
551 552 553 554
  except:
    - master
    - tags
    - /^[\d-]+-stable(-ee)?$/
555
    - /(^docs[\/-].*|.*-docs$)/
556
    - /(^qa[\/-].*|.*-qa$)/
557

558 559
ee_compat_check:
  <<: *rake-exec
560 561 562
  except:
    - master
    - tags
563
    - /^[\d-]+-stable(-ee)?/
564
    - /^security-/
565 566
    - branches@gitlab-org/gitlab-ee
    - branches@gitlab/gitlab-ee
567
  retry: 0
568
  artifacts:
569
    name: "${CI_JOB_NAME}_${CI_COMIT_REF_NAME}_${CI_COMMIT_SHA}"
570
    when: always
571 572 573 574
    expire_in: 10d
    paths:
      - ee_compat_check/patches/*.patch

575
db:migrate:reset-pg:
576 577 578
  <<: *db-migrate-reset
  <<: *use-pg

579
db:migrate:reset-mysql:
580 581 582
  <<: *db-migrate-reset
  <<: *use-mysql

583 584 585 586 587 588
db:check-schema-pg:
  <<: *db-migrate-reset
  <<: *use-pg
  script:
    - source scripts/schema_changed.sh

589 590 591 592 593 594 595 596
migration:path-pg:
  <<: *migration-paths
  <<: *use-pg

migration:path-mysql:
  <<: *migration-paths
  <<: *use-mysql

597
.db-rollback: &db-rollback
598
  <<: *dedicated-no-docs-and-no-qa-pull-cache-job
599
  script:
600
    - bundle exec rake db:migrate VERSION=20170523121229
601
    - bundle exec rake db:migrate
602

603
db:rollback-pg:
604 605 606
  <<: *db-rollback
  <<: *use-pg

607
db:rollback-mysql:
608 609 610
  <<: *db-rollback
  <<: *use-mysql

611 612
gitlab:setup-pg:
  <<: *gitlab-setup
613 614
  <<: *use-pg

615 616
gitlab:setup-mysql:
  <<: *gitlab-setup
617 618
  <<: *use-mysql

619
# Frontend-related jobs
620
gitlab:assets:compile:
621
  <<: *dedicated-no-docs-and-no-qa-pull-cache-job
622 623 624 625 626 627
  dependencies: []
  variables:
    NODE_ENV: "production"
    RAILS_ENV: "production"
    SETUP_DB: "false"
    SKIP_STORAGE_VALIDATION: "true"
628
    WEBPACK_REPORT: "true"
Mike Greiling's avatar
Mike Greiling committed
629
    NO_COMPRESSION: "true"
630
  script:
631
    - date
632
    - yarn install --frozen-lockfile --production --cache-folder .yarn-cache
633
    - date
634
    - bundle exec rake gitlab:assets:compile
635 636 637 638
  artifacts:
    name: webpack-report
    expire_in: 31d
    paths:
639
      - webpack-report/
640

641
karma:
642
  <<: *dedicated-no-docs-and-no-qa-pull-cache-job
643
  <<: *use-pg
644 645 646
  dependencies:
    - compile-assets
    - setup-test-env
647
  script:
648
    - export BABEL_ENV=coverage CHROME_LOG_FILE=chrome_debug.log
649
    - date
Jacob Vosmaer's avatar
Jacob Vosmaer committed
650
    - scripts/gitaly-test-spawn
651
    - date
652
    - bundle exec rake karma
653
  coverage: '/^Statements *: (\d+\.\d+%)/'
654 655 656
  artifacts:
    name: coverage-javascript
    expire_in: 31d
657
    when: always
658
    paths:
659 660
      - chrome_debug.log
      - coverage-javascript/
661

662
codequality:
663
  <<: *dedicated-no-docs-no-db-pull-cache-job
664 665
  image: docker:stable
  allow_failure: true
666 667 668
  # gitlab-org runners set `privileged: false` but we need to have it set to true
  # since we're using Docker in Docker
  tags: []
669
  before_script: []
670
  services:
671
    - docker:stable-dind
672 673 674 675 676
  variables:
    SETUP_DB: "false"
    DOCKER_DRIVER: overlay2
  cache: {}
  dependencies: []
677
  script:
678 679 680
    # Extract "MAJOR.MINOR" from CI_SERVER_VERSION and generate "MAJOR-MINOR-stable" for Security Products
    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
    - docker run --env SOURCE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
681 682
  artifacts:
    paths: [codeclimate.json]
683
    expire_in: 1 week
684

685
sast:
686 687
  <<: *dedicated-no-docs-no-db-pull-cache-job
  image: docker:stable
688
  variables:
689 690 691 692
    SAST_CONFIDENCE_LEVEL: 2
    DOCKER_DRIVER: overlay2
  allow_failure: true
  tags: []
693
  before_script: []
694 695 696 697
  cache: {}
  dependencies: []
  services:
    - docker:stable-dind
698
  script:
699 700 701 702 703 704
    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
    - docker run
        --env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
        --volume "$PWD:/code"
        --volume /var/run/docker.sock:/var/run/docker.sock
        "registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
705 706 707
  artifacts:
    paths: [gl-sast-report.json]

708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
dependency_scanning:
  <<: *dedicated-no-docs-no-db-pull-cache-job
  image: docker:stable
  variables:
    DOCKER_DRIVER: overlay2
  allow_failure: true
  tags: []
  before_script: []
  cache: {}
  dependencies: []
  services:
    - docker:stable-dind
  script:
    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
    - docker run
        --env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
        --volume "$PWD:/code"
        --volume /var/run/docker.sock:/var/run/docker.sock
        "registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
  artifacts:
    paths: [gl-dependency-scanning-report.json]

730
qa:internal:
731
  <<: *dedicated-no-docs-no-db-pull-cache-job
732 733 734 735 736 737
  services: []
  script:
    - cd qa/
    - bundle install
    - bundle exec rspec

738
qa:selectors:
739
  <<: *dedicated-no-docs-no-db-pull-cache-job
740 741 742 743
  services: []
  script:
    - cd qa/
    - bundle install
744
    - bundle exec bin/qa Test::Sanity::Selectors
745

746
coverage:
747 748 749 750 751 752 753
  # Don't include dedicated-no-docs-no-db-pull-cache-job here since we need to
  # download artifacts from all the rspec jobs instead of from setup-test-env only
  <<: *dedicated-runner
  <<: *except-docs-and-qa
  <<: *pull-cache
  variables:
    SETUP_DB: "false"
754
  stage: post-test
755 756
  script:
    - bundle exec scripts/merge-simplecov
757
  coverage: '/LOC \((\d+\.\d+%)\) covered.$/'
758 759 760 761 762 763 764
  artifacts:
    name: coverage
    expire_in: 31d
    paths:
    - coverage/index.html
    - coverage/assets/

765
lint:javascript:report:
766
  <<: *dedicated-no-docs-and-no-qa-pull-cache-job
767
  stage: post-test
768
  dependencies:
769
    - compile-assets
770
    - setup-test-env
771
  before_script: []
772
  script:
773
    - date
774
    - find app/ spec/ -name '*.js' -exec sed --in-place 's|/\* eslint-disable .*\*/||' {} \; # run report over all files
775
    - date
776
    - yarn run eslint-report || true # ignore exit code
777 778 779 780
  artifacts:
    name: eslint-report
    expire_in: 31d
    paths:
781
      - eslint-report.html
782 783

pages:
784
  <<: *dedicated-no-docs-no-db-pull-cache-job
785 786 787 788
  before_script: []
  stage: pages
  dependencies:
    - coverage
789 790
    - karma
    - gitlab:assets:compile
791
    - lint:javascript:report
792 793 794
  script:
    - mv public/ .public/
    - mkdir public/
795
    - mv coverage/ public/coverage-ruby/ || true
796
    - mv coverage-javascript/ public/coverage-javascript/ || true
797
    - mv eslint-report.html public/ || true
798
    - mv webpack-report/ public/webpack-report/ || true
799 800 801 802
  artifacts:
    paths:
      - public
  only:
803
    - master@gitlab-org/gitlab-ce
804
    - master@gitlab-org/gitlab-ee
805 806 807 808

# Insurance in case a gem needed by one of our releases gets yanked from
# rubygems.org in the future.
cache gems:
809
  <<: *dedicated-no-docs-no-db-pull-cache-job
810 811 812 813 814
  script:
    - bundle package --all --all-platforms
  artifacts:
    paths:
      - vendor/cache
815 816
  only:
    - master@gitlab-org/gitlab-ce
817
    - master@gitlab-org/gitlab-ee
818
    - tags
819 820

gitlab_git_test:
821
  <<: *dedicated-runner
822
  <<: *except-docs-and-qa
823 824
  variables:
    SETUP_DB: "false"
825 826
  before_script: []
  cache: {}
827 828
  script:
    - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes