Commit 4d332efb authored by Rémy Coutable's avatar Rémy Coutable

Dogfood YAML anchors in CI config

This allows to DRY up the config a bit.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 36e252d1
...@@ -14,14 +14,17 @@ ...@@ -14,14 +14,17 @@
SIZE: 0 # number of external projects to fork, requires network connection SIZE: 0 # number of external projects to fork, requires network connection
# SEED_NESTED_GROUPS: "false" # requires network connection # SEED_NESTED_GROUPS: "false" # requires network connection
.run-dev-fixtures-script: &run-dev-fixtures-script
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- run_timed_command "RAILS_ENV=test bundle exec rake db:seed_fu"
run-dev-fixtures: run-dev-fixtures:
extends: extends:
- .run-dev-fixtures - .run-dev-fixtures
- .dev-fixtures:rules:ee-and-foss - .dev-fixtures:rules:ee-and-foss
script: script:
- run_timed_command "scripts/gitaly-test-build" - *run-dev-fixtures-script
- run_timed_command "scripts/gitaly-test-spawn"
- run_timed_command "RAILS_ENV=test bundle exec rake db:seed_fu"
run-dev-fixtures-ee: run-dev-fixtures-ee:
extends: extends:
...@@ -29,7 +32,5 @@ run-dev-fixtures-ee: ...@@ -29,7 +32,5 @@ run-dev-fixtures-ee:
- .dev-fixtures:rules:ee-only - .dev-fixtures:rules:ee-only
- .use-pg11-ee - .use-pg11-ee
script: script:
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- cp ee/db/fixtures/development/* $FIXTURE_PATH - cp ee/db/fixtures/development/* $FIXTURE_PATH
- run_timed_command "RAILS_ENV=test bundle exec rake db:seed_fu" - *run-dev-fixtures-script
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
# we override the max_old_space_size to prevent OOM errors # we override the max_old_space_size to prevent OOM errors
NODE_OPTIONS: --max_old_space_size=3584 NODE_OPTIONS: --max_old_space_size=3584
.yarn-install: &yarn-install
- source scripts/utils.sh
- run_timed_command "retry yarn install --frozen-lockfile"
.compile-assets-base: .compile-assets-base:
extends: extends:
- .frontend-base - .frontend-base
...@@ -16,9 +20,7 @@ ...@@ -16,9 +20,7 @@
WEBPACK_VENDOR_DLL: "true" WEBPACK_VENDOR_DLL: "true"
stage: prepare stage: prepare
script: script:
- node --version - *yarn-install
- run_timed_command "retry yarn install --frozen-lockfile"
- free -m
- run_timed_command "bin/rake gitlab:assets:compile" - run_timed_command "bin/rake gitlab:assets:compile"
- run_timed_command "scripts/clean-old-cached-assets" - run_timed_command "scripts/clean-old-cached-assets"
...@@ -85,8 +87,7 @@ update-yarn-cache: ...@@ -85,8 +87,7 @@ update-yarn-cache:
- .shared:rules:update-cache - .shared:rules:update-cache
stage: prepare stage: prepare
script: script:
- source scripts/utils.sh - *yarn-install
- run_timed_command "retry yarn install --frozen-lockfile"
cache: cache:
policy: push policy: push
...@@ -137,14 +138,14 @@ eslint-as-if-foss: ...@@ -137,14 +138,14 @@ eslint-as-if-foss:
- .as-if-foss - .as-if-foss
needs: [] needs: []
script: script:
- run_timed_command "retry yarn install --frozen-lockfile" - *yarn-install
- yarn run eslint - run_timed_command "yarn run eslint"
.karma-base: .karma-base:
extends: .frontend-test-base extends: .frontend-test-base
script: script:
- export BABEL_ENV=coverage CHROME_LOG_FILE=chrome_debug.log - export BABEL_ENV=coverage CHROME_LOG_FILE=chrome_debug.log
- run_timed_command "retry yarn install --frozen-lockfile" - *yarn-install
- run_timed_command "yarn karma" - run_timed_command "yarn karma"
karma: karma:
...@@ -175,7 +176,7 @@ karma-as-if-foss: ...@@ -175,7 +176,7 @@ karma-as-if-foss:
.jest-base: .jest-base:
extends: .frontend-test-base extends: .frontend-test-base
script: script:
- run_timed_command "retry yarn install --frozen-lockfile" - *yarn-install
- run_timed_command "yarn jest --ci --coverage --testSequencer ./scripts/frontend/parallel_ci_sequencer.js" - run_timed_command "yarn jest --ci --coverage --testSequencer ./scripts/frontend/parallel_ci_sequencer.js"
jest: jest:
...@@ -200,7 +201,7 @@ jest-integration: ...@@ -200,7 +201,7 @@ jest-integration:
- .frontend-test-base - .frontend-test-base
- .frontend:rules:default-frontend-jobs - .frontend:rules:default-frontend-jobs
script: script:
- run_timed_command "retry yarn install --frozen-lockfile" - *yarn-install
- run_timed_command "yarn jest:integration --ci" - run_timed_command "yarn jest:integration --ci"
needs: ["frontend-fixtures"] needs: ["frontend-fixtures"]
...@@ -220,8 +221,7 @@ coverage-frontend: ...@@ -220,8 +221,7 @@ coverage-frontend:
needs: ["jest"] needs: ["jest"]
stage: post-test stage: post-test
before_script: before_script:
- source scripts/utils.sh - *yarn-install
- run_timed_command "retry yarn install --frozen-lockfile"
script: script:
- run_timed_command "yarn node scripts/frontend/merge_coverage_frontend.js" - run_timed_command "yarn node scripts/frontend/merge_coverage_frontend.js"
coverage: '/^Statements\s*:\s*?(\d+(?:\.\d+)?)%/' coverage: '/^Statements\s*:\s*?(\d+(?:\.\d+)?)%/'
...@@ -241,9 +241,8 @@ coverage-frontend: ...@@ -241,9 +241,8 @@ coverage-frontend:
stage: test stage: test
dependencies: [] dependencies: []
script: script:
- source scripts/utils.sh - *yarn-install
- run_timed_command "yarn install --frozen-lockfile" - run_timed_command "retry yarn run webpack-prod"
- run_timed_command "yarn run webpack-prod"
qa-frontend-node:10: qa-frontend-node:10:
extends: .qa-frontend-node extends: .qa-frontend-node
...@@ -266,8 +265,7 @@ webpack-dev-server: ...@@ -266,8 +265,7 @@ webpack-dev-server:
WEBPACK_MEMORY_TEST: "true" WEBPACK_MEMORY_TEST: "true"
WEBPACK_VENDOR_DLL: "true" WEBPACK_VENDOR_DLL: "true"
script: script:
- source scripts/utils.sh - *yarn-install
- run_timed_command "retry yarn install --frozen-lockfile"
- run_timed_command "retry yarn webpack-vendor" - run_timed_command "retry yarn webpack-vendor"
- run_timed_command "node --expose-gc node_modules/.bin/webpack-dev-server --config config/webpack.config.js" - run_timed_command "node --expose-gc node_modules/.bin/webpack-dev-server --config config/webpack.config.js"
artifacts: artifacts:
......
...@@ -6,6 +6,14 @@ ...@@ -6,6 +6,14 @@
- .default-before_script - .default-before_script
- .rails-cache - .rails-cache
.base-script: &base-script
# Only install knapsack after bundle install! Otherwise oddly some native
# gems could not be found under some circumstance. No idea why, hours wasted.
- run_timed_command "gem install knapsack --no-document"
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- source ./scripts/rspec_helpers.sh
.rspec-base: .rspec-base:
extends: .rails-job-base extends: .rails-job-base
stage: test stage: test
...@@ -14,12 +22,7 @@ ...@@ -14,12 +22,7 @@
RUBY_GC_MALLOC_LIMIT_MAX: 134217728 RUBY_GC_MALLOC_LIMIT_MAX: 134217728
needs: ["setup-test-env", "retrieve-tests-metadata", "compile-test-assets"] needs: ["setup-test-env", "retrieve-tests-metadata", "compile-test-assets"]
script: script:
# Only install knapsack after bundle install! Otherwise oddly some native - *base-script
# gems could not be found under some circumstance. No idea why, hours wasted.
- run_timed_command "gem install knapsack --no-document"
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh
- rspec_paralellized_job "--tag ~quarantine --tag ~geo --tag ~level:migration" - rspec_paralellized_job "--tag ~quarantine --tag ~geo --tag ~level:migration"
artifacts: artifacts:
expire_in: 31d expire_in: 31d
...@@ -38,12 +41,7 @@ ...@@ -38,12 +41,7 @@
.rspec-base-migration: .rspec-base-migration:
extends: .rails:rules:ee-and-foss-migration extends: .rails:rules:ee-and-foss-migration
script: script:
# Only install knapsack after bundle install! Otherwise oddly some native - *base-script
# gems could not be found under some circumstance. No idea why, hours wasted.
- run_timed_command "gem install knapsack --no-document"
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh
- rspec_paralellized_job "--tag ~quarantine --tag ~geo --tag level:migration" - rspec_paralellized_job "--tag ~quarantine --tag ~geo --tag level:migration"
.rspec-base-pg11: .rspec-base-pg11:
...@@ -76,12 +74,7 @@ ...@@ -76,12 +74,7 @@
.rspec-ee-base-geo: .rspec-ee-base-geo:
extends: .rspec-base extends: .rspec-base
script: script:
# Only install knapsack after bundle install! Otherwise oddly some native - *base-script
# gems could not be found under some circumstance. No idea why, hours wasted.
- run_timed_command "gem install knapsack --no-document"
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh
- rspec_paralellized_job "--tag ~quarantine --tag geo" - rspec_paralellized_job "--tag ~quarantine --tag geo"
.rspec-ee-base-geo-pg11: .rspec-ee-base-geo-pg11:
...@@ -318,8 +311,7 @@ gitlab:setup: ...@@ -318,8 +311,7 @@ gitlab:setup:
# db/fixtures/development/04_project.rb thanks to SIZE=1 below # db/fixtures/development/04_project.rb thanks to SIZE=1 below
- git clone https://gitlab.com/gitlab-org/gitlab-test.git - git clone https://gitlab.com/gitlab-org/gitlab-test.git
/home/git/repositories/gitlab-org/gitlab-test.git /home/git/repositories/gitlab-org/gitlab-test.git
- run_timed_command "scripts/gitaly-test-build" - *base-script
- run_timed_command "scripts/gitaly-test-spawn"
- force=yes SIZE=1 FIXTURE_PATH="db/fixtures/development" bundle exec rake gitlab:setup - force=yes SIZE=1 FIXTURE_PATH="db/fixtures/development" bundle exec rake gitlab:setup
artifacts: artifacts:
when: on_failure when: on_failure
...@@ -542,9 +534,7 @@ rspec fail-fast: ...@@ -542,9 +534,7 @@ rspec fail-fast:
stage: test stage: test
needs: ["setup-test-env", "retrieve-tests-metadata", "compile-test-assets", "detect-tests"] needs: ["setup-test-env", "retrieve-tests-metadata", "compile-test-assets", "detect-tests"]
script: script:
- run_timed_command "scripts/gitaly-test-build" - *base-script
- run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh
- rspec_fail_fast tmp/matching_tests.txt "--tag ~quarantine" - rspec_fail_fast tmp/matching_tests.txt "--tag ~quarantine"
artifacts: artifacts:
expire_in: 7d expire_in: 7d
...@@ -557,9 +547,7 @@ rspec foss-impact: ...@@ -557,9 +547,7 @@ rspec foss-impact:
- .rails:rules:rspec-foss-impact - .rails:rules:rspec-foss-impact
needs: ["setup-test-env", "retrieve-tests-metadata", "compile-test-assets as-if-foss", "detect-tests as-if-foss"] needs: ["setup-test-env", "retrieve-tests-metadata", "compile-test-assets as-if-foss", "detect-tests as-if-foss"]
script: script:
- run_timed_command "scripts/gitaly-test-build" - *base-script
- run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh
- rspec_matched_foss_tests tmp/matching_foss_tests.txt "--tag ~quarantine" - rspec_matched_foss_tests tmp/matching_foss_tests.txt "--tag ~quarantine"
artifacts: artifacts:
expire_in: 7d expire_in: 7d
......
...@@ -16,6 +16,11 @@ review-cleanup: ...@@ -16,6 +16,11 @@ review-cleanup:
- ruby -rrubygems scripts/review_apps/automated_cleanup.rb - ruby -rrubygems scripts/review_apps/automated_cleanup.rb
- gcp_cleanup - gcp_cleanup
.base-before_script: &base-before_script
- source ./scripts/utils.sh
- source ./scripts/review_apps/review-apps.sh
- install_api_client_dependencies_with_apk
review-build-cng: review-build-cng:
extends: extends:
- .default-retry - .default-retry
...@@ -23,7 +28,7 @@ review-build-cng: ...@@ -23,7 +28,7 @@ review-build-cng:
image: ruby:2.6-alpine image: ruby:2.6-alpine
stage: review-prepare stage: review-prepare
before_script: before_script:
- source scripts/utils.sh - source ./scripts/utils.sh
- install_api_client_dependencies_with_apk - install_api_client_dependencies_with_apk
- install_gitlab_gem - install_gitlab_gem
needs: needs:
...@@ -62,9 +67,7 @@ review-deploy: ...@@ -62,9 +67,7 @@ review-deploy:
- export GITALY_VERSION=$(<GITALY_SERVER_VERSION) - export GITALY_VERSION=$(<GITALY_SERVER_VERSION)
- export GITLAB_WORKHORSE_VERSION=$(<GITLAB_WORKHORSE_VERSION) - export GITLAB_WORKHORSE_VERSION=$(<GITLAB_WORKHORSE_VERSION)
- echo "${CI_ENVIRONMENT_URL}" > environment_url.txt - echo "${CI_ENVIRONMENT_URL}" > environment_url.txt
- source ./scripts/utils.sh - *base-before_script
- install_api_client_dependencies_with_apk
- source scripts/review_apps/review-apps.sh
script: script:
- check_kube_domain - check_kube_domain
- ensure_namespace - ensure_namespace
...@@ -97,9 +100,7 @@ review-deploy: ...@@ -97,9 +100,7 @@ review-deploy:
# See https://gitlab.com/gitlab-org/gitlab/issues/191273 # See https://gitlab.com/gitlab-org/gitlab/issues/191273
GIT_DEPTH: 1 GIT_DEPTH: 1
before_script: before_script:
- apk add --update openssl - *base-before_script
- source ./scripts/utils.sh
- source ./scripts/review_apps/review-apps.sh
review-stop-failed-deployment: review-stop-failed-deployment:
extends: extends:
...@@ -142,8 +143,7 @@ review-stop: ...@@ -142,8 +143,7 @@ review-stop:
- export CI_ENVIRONMENT_URL="$(cat environment_url.txt)" - export CI_ENVIRONMENT_URL="$(cat environment_url.txt)"
- echo "${CI_ENVIRONMENT_URL}" - echo "${CI_ENVIRONMENT_URL}"
- echo "${QA_IMAGE}" - echo "${QA_IMAGE}"
- source scripts/utils.sh - *base-before_script
- install_api_client_dependencies_with_apk
- gem install gitlab-qa --no-document ${GITLAB_QA_VERSION:+ --version ${GITLAB_QA_VERSION}} - gem install gitlab-qa --no-document ${GITLAB_QA_VERSION:+ --version ${GITLAB_QA_VERSION}}
artifacts: artifacts:
paths: paths:
...@@ -231,6 +231,6 @@ danger-review: ...@@ -231,6 +231,6 @@ danger-review:
stage: test stage: test
needs: [] needs: []
script: script:
- source scripts/utils.sh - source ./scripts/utils.sh
- retry yarn install --frozen-lockfile - run_timed_command "retry yarn install --frozen-lockfile"
- danger --fail-on-errors=true --verbose - danger --fail-on-errors=true --verbose
...@@ -38,6 +38,6 @@ update-tests-metadata: ...@@ -38,6 +38,6 @@ update-tests-metadata:
- rspec-ee integration pg11 geo - rspec-ee integration pg11 geo
- rspec-ee system pg11 geo - rspec-ee system pg11 geo
script: script:
- retry gem install fog-aws mime-types activesupport rspec_profiling postgres-copy --no-document - run_timed_command "retry gem install fog-aws mime-types activesupport rspec_profiling postgres-copy --no-document"
- source scripts/rspec_helpers.sh - source ./scripts/rspec_helpers.sh
- update_tests_metadata - update_tests_metadata
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment