GitLab wurde erfolgreich aktualisiert. Durch regelmäßige Updates bleibt das THM GitLab sicher. Danke für Ihre Geduld.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 358
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
359

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

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

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

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

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

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

433
# DB migration, rollback, and seed jobs
434
.db-migrate-reset: &db-migrate-reset
435
  <<: *dedicated-runner
436
  <<: *except-docs
437 438
  <<: *pull-cache
  stage: test
439
  script:
440
    - bundle exec rake db:migrate:reset
441

442
db:migrate:reset-pg:
443 444 445
  <<: *db-migrate-reset
  <<: *use-pg

446
db:migrate:reset-mysql:
447 448 449
  <<: *db-migrate-reset
  <<: *use-mysql

450 451
.migration-paths: &migration-paths
  <<: *dedicated-runner
452
  <<: *pull-cache
453
  <<: *except-docs
454
  stage: test
455 456 457 458 459 460
  variables:
    SETUP_DB: "false"
  script:
    - git fetch origin v8.14.10
    - git checkout -f FETCH_HEAD
    - bundle install $BUNDLE_INSTALL_FLAGS
461
    - cp config/gitlab.yml.example config/gitlab.yml
462 463 464 465 466 467 468 469 470 471 472 473 474 475
    - 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

476
.db-rollback: &db-rollback
477
  <<: *dedicated-runner
478
  <<: *except-docs
479 480
  <<: *pull-cache
  stage: test
481
  script:
482 483
    - bundle exec rake db:rollback STEP=120
    - bundle exec rake db:migrate
484

485
db:rollback-pg:
486 487 488
  <<: *db-rollback
  <<: *use-pg

489
db:rollback-mysql:
490 491 492 493
  <<: *db-rollback
  <<: *use-mysql

.db-seed_fu: &db-seed_fu
494
  <<: *dedicated-runner
495
  <<: *except-docs
496 497
  <<: *pull-cache
  stage: test
498 499 500 501 502 503 504 505 506 507 508 509 510
  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

511
db:seed_fu-pg:
512 513 514
  <<: *db-seed_fu
  <<: *use-pg

515
db:seed_fu-mysql:
516 517 518
  <<: *db-seed_fu
  <<: *use-mysql

519 520 521 522 523 524
db:check-schema-pg:
  <<: *db-migrate-reset
  <<: *use-pg
  script:
    - source scripts/schema_changed.sh

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

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

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

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

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

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

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

gitlab_git_test:
671 672
  <<: *pull-cache
  <<: *except-docs
673 674 675 676
  variables:
    SETUP_DB: "false"
  script:
    - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes