.gitlab-ci.yml 18.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
Zeger-Jan van de Weg's avatar
Zeger-Jan van de Weg committed
9
  key: "ruby-235-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
    - 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 84 85 86 87
.except-docs-and-qa: &except-docs-and-qa
  except:
    - /(^docs[\/-].*|.*-docs$)/
    - /(^qa[\/-].*|.*-qa$)/

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

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

122 123
.rspec-metadata-mysql: &rspec-metadata-mysql
  <<: *rspec-metadata
124 125
  <<: *use-mysql

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

149 150
.spinach-metadata-pg: &spinach-metadata-pg
  <<: *spinach-metadata
151 152
  <<: *use-pg

153 154
.spinach-metadata-mysql: &spinach-metadata-mysql
  <<: *spinach-metadata
155 156
  <<: *use-mysql

157 158 159 160 161 162 163
.only-canonical-masters: &only-canonical-masters
  only:
    - master@gitlab-org/gitlab-ce
    - master@gitlab-org/gitlab-ee
    - master@gitlab/gitlabhq
    - master@gitlab/gitlab-ee

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

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

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

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

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

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

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

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 369 370 371 372
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
373

374
# Static analysis jobs
375
.ruby-static-analysis: &ruby-static-analysis
376
  <<: *pull-cache
377 378 379 380
  variables:
    SIMPLECOV: "false"
    SETUP_DB: "false"

381
.rake-exec: &rake-exec
382
  <<: *dedicated-runner
383
  <<: *except-docs-and-qa
384
  <<: *pull-cache
385
  <<: *ruby-static-analysis
386 387
  stage: test
  script:
388
    - bundle exec rake $CI_JOB_NAME
389

390
static-analysis:
391
  <<: *dedicated-runner
392
  <<: *except-docs
393
  <<: *ruby-static-analysis
394 395
  stage: test
  script:
396
    - scripts/static-analysis
397

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

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

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

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

453
db:migrate:reset-pg:
454 455 456
  <<: *db-migrate-reset
  <<: *use-pg

457
db:migrate:reset-mysql:
458 459 460
  <<: *db-migrate-reset
  <<: *use-mysql

461 462 463 464 465 466
db:check-schema-pg:
  <<: *db-migrate-reset
  <<: *use-pg
  script:
    - source scripts/schema_changed.sh

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

494
.db-rollback: &db-rollback
495
  <<: *dedicated-runner
496
  <<: *except-docs-and-qa
497 498
  <<: *pull-cache
  stage: test
499
  script:
500
    - bundle exec rake db:rollback STEP=119
501
    - bundle exec rake db:migrate
502

503
db:rollback-pg:
504 505 506
  <<: *db-rollback
  <<: *use-pg

507
db:rollback-mysql:
508 509 510 511
  <<: *db-rollback
  <<: *use-mysql

.db-seed_fu: &db-seed_fu
512
  <<: *dedicated-runner
513
  <<: *except-docs-and-qa
514 515
  <<: *pull-cache
  stage: test
516 517 518
  variables:
    SIZE: "1"
    SETUP_DB: "false"
519
    CREATE_DB_USER: "true"
520 521 522 523 524 525 526 527 528 529
  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

530
db:seed_fu-pg:
531 532 533
  <<: *db-seed_fu
  <<: *use-pg

534
db:seed_fu-mysql:
535 536 537
  <<: *db-seed_fu
  <<: *use-mysql

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

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

583
codequality:
584
  <<: *except-docs
585
  <<: *pull-cache
586 587 588 589 590 591 592 593 594
  before_script: []
  image: docker:latest
  stage: test
  variables:
    SETUP_DB: "false"
    DOCKER_DRIVER: overlay
  services:
    - docker:dind
  script:
595 596
    - 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
597
    - 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
598
    - cat raw_codeclimate.json | docker run -i stedolan/jq -c 'map({check_name,fingerprint,location})' > codeclimate.json
599
    - mv .rubocop.yml.bak .rubocop.yml
600 601 602
  artifacts:
    paths: [codeclimate.json]

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

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

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

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

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

gitlab_git_test:
694
  <<: *dedicated-runner
695
  <<: *except-docs-and-qa
696
  <<: *pull-cache
697 698 699 700
  variables:
    SETUP_DB: "false"
  script:
    - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes