.gitlab-ci.yml 17.5 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-7.1-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

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

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

61 62
.use-pg: &use-pg
  services:
63
    - postgres:9.2
64 65 66
    - redis:alpine

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

71
.only-if-want-mysql: &only-if-want-mysql
72
  only:
73
    - /mysql/
74
    - /-stable/
75
    - master@gitlab-org/gitlab-ce
76
    - master@gitlab-org/gitlab-ee
77
    - master@gitlab/gitlabhq
78
    - master@gitlab/gitlab-ee
79
    - tags@gitlab-org/gitlab-ce
80
    - tags@gitlab-org/gitlab-ee
81
    - tags@gitlab/gitlabhq
82
    - tags@gitlab/gitlab-ee
83

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

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

119 120
.rspec-metadata-pg: &rspec-metadata-pg
  <<: *rspec-metadata
121
  <<: *use-pg
122
  <<: *except-docs
123

124 125
.rspec-metadata-mysql: &rspec-metadata-mysql
  <<: *rspec-metadata
126
  <<: *use-mysql
127
  <<: *only-if-want-mysql
128
  <<: *except-docs
129

130
.spinach-metadata: &spinach-metadata
131
  <<: *dedicated-runner
132 133
  <<: *pull-cache
  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}
142 143 144
    - knapsack spinach "-r rerun" || retry '[[ -e tmp/spinach-rerun.txt ]] && bundle exec spinach -r rerun $(cat tmp/spinach-rerun.txt)'
  artifacts:
    expire_in: 31d
145
    when: always
146
    paths:
147 148 149
      - coverage/
      - knapsack/
      - tmp/capybara/
150

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

156 157
.spinach-metadata-mysql: &spinach-metadata-mysql
  <<: *spinach-metadata
158
  <<: *use-mysql
159
  <<: *only-if-want-mysql
160
  <<: *except-docs
161

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

169 170 171
# Trigger a package build on omnibus-gitlab repository

build-package:
172
  image: ruby:2.3-alpine
173
  before_script: []
174 175 176 177 178
  services: []
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "false"
  stage: build
179
  cache: {}
180 181
  when: manual
  script:
182
    - scripts/trigger-build
183 184 185
  only:
    - //@gitlab-org/gitlab-ce
    - //@gitlab-org/gitlab-ee
186

187 188 189
# Retrieve knapsack and rspec_flaky reports
retrieve-tests-metadata:
  <<: *tests-metadata-state
190
  <<: *dedicated-runner
191
  <<: *except-docs
192
  stage: prepare
193
  cache:
194
    key: tests_metadata
195
    policy: pull
196
  script:
197
    - mkdir -p knapsack/${CI_PROJECT_NAME}/
198 199
    - 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
200 201
    - '[[ -f $KNAPSACK_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_RSPEC_SUITE_REPORT_PATH}'
    - '[[ -f $KNAPSACK_SPINACH_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_SPINACH_SUITE_REPORT_PATH}'
202 203 204
    - 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}'
205

206 207
update-tests-metadata:
  <<: *tests-metadata-state
208
  <<: *dedicated-runner
209
  <<: *only-canonical-masters
210
  stage: post-test
211
  cache:
212
    key: tests_metadata
213 214
    paths:
      - knapsack/
215
      - rspec_flaky/
216
    policy: push
217
  script:
218
    - retry gem install fog-aws mime-types
219 220
    - 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
221 222 223
    - 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'
224
    - rm -f knapsack/${CI_PROJECT_NAME}/*_node_*.json
225 226 227 228
    - rm -f rspec_flaky/${CI_PROJECT_NAME}/all_node_*.json

flaky-examples-check:
  <<: *dedicated-runner
229
  <<: *except-docs
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
  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
  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
252 253

setup-test-env:
254
  <<: *use-pg
255
  <<: *dedicated-runner
256
  <<: *except-docs
257
  stage: prepare
258 259
  cache:
    <<: *default-cache
260
  script:
261
    - node --version
262
    - yarn install --pure-lockfile --cache-folder .yarn-cache
263
    - bundle exec rake gettext:po_to_json
Mike Greiling's avatar
Mike Greiling committed
264
    - bundle exec rake gitlab:assets:compile
265
    - bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init'
Jacob Vosmaer's avatar
Jacob Vosmaer committed
266
    - scripts/gitaly-test-build # Do not use 'bundle exec' here
267 268 269
  artifacts:
    expire_in: 7d
    paths:
270
      - node_modules
271 272 273
      - public/assets
      - tmp/tests

274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
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
299

300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
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
325

326 327 328 329 330
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
331

332 333 334 335 336
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
337

338
# Static analysis jobs
339
.ruby-static-analysis: &ruby-static-analysis
340
  <<: *pull-cache
341 342 343 344
  variables:
    SIMPLECOV: "false"
    SETUP_DB: "false"

345
.rake-exec: &rake-exec
346
  <<: *ruby-static-analysis
347
  <<: *dedicated-runner
348
  <<: *except-docs
349
  <<: *pull-cache
350 351
  stage: test
  script:
352
    - bundle exec rake $CI_JOB_NAME
353

354
static-analysis:
355 356
  <<: *ruby-static-analysis
  <<: *dedicated-runner
357
  <<: *except-docs
358 359
  stage: test
  script:
360
    - scripts/static-analysis
361

362 363 364 365
# Documentation checks:
# - Check validity of relative links
# - Make sure cURL examples in API docs use the full switches
docs lint:
366
  <<: *dedicated-runner
367 368 369 370 371 372
  image: "registry.gitlab.com/gitlab-org/gitlab-build-images:nanoc-bootstrap-ruby-2.4-alpine"
  stage: test
  cache: {}
  dependencies: []
  before_script: []
  script:
373
    - scripts/lint-doc.sh
374 375 376 377 378 379 380
    - mv doc/ /nanoc/content/
    - cd /nanoc
    # Build HTML from Markdown
    - bundle exec nanoc
    # Check the internal links
    - bundle exec nanoc check internal_links

381 382
downtime_check:
  <<: *rake-exec
383 384 385 386
  except:
    - master
    - tags
    - /^[\d-]+-stable(-ee)?$/
387
    - /(^docs[\/-].*|.*-docs$)/
388

389 390
ee_compat_check:
  <<: *rake-exec
391 392 393 394 395
  only:
    - branches@gitlab-org/gitlab-ce
  except:
    - master
    - tags
396
    - /^[\d-]+-stable(-ee)?/
397 398
  allow_failure: yes
  cache:
399
    key: "ee_compat_check_repo"
400
    paths:
401
      - ee_compat_check/ee-repo/
402
  artifacts:
403
    name: "${CI_JOB_NAME}_${CI_COMIT_REF_NAME}_${CI_COMMIT_SHA}"
404 405 406 407 408
    when: on_failure
    expire_in: 10d
    paths:
      - ee_compat_check/patches/*.patch

409
# DB migration, rollback, and seed jobs
410
.db-migrate-reset: &db-migrate-reset
411
  <<: *dedicated-runner
412
  <<: *except-docs
413 414
  <<: *pull-cache
  stage: test
415
  script:
416
    - bundle exec rake db:migrate:reset
417

418
db:migrate:reset-pg:
419 420 421
  <<: *db-migrate-reset
  <<: *use-pg

422
db:migrate:reset-mysql:
423 424 425
  <<: *db-migrate-reset
  <<: *use-mysql

426 427
.migration-paths: &migration-paths
  <<: *dedicated-runner
428 429 430
  <<: *only-canonical-masters
  <<: *pull-cache
  stage: test
431 432 433 434 435 436
  variables:
    SETUP_DB: "false"
  script:
    - git fetch origin v8.14.10
    - git checkout -f FETCH_HEAD
    - bundle install $BUNDLE_INSTALL_FLAGS
437
    - cp config/gitlab.yml.example config/gitlab.yml
438 439 440 441 442 443 444 445 446 447 448 449 450 451
    - 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

452
.db-rollback: &db-rollback
453
  <<: *dedicated-runner
454
  <<: *except-docs
455 456
  <<: *pull-cache
  stage: test
457
  script:
458 459
    - bundle exec rake db:rollback STEP=120
    - bundle exec rake db:migrate
460

461
db:rollback-pg:
462 463 464
  <<: *db-rollback
  <<: *use-pg

465
db:rollback-mysql:
466 467 468 469
  <<: *db-rollback
  <<: *use-mysql

.db-seed_fu: &db-seed_fu
470
  <<: *dedicated-runner
471
  <<: *except-docs
472 473
  <<: *pull-cache
  stage: test
474 475 476 477 478 479 480 481 482 483 484 485 486
  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

487
db:seed_fu-pg:
488 489 490
  <<: *db-seed_fu
  <<: *use-pg

491
db:seed_fu-mysql:
492 493 494
  <<: *db-seed_fu
  <<: *use-mysql

495
# Frontend-related jobs
496
gitlab:assets:compile:
497
  <<: *dedicated-runner
498
  <<: *except-docs
499 500
  <<: *pull-cache
  stage: test
501 502 503 504 505 506 507
  dependencies: []
  variables:
    NODE_ENV: "production"
    RAILS_ENV: "production"
    SETUP_DB: "false"
    USE_DB: "false"
    SKIP_STORAGE_VALIDATION: "true"
508
    WEBPACK_REPORT: "true"
Mike Greiling's avatar
Mike Greiling committed
509
    NO_COMPRESSION: "true"
510
  script:
511
    - yarn install --pure-lockfile --production --cache-folder .yarn-cache
512
    - bundle exec rake gettext:po_to_json
513
    - bundle exec rake gitlab:assets:compile
514 515 516 517
  artifacts:
    name: webpack-report
    expire_in: 31d
    paths:
518
      - webpack-report/
519

520
karma:
521
  <<: *use-pg
522
  <<: *dedicated-runner
523
  <<: *except-docs
524
  <<: *pull-cache
525
  image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.3-golang-1.8-git-2.13-chrome-60.0-node-7.1-postgresql-9.6"
526
  stage: test
527 528
  variables:
    BABEL_ENV: "coverage"
529
    CHROME_LOG_FILE: "chrome_debug.log"
530
  script:
Jacob Vosmaer's avatar
Jacob Vosmaer committed
531
    - scripts/gitaly-test-spawn
532
    - bundle exec rake gettext:po_to_json
533
    - bundle exec rake karma
534
  coverage: '/^Statements *: (\d+\.\d+%)/'
535 536 537
  artifacts:
    name: coverage-javascript
    expire_in: 31d
538
    when: always
539
    paths:
540
    - chrome_debug.log
541
    - coverage-javascript/
542

543
codeclimate:
544
  <<: *except-docs
545
  <<: *pull-cache
546 547 548 549 550 551 552 553 554
  before_script: []
  image: docker:latest
  stage: test
  variables:
    SETUP_DB: "false"
    DOCKER_DRIVER: overlay
  services:
    - docker:dind
  script:
555 556
    - cp .rubocop.yml .rubocop.yml.bak
    - grep -v "rubocop-gitlab-security" .rubocop.yml.bak > .rubocop.yml
557
    - 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
558
    - cat raw_codeclimate.json | docker run -i stedolan/jq -c 'map({check_name,fingerprint,location})' > codeclimate.json
559
    - mv .rubocop.yml.bak .rubocop.yml
560 561 562
  artifacts:
    paths: [codeclimate.json]

563
coverage:
564
  <<: *dedicated-runner
565
  <<: *except-docs
566 567 568
  <<: *pull-cache
  stage: post-test
  services: []
569 570 571 572 573
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "true"
  script:
    - bundle exec scripts/merge-simplecov
574
  coverage: '/LOC \((\d+\.\d+%)\) covered.$/'
575 576 577 578 579 580 581
  artifacts:
    name: coverage
    expire_in: 31d
    paths:
    - coverage/index.html
    - coverage/assets/

582
lint:javascript:report:
583
  <<: *dedicated-runner
584
  <<: *except-docs
585
  <<: *pull-cache
586
  stage: post-test
587 588
  dependencies:
    - setup-test-env
589
  before_script: []
590
  script:
591
    - find app/ spec/ -name '*.js' -exec sed --in-place 's|/\* eslint-disable .*\*/||' {} \; # run report over all files
592
    - yarn run eslint-report || true # ignore exit code
593 594 595 596 597
  artifacts:
    name: eslint-report
    expire_in: 31d
    paths:
    - eslint-report.html
598 599

pages:
600 601
  <<: *dedicated-runner
  <<: *pull-cache
602 603 604 605
  before_script: []
  stage: pages
  dependencies:
    - coverage
606 607
    - karma
    - gitlab:assets:compile
608
    - lint:javascript:report
609 610 611
  script:
    - mv public/ .public/
    - mkdir public/
612
    - mv coverage/ public/coverage-ruby/ || true
613
    - mv coverage-javascript/ public/coverage-javascript/ || true
614
    - mv eslint-report.html public/ || true
615
    - mv webpack-report/ public/webpack-report/ || true
616 617 618 619
  artifacts:
    paths:
      - public
  only:
620
    - master@gitlab-org/gitlab-ce
621
    - master@gitlab-org/gitlab-ee
622 623 624 625

# Insurance in case a gem needed by one of our releases gets yanked from
# rubygems.org in the future.
cache gems:
626
  <<: *dedicated-runner
627
  <<: *pull-cache
628 629 630 631 632 633 634 635 636
  only:
    - tags
  variables:
    SETUP_DB: "false"
  script:
    - bundle package --all --all-platforms
  artifacts:
    paths:
      - vendor/cache
637 638
  only:
    - master@gitlab-org/gitlab-ce
639
    - master@gitlab-org/gitlab-ee
640 641

gitlab_git_test:
642 643
  <<: *pull-cache
  <<: *except-docs
644 645 646 647
  variables:
    SETUP_DB: "false"
  script:
    - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes