.gitlab-ci.yml 18.7 KB
Newer Older
1
image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.3-golang-1.8-git-2.13-phantomjs-2.1-node-8.x-yarn-1.0-postgresql-9.6"
2

3
.default-cache: &default-cache
4
  key: "ruby-233-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
  PHANTOMJS_VERSION: "2.1.1"
27
  GET_SOURCES_ATTEMPTS: "3"
28 29
  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
30
  FLAKY_RSPEC_SUITE_REPORT_PATH: rspec_flaky/${CI_PROJECT_NAME}/report-master.json
31

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

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

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

51
.tests-metadata-state: &tests-metadata-state
52 53 54 55
  services: []
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "false"
56
    TESTS_METADATA_S3_BUCKET: "gitlab-ce-cache"
57 58 59
  artifacts:
    expire_in: 31d
    paths:
60
      - knapsack/
61
      - rspec_flaky/
62

63 64
.use-pg: &use-pg
  services:
65
    - postgres:9.2
66 67 68
    - redis:alpine

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

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

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

108 109
.rspec-metadata-pg: &rspec-metadata-pg
  <<: *rspec-metadata
110
  <<: *use-pg
111
  <<: *except-docs
112

113 114
.rspec-metadata-mysql: &rspec-metadata-mysql
  <<: *rspec-metadata
115
  <<: *use-mysql
116
  <<: *except-docs
117

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

140 141
.spinach-metadata-pg: &spinach-metadata-pg
  <<: *spinach-metadata
142
  <<: *use-pg
143
  <<: *except-docs
144

145 146
.spinach-metadata-mysql: &spinach-metadata-mysql
  <<: *spinach-metadata
147
  <<: *use-mysql
148
  <<: *except-docs
149

150 151 152 153 154 155 156
.only-canonical-masters: &only-canonical-masters
  only:
    - master@gitlab-org/gitlab-ce
    - master@gitlab-org/gitlab-ee
    - master@gitlab/gitlabhq
    - master@gitlab/gitlab-ee

157
# Trigger a package build in omnibus-gitlab repository
158
build-package:
159
  image: ruby:2.3-alpine
160
  before_script: []
161 162 163 164 165
  services: []
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "false"
  stage: build
166
  cache: {}
167 168
  when: manual
  script:
169
    - scripts/trigger-build-omnibus
170 171 172
  only:
    - //@gitlab-org/gitlab-ce
    - //@gitlab-org/gitlab-ee
173

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

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

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

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

flaky-examples-check:
  <<: *dedicated-runner
  image: ruby:2.3-alpine
  services: []
  before_script: []
  cache: {}
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "false"
    NEW_FLAKY_SPECS_REPORT: rspec_flaky/${CI_PROJECT_NAME}/new_rspec_flaky_examples.json
  stage: post-test
  allow_failure: yes
  only:
    - branches
  except:
    - master
277
    - /(^docs[\/-].*|.*-docs$)/
278 279 280 281 282 283 284 285
  artifacts:
    expire_in: 30d
    paths:
      - rspec_flaky/
  script:
    - '[[ -f $NEW_FLAKY_SPECS_REPORT ]] || echo "{}" > ${NEW_FLAKY_SPECS_REPORT}'
    - scripts/merge-reports $NEW_FLAKY_SPECS_REPORT rspec_flaky/${CI_PROJECT_NAME}/new_node_*.json
    - scripts/detect-new-flaky-examples $NEW_FLAKY_SPECS_REPORT
286 287

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

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
rspec-pg 0 25: *rspec-metadata-pg
rspec-pg 1 25: *rspec-metadata-pg
rspec-pg 2 25: *rspec-metadata-pg
rspec-pg 3 25: *rspec-metadata-pg
rspec-pg 4 25: *rspec-metadata-pg
rspec-pg 5 25: *rspec-metadata-pg
rspec-pg 6 25: *rspec-metadata-pg
rspec-pg 7 25: *rspec-metadata-pg
rspec-pg 8 25: *rspec-metadata-pg
rspec-pg 9 25: *rspec-metadata-pg
rspec-pg 10 25: *rspec-metadata-pg
rspec-pg 11 25: *rspec-metadata-pg
rspec-pg 12 25: *rspec-metadata-pg
rspec-pg 13 25: *rspec-metadata-pg
rspec-pg 14 25: *rspec-metadata-pg
rspec-pg 15 25: *rspec-metadata-pg
rspec-pg 16 25: *rspec-metadata-pg
rspec-pg 17 25: *rspec-metadata-pg
rspec-pg 18 25: *rspec-metadata-pg
rspec-pg 19 25: *rspec-metadata-pg
rspec-pg 20 25: *rspec-metadata-pg
rspec-pg 21 25: *rspec-metadata-pg
rspec-pg 22 25: *rspec-metadata-pg
rspec-pg 23 25: *rspec-metadata-pg
rspec-pg 24 25: *rspec-metadata-pg
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
rspec-mysql 0 25: *rspec-metadata-mysql
rspec-mysql 1 25: *rspec-metadata-mysql
rspec-mysql 2 25: *rspec-metadata-mysql
rspec-mysql 3 25: *rspec-metadata-mysql
rspec-mysql 4 25: *rspec-metadata-mysql
rspec-mysql 5 25: *rspec-metadata-mysql
rspec-mysql 6 25: *rspec-metadata-mysql
rspec-mysql 7 25: *rspec-metadata-mysql
rspec-mysql 8 25: *rspec-metadata-mysql
rspec-mysql 9 25: *rspec-metadata-mysql
rspec-mysql 10 25: *rspec-metadata-mysql
rspec-mysql 11 25: *rspec-metadata-mysql
rspec-mysql 12 25: *rspec-metadata-mysql
rspec-mysql 13 25: *rspec-metadata-mysql
rspec-mysql 14 25: *rspec-metadata-mysql
rspec-mysql 15 25: *rspec-metadata-mysql
rspec-mysql 16 25: *rspec-metadata-mysql
rspec-mysql 17 25: *rspec-metadata-mysql
rspec-mysql 18 25: *rspec-metadata-mysql
rspec-mysql 19 25: *rspec-metadata-mysql
rspec-mysql 20 25: *rspec-metadata-mysql
rspec-mysql 21 25: *rspec-metadata-mysql
rspec-mysql 22 25: *rspec-metadata-mysql
rspec-mysql 23 25: *rspec-metadata-mysql
rspec-mysql 24 25: *rspec-metadata-mysql
358

359 360 361 362 363
spinach-pg 0 5: *spinach-metadata-pg
spinach-pg 1 5: *spinach-metadata-pg
spinach-pg 2 5: *spinach-metadata-pg
spinach-pg 3 5: *spinach-metadata-pg
spinach-pg 4 5: *spinach-metadata-pg
364

365 366 367 368 369
spinach-mysql 0 5: *spinach-metadata-mysql
spinach-mysql 1 5: *spinach-metadata-mysql
spinach-mysql 2 5: *spinach-metadata-mysql
spinach-mysql 3 5: *spinach-metadata-mysql
spinach-mysql 4 5: *spinach-metadata-mysql
370

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

378
.rake-exec: &rake-exec
379
  <<: *ruby-static-analysis
380
  <<: *dedicated-runner
381
  <<: *except-docs
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 401 402 403 404 405
  image: "registry.gitlab.com/gitlab-org/gitlab-build-images:nanoc-bootstrap-ruby-2.4-alpine"
  stage: test
  cache: {}
  dependencies: []
  before_script: []
  script:
406
    - scripts/lint-doc.sh
407 408 409 410 411 412 413
    - mv doc/ /nanoc/content/
    - cd /nanoc
    # Build HTML from Markdown
    - bundle exec nanoc
    # Check the internal links
    - bundle exec nanoc check internal_links

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

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

442
# DB migration, rollback, and seed jobs
443
.db-migrate-reset: &db-migrate-reset
444
  <<: *dedicated-runner
445
  <<: *except-docs
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
  stage: test
464 465 466 467 468 469
  variables:
    SETUP_DB: "false"
  script:
    - git fetch origin v8.14.10
    - git checkout -f FETCH_HEAD
    - bundle install $BUNDLE_INSTALL_FLAGS
470
    - cp config/gitlab.yml.example config/gitlab.yml
471 472 473 474 475 476 477 478 479 480 481 482 483 484
    - 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

485
.db-rollback: &db-rollback
486
  <<: *dedicated-runner
487
  <<: *except-docs
488 489
  <<: *pull-cache
  stage: test
490
  script:
491 492
    - bundle exec rake db:rollback STEP=120
    - bundle exec rake db:migrate
493

494
db:rollback-pg:
495 496 497
  <<: *db-rollback
  <<: *use-pg

498
db:rollback-mysql:
499 500 501 502
  <<: *db-rollback
  <<: *use-mysql

.db-seed_fu: &db-seed_fu
503
  <<: *dedicated-runner
504
  <<: *except-docs
505 506
  <<: *pull-cache
  stage: test
507 508 509 510 511 512 513 514 515 516 517 518 519
  variables:
    SIZE: "1"
    SETUP_DB: "false"
  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

520
db:seed_fu-pg:
521 522 523
  <<: *db-seed_fu
  <<: *use-pg

524
db:seed_fu-mysql:
525 526 527
  <<: *db-seed_fu
  <<: *use-mysql

528 529 530 531 532 533
db:check-schema-pg:
  <<: *db-migrate-reset
  <<: *use-pg
  script:
    - source scripts/schema_changed.sh

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

558
karma:
559
  <<: *use-pg
560
  <<: *dedicated-runner
561
  <<: *except-docs
562
  <<: *pull-cache
563
  image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.3-golang-1.8-git-2.13-chrome-61.0-node-8.x-yarn-1.0-postgresql-9.6"
564
  stage: test
565 566
  variables:
    BABEL_ENV: "coverage"
567
    CHROME_LOG_FILE: "chrome_debug.log"
568
  script:
Jacob Vosmaer's avatar
Jacob Vosmaer committed
569
    - scripts/gitaly-test-spawn
570
    - bundle exec rake gettext:po_to_json
571
    - bundle exec rake karma
572
  coverage: '/^Statements *: (\d+\.\d+%)/'
573 574 575
  artifacts:
    name: coverage-javascript
    expire_in: 31d
576
    when: always
577
    paths:
578
    - chrome_debug.log
579
    - coverage-javascript/
580

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

601
coverage:
602
  <<: *dedicated-runner
603
  <<: *except-docs
604 605 606
  <<: *pull-cache
  stage: post-test
  services: []
607 608 609 610 611
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "true"
  script:
    - bundle exec scripts/merge-simplecov
612
  coverage: '/LOC \((\d+\.\d+%)\) covered.$/'
613 614 615 616 617 618 619
  artifacts:
    name: coverage
    expire_in: 31d
    paths:
    - coverage/index.html
    - coverage/assets/

620
lint:javascript:report:
621
  <<: *dedicated-runner
622
  <<: *except-docs
623
  <<: *pull-cache
624
  stage: post-test
625 626
  dependencies:
    - setup-test-env
627
  before_script: []
628
  script:
629
    - find app/ spec/ -name '*.js' -exec sed --in-place 's|/\* eslint-disable .*\*/||' {} \; # run report over all files
630
    - yarn run eslint-report || true # ignore exit code
631 632 633 634 635
  artifacts:
    name: eslint-report
    expire_in: 31d
    paths:
    - eslint-report.html
636 637

pages:
638 639
  <<: *dedicated-runner
  <<: *pull-cache
640 641 642 643
  before_script: []
  stage: pages
  dependencies:
    - coverage
644 645
    - karma
    - gitlab:assets:compile
646
    - lint:javascript:report
647 648 649
  script:
    - mv public/ .public/
    - mkdir public/
650
    - mv coverage/ public/coverage-ruby/ || true
651
    - mv coverage-javascript/ public/coverage-javascript/ || true
652
    - mv eslint-report.html public/ || true
653
    - mv webpack-report/ public/webpack-report/ || true
654 655 656 657
  artifacts:
    paths:
      - public
  only:
658
    - master@gitlab-org/gitlab-ce
659
    - master@gitlab-org/gitlab-ee
660 661 662 663

# Insurance in case a gem needed by one of our releases gets yanked from
# rubygems.org in the future.
cache gems:
664
  <<: *dedicated-runner
665
  <<: *pull-cache
666 667 668 669 670 671 672 673 674
  only:
    - tags
  variables:
    SETUP_DB: "false"
  script:
    - bundle package --all --all-platforms
  artifacts:
    paths:
      - vendor/cache
675 676
  only:
    - master@gitlab-org/gitlab-ce
677
    - master@gitlab-org/gitlab-ee
678 679

gitlab_git_test:
680 681
  <<: *pull-cache
  <<: *except-docs
682 683 684 685
  variables:
    SETUP_DB: "false"
  script:
    - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes