Commit d9554bd5 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '217916-frontend-fixtures-parallel' into 'master'

Make frontend fixtures parallel with knapsack

See merge request gitlab-org/gitlab!46959
parents 063506f9 1e134e19
......@@ -97,32 +97,41 @@ update-yarn-cache:
- .rails-cache
- .use-pg11
stage: fixtures
needs: ["setup-test-env", "compile-test-assets"]
needs: ["setup-test-env", "retrieve-tests-metadata", "compile-test-assets"]
variables:
SETUP_DB: "true"
WEBPACK_VENDOR_DLL: "true"
script:
- run_timed_command "gem install knapsack --no-document"
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- run_timed_command "bin/rake frontend:fixtures"
- source ./scripts/rspec_helpers.sh
- rspec_paralellized_job "--tag frontend_fixture"
artifacts:
name: frontend-fixtures
expire_in: 31d
when: always
paths:
- tmp/tests/frontend/
- knapsack/
frontend-fixtures:
rspec frontend_fixture:
extends:
- .frontend-fixtures-base
- .frontend:rules:default-frontend-jobs
frontend-fixtures-as-if-foss:
rspec frontend_fixture as-if-foss:
extends:
- .frontend-fixtures-base
- .frontend:rules:default-frontend-jobs-as-if-foss
- .as-if-foss
rspec-ee frontend_fixture:
extends:
- .frontend-fixtures-base
- .frontend:rules:default-frontend-jobs
parallel: 2
.frontend-test-base:
extends:
- .frontend-base
......@@ -152,7 +161,8 @@ karma:
extends:
- .karma-base
- .frontend:rules:default-frontend-jobs
needs: ["frontend-fixtures"]
# Don't use `needs` since `rspec-ee frontend_fixture` doesn't exist in `gitlab-foss` pipelines.
dependencies: ["rspec frontend_fixture", "rspec-ee frontend_fixture"]
coverage: '/^Statements *: (\d+\.\d+%)/'
artifacts:
name: coverage-javascript
......@@ -171,7 +181,7 @@ karma-as-if-foss:
- .karma-base
- .frontend:rules:default-frontend-jobs-as-if-foss
- .as-if-foss
needs: ["frontend-fixtures-as-if-foss"]
needs: ["rspec frontend_fixture as-if-foss"]
.jest-base:
extends: .frontend-test-base
......@@ -183,7 +193,8 @@ jest:
extends:
- .jest-base
- .frontend:rules:default-frontend-jobs
needs: ["frontend-fixtures"]
# Don't use `needs` since `rspec-ee frontend_fixture` doesn't exist in `gitlab-foss` pipelines.
dependencies: ["rspec frontend_fixture", "rspec-ee frontend_fixture"]
artifacts:
name: coverage-frontend
expire_in: 31d
......@@ -203,14 +214,15 @@ jest-integration:
script:
- *yarn-install
- run_timed_command "yarn jest:integration --ci"
needs: ["frontend-fixtures"]
# Don't use `needs` since `rspec-ee frontend_fixture` doesn't exist in `gitlab-foss` pipelines.
dependencies: ["rspec frontend_fixture", "rspec-ee frontend_fixture"]
jest-as-if-foss:
extends:
- .jest-base
- .frontend:rules:default-frontend-jobs-as-if-foss
- .as-if-foss
needs: ["frontend-fixtures-as-if-foss"]
needs: ["rspec frontend_fixture as-if-foss"]
parallel: 2
coverage-frontend:
......
......@@ -28,6 +28,8 @@ update-tests-metadata:
dependencies:
- setup-test-env
- rspec migration pg11
- rspec frontend_fixture
- rspec-ee frontend_fixture
- rspec unit pg11
- rspec integration pg11
- rspec system pg11
......
......@@ -12,6 +12,9 @@ module Quality
lib/gitlab/background_migration
lib/ee/gitlab/background_migration
],
frontend_fixture: %w[
frontend/fixtures
],
unit: %w[
bin
channels
......@@ -63,7 +66,7 @@ module Quality
end
def pattern(level)
@patterns[level] ||= "#{prefix}spec/#{folders_pattern(level)}{,/**/}*_spec.rb"
@patterns[level] ||= "#{prefix}spec/#{folders_pattern(level)}{,/**/}*#{suffix(level)}"
end
def regexp(level)
......@@ -76,6 +79,9 @@ module Quality
# spec/lib/gitlab/background_migration and tests under spec/lib are unit by default
when regexp(:migration), regexp(:background_migration)
:migration
# Detect frontend fixture before matching other unit tests
when regexp(:frontend_fixture)
:frontend_fixture
when regexp(:unit)
:unit
when regexp(:integration)
......@@ -93,6 +99,15 @@ module Quality
private
def suffix(level)
case level
when :frontend_fixture
".rb"
else
"_spec.rb"
end
end
def migration_and_background_migration_folders
TEST_LEVEL_FOLDERS.fetch(:migration) + TEST_LEVEL_FOLDERS.fetch(:background_migration)
end
......
......@@ -18,6 +18,13 @@ RSpec.describe Quality::TestLevel do
end
end
context 'when level is frontend_fixture' do
it 'returns a pattern' do
expect(subject.pattern(:frontend_fixture))
.to eq("spec/{frontend/fixtures}{,/**/}*.rb")
end
end
context 'when level is unit' do
it 'returns a pattern' do
expect(subject.pattern(:unit))
......@@ -86,6 +93,13 @@ RSpec.describe Quality::TestLevel do
end
end
context 'when level is frontend_fixture' do
it 'returns a regexp' do
expect(subject.regexp(:frontend_fixture))
.to eq(%r{spec/(frontend/fixtures)})
end
end
context 'when level is unit' do
it 'returns a regexp' do
expect(subject.regexp(:unit))
......@@ -144,6 +158,10 @@ RSpec.describe Quality::TestLevel do
expect(subject.level_for('spec/models/abuse_report_spec.rb')).to eq(:unit)
end
it 'returns the correct level for a frontend fixture test' do
expect(subject.level_for('spec/frontend/fixtures/pipelines.rb')).to eq(:frontend_fixture)
end
it 'returns the correct level for a tooling test' do
expect(subject.level_for('spec/tooling/lib/tooling/test_file_finder_spec.rb')).to eq(:unit)
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