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