Commit 720afc74 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch '247457-optimise-rspec-coverage' into 'master'

Optimise `rspec:coverage`

Closes #247457

See merge request gitlab-org/gitlab!42364
parents 1def732d 15b2927c
...@@ -34,6 +34,13 @@ ...@@ -34,6 +34,13 @@
- tmp/rubocop_cache/ - tmp/rubocop_cache/
policy: pull policy: pull
.coverage-cache:
cache:
key: "coverage-cache-v1"
paths:
- vendor/ruby/
policy: pull
.qa-cache: .qa-cache:
cache: cache:
key: "qa-v1" key: "qa-v1"
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
stage: test stage: test
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
# 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-build"
- run_timed_command "scripts/gitaly-test-spawn" - run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh - source scripts/rspec_helpers.sh
...@@ -32,6 +35,9 @@ ...@@ -32,6 +35,9 @@
.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
# 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-build"
- run_timed_command "scripts/gitaly-test-spawn" - run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh - source scripts/rspec_helpers.sh
...@@ -67,6 +73,9 @@ ...@@ -67,6 +73,9 @@
.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
# 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-build"
- run_timed_command "scripts/gitaly-test-spawn" - run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh - source scripts/rspec_helpers.sh
...@@ -160,6 +169,25 @@ update-rails-cache: ...@@ -160,6 +169,25 @@ update-rails-cache:
cache: cache:
policy: push # We want to rebuild the cache from scratch to ensure stale dependencies are cleaned up. policy: push # We want to rebuild the cache from scratch to ensure stale dependencies are cleaned up.
.coverage-base:
extends:
- .default-retry
- .default-before_script
- .coverage-cache
variables:
SETUP_DB: "false"
USE_BUNDLE_INSTALL: "false"
update-coverage-cache:
extends:
- .coverage-base
- .shared:rules:update-cache
stage: prepare
script:
- run_timed_command "bundle install --jobs=$(nproc) --path=vendor --retry=3 --quiet --without default development test production puma unicorn kerberos metrics omnibus ed25519"
cache:
policy: push # We want to rebuild the cache from scratch to ensure stale dependencies are cleaned up.
.static-analysis-base: .static-analysis-base:
extends: extends:
- .default-retry - .default-retry
...@@ -178,7 +206,7 @@ update-static-analysis-cache: ...@@ -178,7 +206,7 @@ update-static-analysis-cache:
script: script:
- rm -rf ./node_modules # We remove node_modules because there's no mechanism to remove stall entries. - rm -rf ./node_modules # We remove node_modules because there's no mechanism to remove stall entries.
- run_timed_command "retry yarn install --frozen-lockfile" - run_timed_command "retry yarn install --frozen-lockfile"
- bundle exec rubocop --parallel # For the moment we only cache `vendor/ruby/`, `node_modules/`, and `tmp/rubocop_cache` so we don't need to run all the tasks, - run_timed_command "bundle exec rubocop --parallel" # For the moment we only cache `vendor/ruby/`, `node_modules/`, and `tmp/rubocop_cache` so we don't need to run all the tasks,
cache: cache:
# We want to rebuild the cache from scratch to ensure stale dependencies are cleaned up but RuboCop has a mechanism # We want to rebuild the cache from scratch to ensure stale dependencies are cleaned up but RuboCop has a mechanism
# for keeping only the N latest cache files, so we take advantage of it with `pull-push` and removing `node_modules` at the start of the job. # for keeping only the N latest cache files, so we take advantage of it with `pull-push` and removing `node_modules` at the start of the job.
...@@ -313,7 +341,7 @@ db:backup_and_restore: ...@@ -313,7 +341,7 @@ db:backup_and_restore:
rspec:coverage: rspec:coverage:
extends: extends:
- .rails-job-base - .coverage-base
- .rails:rules:rspec-coverage - .rails:rules:rspec-coverage
stage: post-test stage: post-test
# We cannot use needs since it would mean needing 84 jobs (since most are parallelized) # We cannot use needs since it would mean needing 84 jobs (since most are parallelized)
...@@ -333,11 +361,10 @@ rspec:coverage: ...@@ -333,11 +361,10 @@ rspec:coverage:
- rspec-ee system pg11 geo - rspec-ee system pg11 geo
- memory-static - memory-static
- memory-on-boot - memory-on-boot
variables:
SETUP_DB: "false"
script: script:
- bundle exec scripts/merge-simplecov - run_timed_command "bundle install --jobs=$(nproc) --path=vendor --retry=3 --quiet --without default development test production puma unicorn kerberos metrics omnibus ed25519"
- bundle exec scripts/gather-test-memory-data - run_timed_command "bundle exec scripts/merge-simplecov"
- run_timed_command "bundle exec scripts/gather-test-memory-data"
coverage: '/LOC \((\d+\.\d+%)\) covered.$/' coverage: '/LOC \((\d+\.\d+%)\) covered.$/'
artifacts: artifacts:
name: coverage name: coverage
......
...@@ -375,8 +375,6 @@ group :development, :test do ...@@ -375,8 +375,6 @@ group :development, :test do
gem 'scss_lint', '~> 0.56.0', require: false gem 'scss_lint', '~> 0.56.0', require: false
gem 'haml_lint', '~> 0.34.0', require: false gem 'haml_lint', '~> 0.34.0', require: false
gem 'simplecov', '~> 0.18.5', require: false
gem 'simplecov-cobertura', '~> 1.3.1', require: false
gem 'bundler-audit', '~> 0.6.1', require: false gem 'bundler-audit', '~> 0.6.1', require: false
gem 'benchmark-ips', '~> 2.3.0', require: false gem 'benchmark-ips', '~> 2.3.0', require: false
...@@ -394,6 +392,11 @@ group :development, :test do ...@@ -394,6 +392,11 @@ group :development, :test do
gem 'rblineprof', '~> 0.3.6', platform: :mri, require: false gem 'rblineprof', '~> 0.3.6', platform: :mri, require: false
end end
group :development, :test, :coverage do
gem 'simplecov', '~> 0.18.5', require: false
gem 'simplecov-cobertura', '~> 1.3.1', require: false
end
# Gems required in omnibus-gitlab pipeline # Gems required in omnibus-gitlab pipeline
group :development, :test, :omnibus do group :development, :test, :omnibus do
gem 'license_finder', '~> 5.4', require: false gem 'license_finder', '~> 5.4', require: false
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
export SETUP_DB=${SETUP_DB:-true} export SETUP_DB=${SETUP_DB:-true}
export USE_BUNDLE_INSTALL=${USE_BUNDLE_INSTALL:-true} export USE_BUNDLE_INSTALL=${USE_BUNDLE_INSTALL:-true}
export BUNDLE_INSTALL_FLAGS=${BUNDLE_INSTALL_FLAGS:-"--without=production --without=development --jobs=$(nproc) --path=vendor --retry=3 --quiet"} export BUNDLE_INSTALL_FLAGS=${BUNDLE_INSTALL_FLAGS:-"--without=production development --jobs=$(nproc) --path=vendor --retry=3 --quiet"}
if [ "$USE_BUNDLE_INSTALL" != "false" ]; then if [ "$USE_BUNDLE_INSTALL" != "false" ]; then
bundle --version bundle --version
...@@ -14,10 +14,6 @@ if [ "$USE_BUNDLE_INSTALL" != "false" ]; then ...@@ -14,10 +14,6 @@ if [ "$USE_BUNDLE_INSTALL" != "false" ]; then
run_timed_command "bundle pristine pg" run_timed_command "bundle pristine pg"
fi fi
# 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"
cp config/gitlab.yml.example config/gitlab.yml cp config/gitlab.yml.example config/gitlab.yml
sed -i 's/bin_path: \/usr\/bin\/git/bin_path: \/usr\/local\/bin\/git/' config/gitlab.yml sed -i 's/bin_path: \/usr\/bin\/git/bin_path: \/usr\/local\/bin\/git/' config/gitlab.yml
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
require 'simplecov' require 'simplecov'
require 'simplecov-cobertura' require 'simplecov-cobertura'
require 'active_support/core_ext/numeric/time'
require_relative '../lib/gitlab/utils' require_relative '../lib/gitlab/utils'
module SimpleCovEnv module SimpleCovEnv
...@@ -75,7 +74,7 @@ module SimpleCovEnv ...@@ -75,7 +74,7 @@ module SimpleCovEnv
add_group 'Libraries', %w[/lib /ee/lib] add_group 'Libraries', %w[/lib /ee/lib]
add_group 'Tooling', %w[/haml_lint /rubocop /tooling] add_group 'Tooling', %w[/haml_lint /rubocop /tooling]
merge_timeout 365.days merge_timeout 365 * 24 * 3600
end end
end end
end end
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