.gitlab-ci.yml 19.9 KB
Newer Older
1
image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.6-golang-1.9-git-2.14-chrome-63.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.6-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 33
  KNAPSACK_RSPEC_SUITE_REPORT_PATH: knapsack/${CI_PROJECT_NAME}/rspec_report-master.json
  KNAPSACK_SPINACH_SUITE_REPORT_PATH: knapsack/${CI_PROJECT_NAME}/spinach_report-master.json
34
  FLAKY_RSPEC_SUITE_REPORT_PATH: rspec_flaky/report-suite.json
35

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

Kamil Trzcinski's avatar
Kamil Trzcinski committed
41
stages:
42 43 44 45 46
  - build
  - prepare
  - test
  - post-test
  - pages
47
  - post-cleanup
48

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

62 63
.use-pg: &use-pg
  services:
64 65 66
    # 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).
67
    - postgres:9.2
68 69 70
    - redis:alpine

.use-mysql: &use-mysql
71 72 73
  services:
    - mysql:latest
    - redis:alpine
74

75 76 77
# 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
78 79
.except-docs: &except-docs
  except:
80
    - /(^docs[\/-].*|.*-docs$)/
81

82 83 84 85
.except-qa: &except-qa
  except:
    - /(^qa[\/-].*|.*-qa$)/

86 87 88 89 90
.except-docs-and-qa: &except-docs-and-qa
  except:
    - /(^docs[\/-].*|.*-docs$)/
    - /(^qa[\/-].*|.*-qa$)/

91
.rspec-metadata: &rspec-metadata
92
  <<: *dedicated-runner
93
  <<: *except-docs-and-qa
94
  <<: *pull-cache
95
  stage: test
96
  script:
97
    - JOB_NAME=( $CI_JOB_NAME )
98 99
    - export CI_NODE_INDEX=${JOB_NAME[-2]}
    - export CI_NODE_TOTAL=${JOB_NAME[-1]}
100
    - export KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/${JOB_NAME[0]}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
101
    - export KNAPSACK_GENERATE_REPORT=true
102 103 104
    - 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
105
    - export FLAKY_RSPEC_GENERATE_REPORT=true
106
    - export CACHE_CLASSES=true
107
    - cp ${KNAPSACK_RSPEC_SUITE_REPORT_PATH} ${KNAPSACK_REPORT_PATH}
108
    - '[[ -f $FLAKY_RSPEC_REPORT_PATH ]] || echo "{}" > ${FLAKY_RSPEC_REPORT_PATH}'
109
    - '[[ -f $NEW_FLAKY_RSPEC_REPORT_PATH ]] || echo "{}" > ${NEW_FLAKY_RSPEC_REPORT_PATH}'
Jacob Vosmaer's avatar
Jacob Vosmaer committed
110
    - scripts/gitaly-test-spawn
111 112 113
    - knapsack rspec "--color --format documentation"
  artifacts:
    expire_in: 31d
114
    when: always
115
    paths:
116 117
      - coverage/
      - knapsack/
118
      - rspec_flaky/
119
      - tmp/capybara/
120

121 122
.rspec-metadata-pg: &rspec-metadata-pg
  <<: *rspec-metadata
123 124
  <<: *use-pg

125 126
.rspec-metadata-mysql: &rspec-metadata-mysql
  <<: *rspec-metadata
127 128
  <<: *use-mysql

129
.spinach-metadata: &spinach-metadata
130
  <<: *dedicated-runner
131
  <<: *except-docs-and-qa
132
  <<: *pull-cache
133
  stage: test
134
  script:
135
    - JOB_NAME=( $CI_JOB_NAME )
136 137
    - export CI_NODE_INDEX=${JOB_NAME[-2]}
    - export CI_NODE_TOTAL=${JOB_NAME[-1]}
138
    - export KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/${JOB_NAME[0]}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
139
    - export KNAPSACK_GENERATE_REPORT=true
140
    - export CACHE_CLASSES=true
141
    - cp ${KNAPSACK_SPINACH_SUITE_REPORT_PATH} ${KNAPSACK_REPORT_PATH}
Jacob Vosmaer's avatar
Jacob Vosmaer committed
142
    - scripts/gitaly-test-spawn
143
    - knapsack spinach "-r rerun" -b || retry '[[ -e tmp/spinach-rerun.txt ]] && bundle exec spinach -b -r rerun $(cat tmp/spinach-rerun.txt)'
144 145
  artifacts:
    expire_in: 31d
146
    when: always
147
    paths:
148 149 150
      - coverage/
      - knapsack/
      - tmp/capybara/
151

152 153
.spinach-metadata-pg: &spinach-metadata-pg
  <<: *spinach-metadata
154 155
  <<: *use-pg

156 157
.spinach-metadata-mysql: &spinach-metadata-mysql
  <<: *spinach-metadata
158 159
  <<: *use-mysql

160 161 162 163 164 165 166
.only-canonical-masters: &only-canonical-masters
  only:
    - master@gitlab-org/gitlab-ce
    - master@gitlab-org/gitlab-ee
    - master@gitlab/gitlabhq
    - master@gitlab/gitlab-ee

167
##
168
# Trigger a package build in omnibus-gitlab repository
169 170
#
package-qa:
171
  <<: *dedicated-runner
172
  image: ruby:2.4-alpine
173
  before_script: []
174
  stage: build
175
  cache: {}
176 177
  when: manual
  script:
178
    - scripts/trigger-build-omnibus
179 180 181
  only:
    - //@gitlab-org/gitlab-ce
    - //@gitlab-org/gitlab-ee
182

183 184
# Review docs base
.review-docs: &review-docs
185
  <<: *dedicated-runner
186
  <<: *except-qa
187
  image: ruby:2.4-alpine
188 189
  before_script:
    - gem install gitlab --no-doc
190 191 192 193 194 195 196 197
    # 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: []
198
  variables:
199
    GIT_STRATEGY: none
200 201 202 203 204 205 206 207 208 209 210
  when: manual
  only:
    - branches

# 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
211 212
    # 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
213
    url: http://$DOCS_GITLAB_REPO_SUFFIX-$CI_COMMIT_REF_SLUG.$DOCS_REVIEW_APPS_DOMAIN/$DOCS_GITLAB_REPO_SUFFIX
214 215
    on_stop: review-docs-cleanup
  script:
216
    - ./trigger-build-docs deploy
217 218 219 220 221 222 223 224 225

# 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:
226
    - ./trigger-build-docs cleanup
227

228 229 230
# Retrieve knapsack and rspec_flaky reports
retrieve-tests-metadata:
  <<: *tests-metadata-state
231
  <<: *except-docs-and-qa
232
  stage: prepare
233
  cache:
234
    key: tests_metadata
235
    policy: pull
236
  script:
237
    - mkdir -p knapsack/${CI_PROJECT_NAME}/
238 239
    - 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
    - wget -O $KNAPSACK_SPINACH_SUITE_REPORT_PATH http://${TESTS_METADATA_S3_BUCKET}.s3.amazonaws.com/$KNAPSACK_SPINACH_SUITE_REPORT_PATH || rm $KNAPSACK_SPINACH_SUITE_REPORT_PATH
240 241
    - '[[ -f $KNAPSACK_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_RSPEC_SUITE_REPORT_PATH}'
    - '[[ -f $KNAPSACK_SPINACH_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_SPINACH_SUITE_REPORT_PATH}'
242
    - mkdir -p rspec_flaky/
243 244
    - 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}'
245

246 247
update-tests-metadata:
  <<: *tests-metadata-state
248
  <<: *only-canonical-masters
249
  stage: post-test
250
  cache:
251
    key: tests_metadata
252 253
    paths:
      - knapsack/
254
      - rspec_flaky/
255
    policy: push
256
  script:
257
    - retry gem install fog-aws mime-types
258 259
    - scripts/merge-reports ${KNAPSACK_RSPEC_SUITE_REPORT_PATH} knapsack/${CI_PROJECT_NAME}/rspec-pg_node_*.json
    - scripts/merge-reports ${KNAPSACK_SPINACH_SUITE_REPORT_PATH} knapsack/${CI_PROJECT_NAME}/spinach-pg_node_*.json
260
    - scripts/merge-reports ${FLAKY_RSPEC_SUITE_REPORT_PATH} rspec_flaky/all_*_*.json
261 262
    - '[[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $KNAPSACK_RSPEC_SUITE_REPORT_PATH $KNAPSACK_SPINACH_SUITE_REPORT_PATH'
    - '[[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $FLAKY_RSPEC_SUITE_REPORT_PATH'
263
    - rm -f knapsack/${CI_PROJECT_NAME}/*_node_*.json
264
    - rm -f rspec_flaky/all_*.json rspec_flaky/new_*.json
265 266 267 268 269 270 271 272 273

flaky-examples-check:
  <<: *dedicated-runner
  image: ruby:2.3-alpine
  services: []
  before_script: []
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "false"
274
    NEW_FLAKY_SPECS_REPORT: rspec_flaky/report-new.json
275
  stage: post-test
276
  allow_failure: true
277
  retry: 0
278 279 280 281
  only:
    - branches
  except:
    - master
282
    - /(^docs[\/-].*|.*-docs$)/
283
    - /(^qa[\/-].*|.*-qa$)/
284 285 286 287 288 289
  artifacts:
    expire_in: 30d
    paths:
      - rspec_flaky/
  script:
    - '[[ -f $NEW_FLAKY_SPECS_REPORT ]] || echo "{}" > ${NEW_FLAKY_SPECS_REPORT}'
290
    - scripts/merge-reports ${NEW_FLAKY_SPECS_REPORT} rspec_flaky/new_*_*.json
291
    - scripts/detect-new-flaky-examples $NEW_FLAKY_SPECS_REPORT
292

293
compile-assets:
294
  <<: *dedicated-runner
295
  <<: *except-docs
296
  <<: *use-pg
297
  stage: prepare
298 299
  cache:
    <<: *default-cache
300
  script:
301
    - node --version
302
    - yarn install --frozen-lockfile --cache-folder .yarn-cache
Mike Greiling's avatar
Mike Greiling committed
303
    - bundle exec rake gitlab:assets:compile
304 305 306
  artifacts:
    expire_in: 7d
    paths:
307
      - node_modules
308
      - public/assets
309 310 311 312 313 314 315 316 317 318 319 320 321 322

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:
323
      - tmp/tests
324
      - config/secrets.yml
325

326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
rspec-pg 0 27: *rspec-metadata-pg
rspec-pg 1 27: *rspec-metadata-pg
rspec-pg 2 27: *rspec-metadata-pg
rspec-pg 3 27: *rspec-metadata-pg
rspec-pg 4 27: *rspec-metadata-pg
rspec-pg 5 27: *rspec-metadata-pg
rspec-pg 6 27: *rspec-metadata-pg
rspec-pg 7 27: *rspec-metadata-pg
rspec-pg 8 27: *rspec-metadata-pg
rspec-pg 9 27: *rspec-metadata-pg
rspec-pg 10 27: *rspec-metadata-pg
rspec-pg 11 27: *rspec-metadata-pg
rspec-pg 12 27: *rspec-metadata-pg
rspec-pg 13 27: *rspec-metadata-pg
rspec-pg 14 27: *rspec-metadata-pg
rspec-pg 15 27: *rspec-metadata-pg
rspec-pg 16 27: *rspec-metadata-pg
rspec-pg 17 27: *rspec-metadata-pg
rspec-pg 18 27: *rspec-metadata-pg
rspec-pg 19 27: *rspec-metadata-pg
rspec-pg 20 27: *rspec-metadata-pg
rspec-pg 21 27: *rspec-metadata-pg
rspec-pg 22 27: *rspec-metadata-pg
rspec-pg 23 27: *rspec-metadata-pg
rspec-pg 24 27: *rspec-metadata-pg
rspec-pg 25 27: *rspec-metadata-pg
rspec-pg 26 27: *rspec-metadata-pg

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

spinach-pg 0 3: *spinach-metadata-pg
spinach-pg 1 3: *spinach-metadata-pg
spinach-pg 2 3: *spinach-metadata-pg

spinach-mysql 0 3: *spinach-metadata-mysql
spinach-mysql 1 3: *spinach-metadata-mysql
spinach-mysql 2 3: *spinach-metadata-mysql
389

390
# Static analysis jobs
391 392 393 394 395
.ruby-static-analysis: &ruby-static-analysis
  variables:
    SIMPLECOV: "false"
    SETUP_DB: "false"

396
.rake-exec: &rake-exec
397
  <<: *dedicated-runner
398
  <<: *except-docs-and-qa
399
  <<: *pull-cache
400
  <<: *ruby-static-analysis
401 402
  stage: test
  script:
403
    - bundle exec rake $CI_JOB_NAME
404

405
static-analysis:
406
  <<: *dedicated-runner
407
  <<: *except-docs
408
  <<: *ruby-static-analysis
409 410
  stage: test
  script:
411
    - scripts/static-analysis
Lin Jen-Shin's avatar
Lin Jen-Shin committed
412 413 414 415 416 417
  cache:
    key: "ruby-2.3.6-with-yarn-and-rubocop"
    paths:
      - vendor/ruby
      - .yarn-cache/
      - tmp/rubocop_cache
418

419 420 421 422
# Documentation checks:
# - Check validity of relative links
# - Make sure cURL examples in API docs use the full switches
docs lint:
423
  <<: *dedicated-runner
424
  <<: *except-qa
425 426 427 428 429 430
  image: "registry.gitlab.com/gitlab-org/gitlab-build-images:nanoc-bootstrap-ruby-2.4-alpine"
  stage: test
  cache: {}
  dependencies: []
  before_script: []
  script:
431
    - scripts/lint-doc.sh
432
    - scripts/lint-changelog-yaml
433 434 435 436 437 438 439
    - mv doc/ /nanoc/content/
    - cd /nanoc
    # Build HTML from Markdown
    - bundle exec nanoc
    # Check the internal links
    - bundle exec nanoc check internal_links

440 441
downtime_check:
  <<: *rake-exec
442 443 444 445
  except:
    - master
    - tags
    - /^[\d-]+-stable(-ee)?$/
446
    - /(^docs[\/-].*|.*-docs$)/
447
    - /(^qa[\/-].*|.*-qa$)/
448

449 450
ee_compat_check:
  <<: *rake-exec
451 452 453
  except:
    - master
    - tags
454
    - /^[\d-]+-stable(-ee)?/
455
    - /^security-/
456 457
    - branches@gitlab-org/gitlab-ee
    - branches@gitlab/gitlab-ee
458
  retry: 0
459
  artifacts:
460
    name: "${CI_JOB_NAME}_${CI_COMIT_REF_NAME}_${CI_COMMIT_SHA}"
461
    when: always
462 463 464 465
    expire_in: 10d
    paths:
      - ee_compat_check/patches/*.patch

466
# DB migration, rollback, and seed jobs
467
.db-migrate-reset: &db-migrate-reset
468
  <<: *dedicated-runner
469
  <<: *except-docs-and-qa
470 471
  <<: *pull-cache
  stage: test
472
  script:
473
    - bundle exec rake db:migrate:reset
474

475
db:migrate:reset-pg:
476 477 478
  <<: *db-migrate-reset
  <<: *use-pg

479
db:migrate:reset-mysql:
480 481 482
  <<: *db-migrate-reset
  <<: *use-mysql

483 484 485 486 487 488
db:check-schema-pg:
  <<: *db-migrate-reset
  <<: *use-pg
  script:
    - source scripts/schema_changed.sh

489 490
.migration-paths: &migration-paths
  <<: *dedicated-runner
491
  <<: *except-docs-and-qa
492
  <<: *pull-cache
493
  stage: test
494 495
  variables:
    SETUP_DB: "false"
496
    CREATE_DB_USER: "true"
497
  script:
498
    - git fetch https://gitlab.com/gitlab-org/gitlab-ce.git v9.3.0
499 500
    - git checkout -f FETCH_HEAD
    - bundle install $BUNDLE_INSTALL_FLAGS
501
    - cp config/gitlab.yml.example config/gitlab.yml
502 503 504 505 506 507 508 509 510 511 512 513 514 515
    - bundle exec rake db:drop db:create db:schema:load db:seed_fu
    - git checkout $CI_COMMIT_SHA
    - bundle install $BUNDLE_INSTALL_FLAGS
    - . scripts/prepare_build.sh
    - bundle exec rake db:migrate

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

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

516
.db-rollback: &db-rollback
517
  <<: *dedicated-runner
518
  <<: *except-docs-and-qa
519 520
  <<: *pull-cache
  stage: test
521
  script:
522
    - bundle exec rake db:rollback STEP=119
523
    - bundle exec rake db:migrate
524

525
db:rollback-pg:
526 527 528
  <<: *db-rollback
  <<: *use-pg

529
db:rollback-mysql:
530 531 532
  <<: *db-rollback
  <<: *use-mysql

533
.gitlab-setup: &gitlab-setup
534
  <<: *dedicated-runner
535
  <<: *except-docs-and-qa
536 537
  <<: *pull-cache
  stage: test
538 539 540
  variables:
    SIZE: "1"
    SETUP_DB: "false"
541
    CREATE_DB_USER: "true"
542
    FIXTURE_PATH: db/fixtures/development
543 544 545
  script:
    - git clone https://gitlab.com/gitlab-org/gitlab-test.git
       /home/git/repositories/gitlab-org/gitlab-test.git
546 547
    - scripts/gitaly-test-spawn
    - force=yes bundle exec rake gitlab:setup
548 549 550 551 552 553
  artifacts:
    when: on_failure
    expire_in: 1d
    paths:
      - log/development.log

554 555
gitlab:setup-pg:
  <<: *gitlab-setup
556 557
  <<: *use-pg

558 559
gitlab:setup-mysql:
  <<: *gitlab-setup
560 561
  <<: *use-mysql

562
# Frontend-related jobs
563
gitlab:assets:compile:
564
  <<: *dedicated-runner
565
  <<: *except-docs-and-qa
566 567
  <<: *pull-cache
  stage: test
568 569 570 571 572 573
  dependencies: []
  variables:
    NODE_ENV: "production"
    RAILS_ENV: "production"
    SETUP_DB: "false"
    SKIP_STORAGE_VALIDATION: "true"
574
    WEBPACK_REPORT: "true"
Mike Greiling's avatar
Mike Greiling committed
575
    NO_COMPRESSION: "true"
576
  script:
577
    - yarn install --frozen-lockfile --production --cache-folder .yarn-cache
578
    - bundle exec rake gitlab:assets:compile
579 580 581 582
  artifacts:
    name: webpack-report
    expire_in: 31d
    paths:
583
      - webpack-report/
584

585
karma:
586
  <<: *dedicated-runner
587
  <<: *except-docs-and-qa
588
  <<: *pull-cache
589
  <<: *use-pg
590
  stage: test
591 592
  variables:
    BABEL_ENV: "coverage"
593
    CHROME_LOG_FILE: "chrome_debug.log"
594
  script:
Jacob Vosmaer's avatar
Jacob Vosmaer committed
595
    - scripts/gitaly-test-spawn
596
    - bundle exec rake gettext:po_to_json
597
    - bundle exec rake karma
598
  coverage: '/^Statements *: (\d+\.\d+%)/'
599 600 601
  artifacts:
    name: coverage-javascript
    expire_in: 31d
602
    when: always
603
    paths:
604
    - chrome_debug.log
605
    - coverage-javascript/
606

607
codequality:
608
  <<: *except-docs
609
  <<: *pull-cache
610 611 612 613 614 615 616 617 618
  before_script: []
  image: docker:latest
  stage: test
  variables:
    SETUP_DB: "false"
    DOCKER_DRIVER: overlay
  services:
    - docker:dind
  script:
619 620
    - cp .rubocop.yml .rubocop.yml.bak
    - grep -v "rubocop-gitlab-security" .rubocop.yml.bak > .rubocop.yml
Rémy Coutable's avatar
Rémy Coutable committed
621
    - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc dev.gitlab.org:5005/gitlab/gitlab-build-images:gitlab-codeclimate-v2 analyze -f json > raw_codeclimate.json
622
    - cat raw_codeclimate.json | docker run -i stedolan/jq -c 'map({check_name,fingerprint,location})' > codeclimate.json
623
    - mv .rubocop.yml.bak .rubocop.yml
624 625 626
  artifacts:
    paths: [codeclimate.json]

627
sast:
628
  <<: *except-docs
629
  image: registry.gitlab.com/gitlab-org/gl-sast:latest
630 631
  variables:
    CONFIDENCE_LEVEL: 2
632 633 634 635 636 637
  before_script: []
  script:
    - /app/bin/run .
  artifacts:
    paths: [gl-sast-report.json]

638
qa:internal:
639
  <<: *dedicated-runner
640
  <<: *except-docs
641 642 643 644 645 646 647 648 649
  stage: test
  variables:
    SETUP_DB: "false"
  services: []
  script:
    - cd qa/
    - bundle install
    - bundle exec rspec

650 651 652 653 654 655 656 657 658 659
qa:selectors:
  <<: *dedicated-runner
  <<: *except-docs
  stage: test
  variables:
    SETUP_DB: "false"
  services: []
  script:
    - cd qa/
    - bundle install
660
    - bundle exec bin/qa Test::Sanity::Selectors
661

662
coverage:
663
  <<: *dedicated-runner
664
  <<: *except-docs-and-qa
665 666 667
  <<: *pull-cache
  stage: post-test
  services: []
668 669 670 671 672
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "true"
  script:
    - bundle exec scripts/merge-simplecov
673
  coverage: '/LOC \((\d+\.\d+%)\) covered.$/'
674 675 676 677 678 679 680
  artifacts:
    name: coverage
    expire_in: 31d
    paths:
    - coverage/index.html
    - coverage/assets/

681
lint:javascript:report:
682
  <<: *dedicated-runner
683
  <<: *except-docs-and-qa
684
  <<: *pull-cache
685
  stage: post-test
686
  dependencies:
687
    - compile-assets
688
    - setup-test-env
689
  before_script: []
690
  script:
691
    - find app/ spec/ -name '*.js' -exec sed --in-place 's|/\* eslint-disable .*\*/||' {} \; # run report over all files
692
    - yarn run eslint-report || true # ignore exit code
693 694 695 696 697
  artifacts:
    name: eslint-report
    expire_in: 31d
    paths:
    - eslint-report.html
698 699

pages:
700 701
  <<: *dedicated-runner
  <<: *pull-cache
702 703 704 705
  before_script: []
  stage: pages
  dependencies:
    - coverage
706 707
    - karma
    - gitlab:assets:compile
708
    - lint:javascript:report
709 710 711
  script:
    - mv public/ .public/
    - mkdir public/
712
    - mv coverage/ public/coverage-ruby/ || true
713
    - mv coverage-javascript/ public/coverage-javascript/ || true
714
    - mv eslint-report.html public/ || true
715
    - mv webpack-report/ public/webpack-report/ || true
716 717 718 719
  artifacts:
    paths:
      - public
  only:
720
    - master@gitlab-org/gitlab-ce
721
    - master@gitlab-org/gitlab-ee
722 723 724 725

# Insurance in case a gem needed by one of our releases gets yanked from
# rubygems.org in the future.
cache gems:
726
  <<: *dedicated-runner
727
  <<: *pull-cache
728 729 730 731 732 733 734
  variables:
    SETUP_DB: "false"
  script:
    - bundle package --all --all-platforms
  artifacts:
    paths:
      - vendor/cache
735 736
  only:
    - master@gitlab-org/gitlab-ce
737
    - master@gitlab-org/gitlab-ee
738
    - tags
739 740

gitlab_git_test:
741
  <<: *dedicated-runner
742
  <<: *except-docs-and-qa
743 744
  variables:
    SETUP_DB: "false"
745 746
  before_script: []
  cache: {}
747 748
  script:
    - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes