.gitlab-ci.yml 18.8 KB
Newer Older
1
image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.5-golang-1.8-git-2.14-chrome-63.0-node-8.x-yarn-1.2-postgresql-9.6"
2

3
.default-cache: &default-cache
Zeger-Jan van de Weg's avatar
Zeger-Jan van de Weg committed
4
  key: "ruby-235-with-yarn"
5
  paths:
6 7 8 9 10 11 12 13 14 15 16 17
    - vendor/ruby
    - .yarn-cache/

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

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

19 20
variables:
  MYSQL_ALLOW_EMPTY_PASSWORD: "1"
Kamil Trzcinski's avatar
Kamil Trzcinski committed
21
  RAILS_ENV: "test"
Mike Greiling's avatar
Mike Greiling committed
22
  NODE_ENV: "test"
Kamil Trzcinski's avatar
Kamil Trzcinski committed
23
  SIMPLECOV: "true"
24
  GIT_DEPTH: "20"
25
  GIT_SUBMODULE_STRATEGY: "none"
26
  GET_SOURCES_ATTEMPTS: "3"
27 28
  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
29
  FLAKY_RSPEC_SUITE_REPORT_PATH: rspec_flaky/report-suite.json
30

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
31
before_script:
Kamil Trzcinski's avatar
Test  
Kamil Trzcinski committed
32
  - bundle --version
33 34
  - source scripts/utils.sh
  - source scripts/prepare_build.sh
35

Kamil Trzcinski's avatar
Kamil Trzcinski committed
36
stages:
37 38 39 40 41
  - build
  - prepare
  - test
  - post-test
  - pages
42
  - post-cleanup
43

44 45
# Predefined scopes
.dedicated-runner: &dedicated-runner
46
  retry: 1
47 48 49
  tags:
    - gitlab-org

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
    - postgres:9.2
65 66 67
    - redis:alpine

.use-mysql: &use-mysql
68 69 70
  services:
    - mysql:latest
    - redis:alpine
71

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

79 80 81 82
.except-qa: &except-qa
  except:
    - /(^qa[\/-].*|.*-qa$)/

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

114 115
.rspec-metadata-pg: &rspec-metadata-pg
  <<: *rspec-metadata
116 117
  <<: *use-pg

118 119
.rspec-metadata-mysql: &rspec-metadata-mysql
  <<: *rspec-metadata
120 121
  <<: *use-mysql

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

146 147
.spinach-metadata-pg: &spinach-metadata-pg
  <<: *spinach-metadata
148 149
  <<: *use-pg

150 151
.spinach-metadata-mysql: &spinach-metadata-mysql
  <<: *spinach-metadata
152 153
  <<: *use-mysql

154 155 156 157 158 159 160
.only-canonical-masters: &only-canonical-masters
  only:
    - master@gitlab-org/gitlab-ce
    - master@gitlab-org/gitlab-ee
    - master@gitlab/gitlabhq
    - master@gitlab/gitlab-ee

161
##
162
# Trigger a package build in omnibus-gitlab repository
163 164
#
package-qa:
165
  image: ruby:2.4-alpine
166
  before_script: []
167
  stage: build
168
  cache: {}
169 170
  when: manual
  script:
171
    - scripts/trigger-build-omnibus
172 173 174
  only:
    - //@gitlab-org/gitlab-ce
    - //@gitlab-org/gitlab-ee
175

176 177
# Review docs base
.review-docs: &review-docs
178
  <<: *except-qa
179
  image: ruby:2.4-alpine
180 181
  before_script:
    - gem install gitlab --no-doc
182 183 184 185 186 187 188 189
    # 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: []
190
  variables:
191
    GIT_STRATEGY: none
192 193 194 195 196 197 198 199 200 201 202
  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
203 204
    # 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
205
    url: http://$DOCS_GITLAB_REPO_SUFFIX-$CI_COMMIT_REF_SLUG.$DOCS_REVIEW_APPS_DOMAIN/$DOCS_GITLAB_REPO_SUFFIX
206 207
    on_stop: review-docs-cleanup
  script:
208
    - ./trigger-build-docs deploy
209 210 211 212 213 214 215 216 217

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

220 221 222
# Retrieve knapsack and rspec_flaky reports
retrieve-tests-metadata:
  <<: *tests-metadata-state
223
  <<: *except-docs
224
  <<: *except-qa
225
  stage: prepare
226
  cache:
227
    key: tests_metadata
228
    policy: pull
229
  script:
230
    - mkdir -p knapsack/${CI_PROJECT_NAME}/
231 232
    - 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
233 234
    - '[[ -f $KNAPSACK_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_RSPEC_SUITE_REPORT_PATH}'
    - '[[ -f $KNAPSACK_SPINACH_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_SPINACH_SUITE_REPORT_PATH}'
235
    - mkdir -p rspec_flaky/
236 237
    - 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}'
238

239 240
update-tests-metadata:
  <<: *tests-metadata-state
241
  <<: *only-canonical-masters
242
  stage: post-test
243
  cache:
244
    key: tests_metadata
245 246
    paths:
      - knapsack/
247
      - rspec_flaky/
248
    policy: push
249
  script:
250
    - retry gem install fog-aws mime-types
251 252
    - 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
253
    - scripts/merge-reports ${FLAKY_RSPEC_SUITE_REPORT_PATH} rspec_flaky/all_*_*.json
254 255
    - '[[ -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'
256
    - rm -f knapsack/${CI_PROJECT_NAME}/*_node_*.json
257
    - rm -f rspec_flaky/all_*.json rspec_flaky/new_*.json
258 259 260 261 262 263 264 265 266

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

setup-test-env:
287
  <<: *use-pg
288
  <<: *dedicated-runner
289
  <<: *except-docs
290
  stage: prepare
291 292
  cache:
    <<: *default-cache
293
  script:
294
    - node --version
295
    - yarn install --frozen-lockfile --cache-folder .yarn-cache
Mike Greiling's avatar
Mike Greiling committed
296
    - bundle exec rake gitlab:assets:compile
297
    - bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init'
Jacob Vosmaer's avatar
Jacob Vosmaer committed
298
    - scripts/gitaly-test-build # Do not use 'bundle exec' here
299 300 301
  artifacts:
    expire_in: 7d
    paths:
302
      - node_modules
303 304 305
      - public/assets
      - tmp/tests

306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 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
rspec-pg 0 26: *rspec-metadata-pg
rspec-pg 1 26: *rspec-metadata-pg
rspec-pg 2 26: *rspec-metadata-pg
rspec-pg 3 26: *rspec-metadata-pg
rspec-pg 4 26: *rspec-metadata-pg
rspec-pg 5 26: *rspec-metadata-pg
rspec-pg 6 26: *rspec-metadata-pg
rspec-pg 7 26: *rspec-metadata-pg
rspec-pg 8 26: *rspec-metadata-pg
rspec-pg 9 26: *rspec-metadata-pg
rspec-pg 10 26: *rspec-metadata-pg
rspec-pg 11 26: *rspec-metadata-pg
rspec-pg 12 26: *rspec-metadata-pg
rspec-pg 13 26: *rspec-metadata-pg
rspec-pg 14 26: *rspec-metadata-pg
rspec-pg 15 26: *rspec-metadata-pg
rspec-pg 16 26: *rspec-metadata-pg
rspec-pg 17 26: *rspec-metadata-pg
rspec-pg 18 26: *rspec-metadata-pg
rspec-pg 19 26: *rspec-metadata-pg
rspec-pg 20 26: *rspec-metadata-pg
rspec-pg 21 26: *rspec-metadata-pg
rspec-pg 22 26: *rspec-metadata-pg
rspec-pg 23 26: *rspec-metadata-pg
rspec-pg 24 26: *rspec-metadata-pg
rspec-pg 25 26: *rspec-metadata-pg

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

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

spinach-mysql 0 4: *spinach-metadata-mysql
spinach-mysql 1 4: *spinach-metadata-mysql
spinach-mysql 2 4: *spinach-metadata-mysql
spinach-mysql 3 4: *spinach-metadata-mysql
369

370
# Static analysis jobs
371
.ruby-static-analysis: &ruby-static-analysis
372
  <<: *pull-cache
373 374 375 376
  variables:
    SIMPLECOV: "false"
    SETUP_DB: "false"

377
.rake-exec: &rake-exec
378
  <<: *ruby-static-analysis
379
  <<: *dedicated-runner
380
  <<: *except-docs
381
  <<: *except-qa
382
  <<: *pull-cache
383 384
  stage: test
  script:
385
    - bundle exec rake $CI_JOB_NAME
386

387
static-analysis:
388 389
  <<: *ruby-static-analysis
  <<: *dedicated-runner
390
  <<: *except-docs
391 392
  stage: test
  script:
393
    - scripts/static-analysis
394

395 396 397 398
# Documentation checks:
# - Check validity of relative links
# - Make sure cURL examples in API docs use the full switches
docs lint:
399
  <<: *dedicated-runner
400
  <<: *except-qa
401 402 403 404 405 406
  image: "registry.gitlab.com/gitlab-org/gitlab-build-images:nanoc-bootstrap-ruby-2.4-alpine"
  stage: test
  cache: {}
  dependencies: []
  before_script: []
  script:
407
    - scripts/lint-doc.sh
408
    - scripts/lint-changelog-yaml
409 410 411 412 413 414 415
    - mv doc/ /nanoc/content/
    - cd /nanoc
    # Build HTML from Markdown
    - bundle exec nanoc
    # Check the internal links
    - bundle exec nanoc check internal_links

416 417
downtime_check:
  <<: *rake-exec
418 419 420 421
  except:
    - master
    - tags
    - /^[\d-]+-stable(-ee)?$/
422
    - /(^docs[\/-].*|.*-docs$)/
423
    - /(^qa[\/-].*|.*-qa$)/
424

425 426
ee_compat_check:
  <<: *rake-exec
427 428 429
  except:
    - master
    - tags
430
    - /^[\d-]+-stable(-ee)?/
431 432
    - branches@gitlab-org/gitlab-ee
    - branches@gitlab/gitlab-ee
433
  retry: 0
434
  artifacts:
435
    name: "${CI_JOB_NAME}_${CI_COMIT_REF_NAME}_${CI_COMMIT_SHA}"
436
    when: always
437 438 439 440
    expire_in: 10d
    paths:
      - ee_compat_check/patches/*.patch

441
# DB migration, rollback, and seed jobs
442
.db-migrate-reset: &db-migrate-reset
443
  <<: *dedicated-runner
444
  <<: *except-docs
445
  <<: *except-qa
446 447
  <<: *pull-cache
  stage: test
448
  script:
449
    - bundle exec rake db:migrate:reset
450

451
db:migrate:reset-pg:
452 453 454
  <<: *db-migrate-reset
  <<: *use-pg

455
db:migrate:reset-mysql:
456 457 458
  <<: *db-migrate-reset
  <<: *use-mysql

459 460
.migration-paths: &migration-paths
  <<: *dedicated-runner
461
  <<: *pull-cache
462
  <<: *except-docs
463
  <<: *except-qa
464
  stage: test
465 466
  variables:
    SETUP_DB: "false"
467
    CREATE_DB_USER: "true"
468
  script:
469
    - git fetch https://gitlab.com/gitlab-org/gitlab-ce.git v9.3.0
470 471
    - git checkout -f FETCH_HEAD
    - bundle install $BUNDLE_INSTALL_FLAGS
472
    - cp config/gitlab.yml.example config/gitlab.yml
473 474 475 476 477 478 479 480 481 482 483 484 485 486
    - 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

487
.db-rollback: &db-rollback
488
  <<: *dedicated-runner
489
  <<: *except-docs
490
  <<: *except-qa
491 492
  <<: *pull-cache
  stage: test
493
  script:
494
    - bundle exec rake db:rollback STEP=119
495
    - bundle exec rake db:migrate
496

497
db:rollback-pg:
498 499 500
  <<: *db-rollback
  <<: *use-pg

501
db:rollback-mysql:
502 503 504 505
  <<: *db-rollback
  <<: *use-mysql

.db-seed_fu: &db-seed_fu
506
  <<: *dedicated-runner
507
  <<: *except-docs
508
  <<: *except-qa
509 510
  <<: *pull-cache
  stage: test
511 512 513
  variables:
    SIZE: "1"
    SETUP_DB: "false"
514
    CREATE_DB_USER: "true"
515 516 517 518 519 520 521 522 523 524
  script:
    - git clone https://gitlab.com/gitlab-org/gitlab-test.git
       /home/git/repositories/gitlab-org/gitlab-test.git
    - bundle exec rake db:setup db:seed_fu
  artifacts:
    when: on_failure
    expire_in: 1d
    paths:
      - log/development.log

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

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

533 534 535 536 537 538
db:check-schema-pg:
  <<: *db-migrate-reset
  <<: *use-pg
  script:
    - source scripts/schema_changed.sh

539
# Frontend-related jobs
540
gitlab:assets:compile:
541
  <<: *dedicated-runner
542
  <<: *except-docs
543
  <<: *except-qa
544 545
  <<: *pull-cache
  stage: test
546 547 548 549 550 551
  dependencies: []
  variables:
    NODE_ENV: "production"
    RAILS_ENV: "production"
    SETUP_DB: "false"
    SKIP_STORAGE_VALIDATION: "true"
552
    WEBPACK_REPORT: "true"
Mike Greiling's avatar
Mike Greiling committed
553
    NO_COMPRESSION: "true"
554
  script:
555
    - yarn install --frozen-lockfile --production --cache-folder .yarn-cache
556
    - bundle exec rake gitlab:assets:compile
557 558 559 560
  artifacts:
    name: webpack-report
    expire_in: 31d
    paths:
561
      - webpack-report/
562

563
karma:
564
  <<: *use-pg
565
  <<: *dedicated-runner
566
  <<: *except-docs
567
  <<: *except-qa
568 569
  <<: *pull-cache
  stage: test
570 571
  variables:
    BABEL_ENV: "coverage"
572
    CHROME_LOG_FILE: "chrome_debug.log"
573
  script:
Jacob Vosmaer's avatar
Jacob Vosmaer committed
574
    - scripts/gitaly-test-spawn
575
    - bundle exec rake gettext:po_to_json
576
    - bundle exec rake karma
577
  coverage: '/^Statements *: (\d+\.\d+%)/'
578 579 580
  artifacts:
    name: coverage-javascript
    expire_in: 31d
581
    when: always
582
    paths:
583
    - chrome_debug.log
584
    - coverage-javascript/
585

586
codequality:
587
  <<: *except-docs
588
  <<: *pull-cache
589 590 591 592 593 594 595 596 597
  before_script: []
  image: docker:latest
  stage: test
  variables:
    SETUP_DB: "false"
    DOCKER_DRIVER: overlay
  services:
    - docker:dind
  script:
598 599
    - cp .rubocop.yml .rubocop.yml.bak
    - grep -v "rubocop-gitlab-security" .rubocop.yml.bak > .rubocop.yml
600
    - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f json > raw_codeclimate.json
601
    - cat raw_codeclimate.json | docker run -i stedolan/jq -c 'map({check_name,fingerprint,location})' > codeclimate.json
602
    - mv .rubocop.yml.bak .rubocop.yml
603 604 605
  artifacts:
    paths: [codeclimate.json]

606
qa:internal:
607
  <<: *except-docs
608 609 610 611 612 613 614 615 616
  stage: test
  variables:
    SETUP_DB: "false"
  services: []
  script:
    - cd qa/
    - bundle install
    - bundle exec rspec

617
coverage:
618
  <<: *dedicated-runner
619
  <<: *except-docs
620
  <<: *except-qa
621 622 623
  <<: *pull-cache
  stage: post-test
  services: []
624 625 626 627 628
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "true"
  script:
    - bundle exec scripts/merge-simplecov
629
  coverage: '/LOC \((\d+\.\d+%)\) covered.$/'
630 631 632 633 634 635 636
  artifacts:
    name: coverage
    expire_in: 31d
    paths:
    - coverage/index.html
    - coverage/assets/

637
lint:javascript:report:
638
  <<: *dedicated-runner
639
  <<: *except-docs
640
  <<: *except-qa
641
  <<: *pull-cache
642
  stage: post-test
643 644
  dependencies:
    - setup-test-env
645
  before_script: []
646
  script:
647
    - find app/ spec/ -name '*.js' -exec sed --in-place 's|/\* eslint-disable .*\*/||' {} \; # run report over all files
648
    - yarn run eslint-report || true # ignore exit code
649 650 651 652 653
  artifacts:
    name: eslint-report
    expire_in: 31d
    paths:
    - eslint-report.html
654 655

pages:
656 657
  <<: *dedicated-runner
  <<: *pull-cache
658 659 660 661
  before_script: []
  stage: pages
  dependencies:
    - coverage
662 663
    - karma
    - gitlab:assets:compile
664
    - lint:javascript:report
665 666 667
  script:
    - mv public/ .public/
    - mkdir public/
668
    - mv coverage/ public/coverage-ruby/ || true
669
    - mv coverage-javascript/ public/coverage-javascript/ || true
670
    - mv eslint-report.html public/ || true
671
    - mv webpack-report/ public/webpack-report/ || true
672 673 674 675
  artifacts:
    paths:
      - public
  only:
676
    - master@gitlab-org/gitlab-ce
677
    - master@gitlab-org/gitlab-ee
678 679 680 681

# Insurance in case a gem needed by one of our releases gets yanked from
# rubygems.org in the future.
cache gems:
682
  <<: *dedicated-runner
683
  <<: *pull-cache
684 685 686 687 688 689 690 691 692
  only:
    - tags
  variables:
    SETUP_DB: "false"
  script:
    - bundle package --all --all-platforms
  artifacts:
    paths:
      - vendor/cache
693 694
  only:
    - master@gitlab-org/gitlab-ce
695
    - master@gitlab-org/gitlab-ee
696 697

gitlab_git_test:
698 699
  <<: *pull-cache
  <<: *except-docs
700
  <<: *except-qa
701 702 703 704
  variables:
    SETUP_DB: "false"
  script:
    - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes