.gitlab-ci.yml 20 KB
Newer Older
1
image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.6-golang-1.9-git-2.16-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
  - date
39
  - source scripts/utils.sh
40
  - date
41
  - source scripts/prepare_build.sh
42 43 44 45
  - date

after_script:
  - date
46

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

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

68 69
.use-pg: &use-pg
  services:
70 71 72
    # 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).
73
    - postgres:9.2
74 75 76
    - redis:alpine

.use-mysql: &use-mysql
77 78 79
  services:
    - mysql:latest
    - redis:alpine
80

81 82 83
# 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
84 85
.except-docs: &except-docs
  except:
86
    - /(^docs[\/-].*|.*-docs$)/
87

88 89 90 91
.except-qa: &except-qa
  except:
    - /(^qa[\/-].*|.*-qa$)/

92 93 94 95 96
.except-docs-and-qa: &except-docs-and-qa
  except:
    - /(^docs[\/-].*|.*-docs$)/
    - /(^qa[\/-].*|.*-qa$)/

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

127 128
.rspec-metadata-pg: &rspec-metadata-pg
  <<: *rspec-metadata
129 130
  <<: *use-pg

131 132
.rspec-metadata-mysql: &rspec-metadata-mysql
  <<: *rspec-metadata
133 134
  <<: *use-mysql

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

158 159
.spinach-metadata-pg: &spinach-metadata-pg
  <<: *spinach-metadata
160 161
  <<: *use-pg

162 163
.spinach-metadata-mysql: &spinach-metadata-mysql
  <<: *spinach-metadata
164 165
  <<: *use-mysql

166 167 168 169 170 171 172
.only-canonical-masters: &only-canonical-masters
  only:
    - master@gitlab-org/gitlab-ce
    - master@gitlab-org/gitlab-ee
    - master@gitlab/gitlabhq
    - master@gitlab/gitlab-ee

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

189 190
# Review docs base
.review-docs: &review-docs
191
  <<: *dedicated-runner
192
  <<: *except-qa
193
  image: ruby:2.4-alpine
194 195
  before_script:
    - gem install gitlab --no-doc
196 197 198 199 200 201 202 203
    # 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: []
204
  variables:
205
    GIT_STRATEGY: none
206 207 208 209 210 211 212 213 214 215 216
  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
217 218
    # 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
219
    url: http://$DOCS_GITLAB_REPO_SUFFIX-$CI_COMMIT_REF_SLUG.$DOCS_REVIEW_APPS_DOMAIN/$DOCS_GITLAB_REPO_SUFFIX
220 221
    on_stop: review-docs-cleanup
  script:
222
    - ./trigger-build-docs deploy
223 224 225 226 227 228 229 230 231

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

234 235 236
# Retrieve knapsack and rspec_flaky reports
retrieve-tests-metadata:
  <<: *tests-metadata-state
237
  <<: *except-docs-and-qa
238
  stage: prepare
239
  cache:
240
    key: tests_metadata
241
    policy: pull
242
  script:
243
    - mkdir -p knapsack/${CI_PROJECT_NAME}/
244 245
    - 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
246 247
    - '[[ -f $KNAPSACK_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_RSPEC_SUITE_REPORT_PATH}'
    - '[[ -f $KNAPSACK_SPINACH_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_SPINACH_SUITE_REPORT_PATH}'
248
    - mkdir -p rspec_flaky/
249 250
    - 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}'
251

252 253
update-tests-metadata:
  <<: *tests-metadata-state
254
  <<: *only-canonical-masters
255
  stage: post-test
256
  cache:
257
    key: tests_metadata
258 259
    paths:
      - knapsack/
260
      - rspec_flaky/
261
    policy: push
262
  script:
263
    - retry gem install fog-aws mime-types
264 265
    - 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
266
    - scripts/merge-reports ${FLAKY_RSPEC_SUITE_REPORT_PATH} rspec_flaky/all_*_*.json
267 268
    - '[[ -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'
269
    - rm -f knapsack/${CI_PROJECT_NAME}/*_node_*.json
270
    - rm -f rspec_flaky/all_*.json rspec_flaky/new_*.json
271 272 273 274 275 276 277 278 279

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

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

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:
331
      - tmp/tests
332
      - config/secrets.yml
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 389 390 391 392 393 394 395 396
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

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

spinach-mysql 0 2: *spinach-metadata-mysql
spinach-mysql 1 2: *spinach-metadata-mysql
397

398
# Static analysis jobs
399 400 401 402 403
.ruby-static-analysis: &ruby-static-analysis
  variables:
    SIMPLECOV: "false"
    SETUP_DB: "false"

404
.rake-exec: &rake-exec
405
  <<: *dedicated-runner
406
  <<: *except-docs-and-qa
407
  <<: *pull-cache
408
  <<: *ruby-static-analysis
409 410
  stage: test
  script:
411
    - bundle exec rake $CI_JOB_NAME
412

413
static-analysis:
414
  <<: *dedicated-runner
415
  <<: *except-docs
416
  <<: *ruby-static-analysis
417 418
  stage: test
  script:
419
    - scripts/static-analysis
Lin Jen-Shin's avatar
Lin Jen-Shin committed
420 421 422 423 424 425
  cache:
    key: "ruby-2.3.6-with-yarn-and-rubocop"
    paths:
      - vendor/ruby
      - .yarn-cache/
      - tmp/rubocop_cache
426

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

448 449
downtime_check:
  <<: *rake-exec
450 451 452 453
  except:
    - master
    - tags
    - /^[\d-]+-stable(-ee)?$/
454
    - /(^docs[\/-].*|.*-docs$)/
455
    - /(^qa[\/-].*|.*-qa$)/
456

457 458
ee_compat_check:
  <<: *rake-exec
459 460 461
  except:
    - master
    - tags
462
    - /^[\d-]+-stable(-ee)?/
463
    - /^security-/
464 465
    - branches@gitlab-org/gitlab-ee
    - branches@gitlab/gitlab-ee
466
  retry: 0
467
  artifacts:
468
    name: "${CI_JOB_NAME}_${CI_COMIT_REF_NAME}_${CI_COMMIT_SHA}"
469
    when: always
470 471 472 473
    expire_in: 10d
    paths:
      - ee_compat_check/patches/*.patch

474
# DB migration, rollback, and seed jobs
475
.db-migrate-reset: &db-migrate-reset
476
  <<: *dedicated-runner
477
  <<: *except-docs-and-qa
478 479
  <<: *pull-cache
  stage: test
480
  script:
481
    - bundle exec rake db:migrate:reset
482

483
db:migrate:reset-pg:
484 485 486
  <<: *db-migrate-reset
  <<: *use-pg

487
db:migrate:reset-mysql:
488 489 490
  <<: *db-migrate-reset
  <<: *use-mysql

491 492 493 494 495 496
db:check-schema-pg:
  <<: *db-migrate-reset
  <<: *use-pg
  script:
    - source scripts/schema_changed.sh

497 498
.migration-paths: &migration-paths
  <<: *dedicated-runner
499
  <<: *except-docs-and-qa
500
  <<: *pull-cache
501
  stage: test
502 503
  variables:
    SETUP_DB: "false"
504
    CREATE_DB_USER: "true"
505
  script:
506
    - git fetch https://gitlab.com/gitlab-org/gitlab-ce.git v9.3.0
507 508
    - git checkout -f FETCH_HEAD
    - bundle install $BUNDLE_INSTALL_FLAGS
509
    - date
510
    - cp config/gitlab.yml.example config/gitlab.yml
511
    - bundle exec rake db:drop db:create db:schema:load db:seed_fu
512
    - date
513 514
    - git checkout $CI_COMMIT_SHA
    - bundle install $BUNDLE_INSTALL_FLAGS
515
    - date
516
    - . scripts/prepare_build.sh
517
    - date
518 519 520 521 522 523 524 525 526 527
    - bundle exec rake db:migrate

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

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

528
.db-rollback: &db-rollback
529
  <<: *dedicated-runner
530
  <<: *except-docs-and-qa
531 532
  <<: *pull-cache
  stage: test
533
  script:
534
    - bundle exec rake db:rollback STEP=119
535
    - bundle exec rake db:migrate
536

537
db:rollback-pg:
538 539 540
  <<: *db-rollback
  <<: *use-pg

541
db:rollback-mysql:
542 543 544
  <<: *db-rollback
  <<: *use-mysql

545
.gitlab-setup: &gitlab-setup
546
  <<: *dedicated-runner
547
  <<: *except-docs-and-qa
548 549
  <<: *pull-cache
  stage: test
550 551 552
  variables:
    SIZE: "1"
    SETUP_DB: "false"
553
    CREATE_DB_USER: "true"
554
    FIXTURE_PATH: db/fixtures/development
555 556 557
  script:
    - git clone https://gitlab.com/gitlab-org/gitlab-test.git
       /home/git/repositories/gitlab-org/gitlab-test.git
558 559
    - scripts/gitaly-test-spawn
    - force=yes bundle exec rake gitlab:setup
560 561 562 563 564 565
  artifacts:
    when: on_failure
    expire_in: 1d
    paths:
      - log/development.log

566 567
gitlab:setup-pg:
  <<: *gitlab-setup
568 569
  <<: *use-pg

570 571
gitlab:setup-mysql:
  <<: *gitlab-setup
572 573
  <<: *use-mysql

574
# Frontend-related jobs
575
gitlab:assets:compile:
576
  <<: *dedicated-runner
577
  <<: *except-docs-and-qa
578 579
  <<: *pull-cache
  stage: test
580 581 582 583 584 585
  dependencies: []
  variables:
    NODE_ENV: "production"
    RAILS_ENV: "production"
    SETUP_DB: "false"
    SKIP_STORAGE_VALIDATION: "true"
586
    WEBPACK_REPORT: "true"
Mike Greiling's avatar
Mike Greiling committed
587
    NO_COMPRESSION: "true"
588
  script:
589
    - date
590
    - yarn install --frozen-lockfile --production --cache-folder .yarn-cache
591
    - date
592
    - bundle exec rake gitlab:assets:compile
593 594 595 596
  artifacts:
    name: webpack-report
    expire_in: 31d
    paths:
597
      - webpack-report/
598

599
karma:
600
  <<: *dedicated-runner
601
  <<: *except-docs-and-qa
602
  <<: *pull-cache
603
  <<: *use-pg
604
  stage: test
605 606
  variables:
    BABEL_ENV: "coverage"
607
    CHROME_LOG_FILE: "chrome_debug.log"
608
  script:
609
    - date
Jacob Vosmaer's avatar
Jacob Vosmaer committed
610
    - scripts/gitaly-test-spawn
611
    - date
612
    - bundle exec rake gettext:po_to_json
613
    - date
614
    - bundle exec rake karma
615
  coverage: '/^Statements *: (\d+\.\d+%)/'
616 617 618
  artifacts:
    name: coverage-javascript
    expire_in: 31d
619
    when: always
620
    paths:
621
    - chrome_debug.log
622
    - coverage-javascript/
623

624
codequality:
625
  <<: *except-docs
626
  <<: *pull-cache
627
  stage: test
628 629
  image: docker:latest
  before_script: []
630 631
  services:
    - docker:dind
632 633 634 635 636 637
  variables:
    SETUP_DB: "false"
    DOCKER_DRIVER: overlay2
    CODECLIMATE_FORMAT: json
  cache: {}
  dependencies: []
638
  script:
639
    - apk update && apk add jq
640 641
    - ./scripts/codequality analyze -f json > raw_codeclimate.json || true
    # The following line keeps only the fields used in the MR widget, reducing the JSON artifact size
642
    - jq -c 'map({check_name,description,fingerprint,location})' raw_codeclimate.json > codeclimate.json
643 644
  artifacts:
    paths: [codeclimate.json]
645
    expire_in: 1 week
646

647
sast:
648
  <<: *except-docs
649
  image: registry.gitlab.com/gitlab-org/gl-sast:latest
650 651
  variables:
    CONFIDENCE_LEVEL: 2
652 653 654 655 656 657
  before_script: []
  script:
    - /app/bin/run .
  artifacts:
    paths: [gl-sast-report.json]

658
qa:internal:
659
  <<: *dedicated-runner
660
  <<: *except-docs
661 662 663 664 665 666 667 668 669
  stage: test
  variables:
    SETUP_DB: "false"
  services: []
  script:
    - cd qa/
    - bundle install
    - bundle exec rspec

670 671 672 673 674 675 676 677 678 679
qa:selectors:
  <<: *dedicated-runner
  <<: *except-docs
  stage: test
  variables:
    SETUP_DB: "false"
  services: []
  script:
    - cd qa/
    - bundle install
680
    - bundle exec bin/qa Test::Sanity::Selectors
681

682
coverage:
683
  <<: *dedicated-runner
684
  <<: *except-docs-and-qa
685 686 687
  <<: *pull-cache
  stage: post-test
  services: []
688 689 690 691 692
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "true"
  script:
    - bundle exec scripts/merge-simplecov
693
  coverage: '/LOC \((\d+\.\d+%)\) covered.$/'
694 695 696 697 698 699 700
  artifacts:
    name: coverage
    expire_in: 31d
    paths:
    - coverage/index.html
    - coverage/assets/

701
lint:javascript:report:
702
  <<: *dedicated-runner
703
  <<: *except-docs-and-qa
704
  <<: *pull-cache
705
  stage: post-test
706
  dependencies:
707
    - compile-assets
708
    - setup-test-env
709
  before_script: []
710
  script:
711
    - date
712
    - find app/ spec/ -name '*.js' -exec sed --in-place 's|/\* eslint-disable .*\*/||' {} \; # run report over all files
713
    - date
714
    - yarn run eslint-report || true # ignore exit code
715 716 717 718 719
  artifacts:
    name: eslint-report
    expire_in: 31d
    paths:
    - eslint-report.html
720 721

pages:
722 723
  <<: *dedicated-runner
  <<: *pull-cache
724 725 726 727
  before_script: []
  stage: pages
  dependencies:
    - coverage
728 729
    - karma
    - gitlab:assets:compile
730
    - lint:javascript:report
731 732 733
  script:
    - mv public/ .public/
    - mkdir public/
734
    - mv coverage/ public/coverage-ruby/ || true
735
    - mv coverage-javascript/ public/coverage-javascript/ || true
736
    - mv eslint-report.html public/ || true
737
    - mv webpack-report/ public/webpack-report/ || true
738 739 740 741
  artifacts:
    paths:
      - public
  only:
742
    - master@gitlab-org/gitlab-ce
743
    - master@gitlab-org/gitlab-ee
744 745 746 747

# Insurance in case a gem needed by one of our releases gets yanked from
# rubygems.org in the future.
cache gems:
748
  <<: *dedicated-runner
749
  <<: *pull-cache
750 751 752 753 754 755 756
  variables:
    SETUP_DB: "false"
  script:
    - bundle package --all --all-platforms
  artifacts:
    paths:
      - vendor/cache
757 758
  only:
    - master@gitlab-org/gitlab-ce
759
    - master@gitlab-org/gitlab-ee
760
    - tags
761 762

gitlab_git_test:
763
  <<: *dedicated-runner
764
  <<: *except-docs-and-qa
765 766
  variables:
    SETUP_DB: "false"
767 768
  before_script: []
  cache: {}
769 770
  script:
    - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes