.gitlab-ci.yml 18.4 KB
Newer Older
1
image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.5-golang-1.8-git-2.13-chrome-62.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
.rspec-metadata: &rspec-metadata
80
  <<: *dedicated-runner
81
  <<: *pull-cache
82
  <<: *except-docs
83
  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 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
93
    - export FLAKY_RSPEC_GENERATE_REPORT=true
94
    - export CACHE_CLASSES=true
95
    - cp ${KNAPSACK_RSPEC_SUITE_REPORT_PATH} ${KNAPSACK_REPORT_PATH}
96
    - '[[ -f $FLAKY_RSPEC_REPORT_PATH ]] || echo "{}" > ${FLAKY_RSPEC_REPORT_PATH}'
97
    - '[[ -f $NEW_FLAKY_RSPEC_REPORT_PATH ]] || echo "{}" > ${NEW_FLAKY_RSPEC_REPORT_PATH}'
Jacob Vosmaer's avatar
Jacob Vosmaer committed
98
    - scripts/gitaly-test-spawn
99 100 101
    - knapsack rspec "--color --format documentation"
  artifacts:
    expire_in: 31d
102
    when: always
103
    paths:
104 105
      - coverage/
      - knapsack/
106
      - rspec_flaky/
107
      - tmp/capybara/
108

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

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

117
.spinach-metadata: &spinach-metadata
118
  <<: *dedicated-runner
119
  <<: *pull-cache
120
  <<: *except-docs
121
  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 143
  <<: *use-pg

144 145
.spinach-metadata-mysql: &spinach-metadata-mysql
  <<: *spinach-metadata
146 147
  <<: *use-mysql

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

155
# Trigger a package build in omnibus-gitlab repository
156
build-package:
157
  image: ruby:2.4-alpine
158
  before_script: []
159
  stage: build
160
  cache: {}
161 162
  when: manual
  script:
163
    - scripts/trigger-build-omnibus
164 165 166
  only:
    - //@gitlab-org/gitlab-ce
    - //@gitlab-org/gitlab-ee
167

168 169 170
# Review docs base
.review-docs: &review-docs
  image: ruby:2.4-alpine
171 172
  before_script:
    - gem install gitlab --no-doc
173 174 175 176 177 178 179 180
    # 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: []
181
  variables:
182
    GIT_STRATEGY: none
183 184 185 186 187 188 189 190 191 192 193
  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
194 195
    # 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
196
    url: http://$DOCS_GITLAB_REPO_SUFFIX-$CI_COMMIT_REF_SLUG.$DOCS_REVIEW_APPS_DOMAIN/$DOCS_GITLAB_REPO_SUFFIX
197 198
    on_stop: review-docs-cleanup
  script:
199
    - ./trigger-build-docs deploy
200 201 202 203 204 205 206 207 208

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

211 212 213
# Retrieve knapsack and rspec_flaky reports
retrieve-tests-metadata:
  <<: *tests-metadata-state
214
  <<: *except-docs
215
  stage: prepare
216
  cache:
217
    key: tests_metadata
218
    policy: pull
219
  script:
220
    - mkdir -p knapsack/${CI_PROJECT_NAME}/
221 222
    - 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
223 224
    - '[[ -f $KNAPSACK_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_RSPEC_SUITE_REPORT_PATH}'
    - '[[ -f $KNAPSACK_SPINACH_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_SPINACH_SUITE_REPORT_PATH}'
225
    - mkdir -p rspec_flaky/
226 227
    - 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}'
228

229 230
update-tests-metadata:
  <<: *tests-metadata-state
231
  <<: *only-canonical-masters
232
  stage: post-test
233
  cache:
234
    key: tests_metadata
235 236
    paths:
      - knapsack/
237
      - rspec_flaky/
238
    policy: push
239
  script:
240
    - retry gem install fog-aws mime-types
241 242
    - 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
243
    - scripts/merge-reports ${FLAKY_RSPEC_SUITE_REPORT_PATH} rspec_flaky/all_*_*.json
244 245
    - '[[ -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'
246
    - rm -f knapsack/${CI_PROJECT_NAME}/*_node_*.json
247
    - rm -f rspec_flaky/all_*.json rspec_flaky/new_*.json
248 249 250 251 252 253 254 255 256

flaky-examples-check:
  <<: *dedicated-runner
  image: ruby:2.3-alpine
  services: []
  before_script: []
  variables:
    SETUP_DB: "false"
    USE_BUNDLE_INSTALL: "false"
257
    NEW_FLAKY_SPECS_REPORT: rspec_flaky/report-new.json
258 259
  stage: post-test
  allow_failure: yes
260
  retry: 0
261 262 263 264
  only:
    - branches
  except:
    - master
265
    - /(^docs[\/-].*|.*-docs$)/
266 267 268 269 270 271
  artifacts:
    expire_in: 30d
    paths:
      - rspec_flaky/
  script:
    - '[[ -f $NEW_FLAKY_SPECS_REPORT ]] || echo "{}" > ${NEW_FLAKY_SPECS_REPORT}'
272
    - scripts/merge-reports ${NEW_FLAKY_SPECS_REPORT} rspec_flaky/new_*_*.json
273
    - scripts/detect-new-flaky-examples $NEW_FLAKY_SPECS_REPORT
274 275

setup-test-env:
276
  <<: *use-pg
277
  <<: *dedicated-runner
278
  <<: *except-docs
279
  stage: prepare
280 281
  cache:
    <<: *default-cache
282
  script:
283
    - node --version
284
    - yarn install --frozen-lockfile --cache-folder .yarn-cache
Mike Greiling's avatar
Mike Greiling committed
285
    - bundle exec rake gitlab:assets:compile
286
    - bundle exec ruby -Ispec -e 'require "spec_helper" ; TestEnv.init'
Jacob Vosmaer's avatar
Jacob Vosmaer committed
287
    - scripts/gitaly-test-build # Do not use 'bundle exec' here
288 289 290
  artifacts:
    expire_in: 7d
    paths:
291
      - node_modules
292 293 294
      - public/assets
      - tmp/tests

295 296 297 298 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 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
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
358

359
# Static analysis jobs
360
.ruby-static-analysis: &ruby-static-analysis
361
  <<: *pull-cache
362 363 364 365
  variables:
    SIMPLECOV: "false"
    SETUP_DB: "false"

366
.rake-exec: &rake-exec
367
  <<: *ruby-static-analysis
368
  <<: *dedicated-runner
369
  <<: *except-docs
370
  <<: *pull-cache
371 372
  stage: test
  script:
373
    - bundle exec rake $CI_JOB_NAME
374

375
static-analysis:
376 377
  <<: *ruby-static-analysis
  <<: *dedicated-runner
378
  <<: *except-docs
379 380
  stage: test
  script:
381
    - scripts/static-analysis
382

383 384 385 386
# Documentation checks:
# - Check validity of relative links
# - Make sure cURL examples in API docs use the full switches
docs lint:
387
  <<: *dedicated-runner
388 389 390 391 392 393
  image: "registry.gitlab.com/gitlab-org/gitlab-build-images:nanoc-bootstrap-ruby-2.4-alpine"
  stage: test
  cache: {}
  dependencies: []
  before_script: []
  script:
394
    - scripts/lint-doc.sh
395
    - scripts/lint-changelog-yaml
396 397 398 399 400 401 402
    - mv doc/ /nanoc/content/
    - cd /nanoc
    # Build HTML from Markdown
    - bundle exec nanoc
    # Check the internal links
    - bundle exec nanoc check internal_links

403 404
downtime_check:
  <<: *rake-exec
405 406 407 408
  except:
    - master
    - tags
    - /^[\d-]+-stable(-ee)?$/
409
    - /(^docs[\/-].*|.*-docs$)/
410

411 412
ee_compat_check:
  <<: *rake-exec
413 414 415
  except:
    - master
    - tags
416
    - /^[\d-]+-stable(-ee)?/
417 418
    - branches@gitlab-org/gitlab-ee
    - branches@gitlab/gitlab-ee
419
  allow_failure: no
420
  retry: 0
421
  artifacts:
422
    name: "${CI_JOB_NAME}_${CI_COMIT_REF_NAME}_${CI_COMMIT_SHA}"
423 424 425 426 427
    when: on_failure
    expire_in: 10d
    paths:
      - ee_compat_check/patches/*.patch

428
# DB migration, rollback, and seed jobs
429
.db-migrate-reset: &db-migrate-reset
430
  <<: *dedicated-runner
431
  <<: *except-docs
432 433
  <<: *pull-cache
  stage: test
434
  script:
435
    - bundle exec rake db:migrate:reset
436

437
db:migrate:reset-pg:
438 439 440
  <<: *db-migrate-reset
  <<: *use-pg

441
db:migrate:reset-mysql:
442 443 444
  <<: *db-migrate-reset
  <<: *use-mysql

445 446
.migration-paths: &migration-paths
  <<: *dedicated-runner
447
  <<: *pull-cache
448
  <<: *except-docs
449
  stage: test
450 451
  variables:
    SETUP_DB: "false"
452
    CREATE_DB_USER: "true"
453
  script:
454
    - git fetch https://gitlab.com/gitlab-org/gitlab-ce.git v9.3.0
455 456
    - git checkout -f FETCH_HEAD
    - bundle install $BUNDLE_INSTALL_FLAGS
457
    - cp config/gitlab.yml.example config/gitlab.yml
458 459 460 461 462 463 464 465 466 467 468 469 470 471
    - 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

472
.db-rollback: &db-rollback
473
  <<: *dedicated-runner
474
  <<: *except-docs
475 476
  <<: *pull-cache
  stage: test
477
  script:
478
    - bundle exec rake db:rollback STEP=119
479
    - bundle exec rake db:migrate
480

481
db:rollback-pg:
482 483 484
  <<: *db-rollback
  <<: *use-pg

485
db:rollback-mysql:
486 487 488 489
  <<: *db-rollback
  <<: *use-mysql

.db-seed_fu: &db-seed_fu
490
  <<: *dedicated-runner
491
  <<: *except-docs
492 493
  <<: *pull-cache
  stage: test
494 495 496
  variables:
    SIZE: "1"
    SETUP_DB: "false"
497
    CREATE_DB_USER: "true"
498 499 500 501 502 503 504 505 506 507
  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

508
db:seed_fu-pg:
509 510 511
  <<: *db-seed_fu
  <<: *use-pg

512
db:seed_fu-mysql:
513 514 515
  <<: *db-seed_fu
  <<: *use-mysql

516 517 518 519 520 521
db:check-schema-pg:
  <<: *db-migrate-reset
  <<: *use-pg
  script:
    - source scripts/schema_changed.sh

522
# Frontend-related jobs
523
gitlab:assets:compile:
524
  <<: *dedicated-runner
525
  <<: *except-docs
526 527
  <<: *pull-cache
  stage: test
528 529 530 531 532 533
  dependencies: []
  variables:
    NODE_ENV: "production"
    RAILS_ENV: "production"
    SETUP_DB: "false"
    SKIP_STORAGE_VALIDATION: "true"
534
    WEBPACK_REPORT: "true"
Mike Greiling's avatar
Mike Greiling committed
535
    NO_COMPRESSION: "true"
536
  script:
537
    - yarn install --frozen-lockfile --production --cache-folder .yarn-cache
538
    - bundle exec rake gitlab:assets:compile
539 540 541 542
  artifacts:
    name: webpack-report
    expire_in: 31d
    paths:
543
      - webpack-report/
544

545
karma:
546
  <<: *use-pg
547
  <<: *dedicated-runner
548
  <<: *except-docs
549 550
  <<: *pull-cache
  stage: test
551 552
  variables:
    BABEL_ENV: "coverage"
553
    CHROME_LOG_FILE: "chrome_debug.log"
554
  script:
Jacob Vosmaer's avatar
Jacob Vosmaer committed
555
    - scripts/gitaly-test-spawn
556
    - bundle exec rake gettext:po_to_json
557
    - bundle exec rake karma
558
  coverage: '/^Statements *: (\d+\.\d+%)/'
559 560 561
  artifacts:
    name: coverage-javascript
    expire_in: 31d
562
    when: always
563
    paths:
564
    - chrome_debug.log
565
    - coverage-javascript/
566

567
codequality:
568
  <<: *except-docs
569
  <<: *pull-cache
570 571 572 573 574 575 576 577 578
  before_script: []
  image: docker:latest
  stage: test
  variables:
    SETUP_DB: "false"
    DOCKER_DRIVER: overlay
  services:
    - docker:dind
  script:
579 580
    - cp .rubocop.yml .rubocop.yml.bak
    - grep -v "rubocop-gitlab-security" .rubocop.yml.bak > .rubocop.yml
581
    - 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:0.69.0 analyze -f json > raw_codeclimate.json
582
    - cat raw_codeclimate.json | docker run -i stedolan/jq -c 'map({check_name,fingerprint,location})' > codeclimate.json
583
    - mv .rubocop.yml.bak .rubocop.yml
584 585 586
  artifacts:
    paths: [codeclimate.json]

587 588 589 590 591 592 593 594 595 596
qa:internal:
  stage: test
  variables:
    SETUP_DB: "false"
  services: []
  script:
    - cd qa/
    - bundle install
    - bundle exec rspec

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

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

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

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

gitlab_git_test:
676 677
  <<: *pull-cache
  <<: *except-docs
678 679 680 681
  variables:
    SETUP_DB: "false"
  script:
    - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes