diff --git a/.gitlab/ci/frontend.gitlab-ci.yml b/.gitlab/ci/frontend.gitlab-ci.yml index b8a0b894d5bb03dac7c5e3a239bbf3d66b3836b8..48f85219ff4e7f2a3723a92ad6ed1f9ecbcb028f 100644 --- a/.gitlab/ci/frontend.gitlab-ci.yml +++ b/.gitlab/ci/frontend.gitlab-ci.yml @@ -128,13 +128,11 @@ update-storybook-yarn-cache: - tmp/tests/frontend/ - knapsack/ -# In gitlab-foss, generates FOSS fixtures. In gitlab, generates FOSS & EE fixtures. -# That way, we don't need to have two separate jobs. -rspec-all frontend_fixture: +rspec frontend_fixture: extends: - .frontend-fixtures-base - .frontend:rules:default-frontend-jobs - parallel: 5 + parallel: 2 rspec frontend_fixture as-if-foss: extends: @@ -142,6 +140,12 @@ rspec frontend_fixture as-if-foss: - .frontend:rules:default-frontend-jobs-as-if-foss - .as-if-foss +rspec-ee frontend_fixture: + extends: + - .frontend-fixtures-base + - .frontend:rules:default-frontend-jobs-ee + parallel: 3 + graphql-schema-dump: variables: SETUP_DB: "false" @@ -192,7 +196,9 @@ jest: - .frontend:rules:jest needs: - job: "detect-tests" - - job: "rspec-all frontend_fixture" + - job: "rspec frontend_fixture" + - job: "rspec-ee frontend_fixture" + optional: true artifacts: name: coverage-frontend expire_in: 31d @@ -219,7 +225,9 @@ jest-integration: script: - run_timed_command "yarn jest:integration --ci" needs: - - job: "rspec-all frontend_fixture" + - job: "rspec frontend_fixture" + - job: "rspec-ee frontend_fixture" + optional: true - job: "graphql-schema-dump" jest-as-if-foss: @@ -333,7 +341,9 @@ startup-css-check: - .frontend:rules:default-frontend-jobs needs: - job: "compile-test-assets" - - job: "rspec-all frontend_fixture" + - job: "rspec frontend_fixture" + - job: "rspec-ee frontend_fixture" + optional: true startup-css-check as-if-foss: extends: diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 3dfc26af2b5fb8d794929a6ac9ffa6543096d284..25e685e15a194fc175ffde5605d0f8072b06f497 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -495,6 +495,13 @@ - <<: *if-default-refs changes: *code-backstage-patterns +.frontend:rules:default-frontend-jobs-ee: + rules: + - <<: *if-not-ee + when: never + - <<: *if-default-refs + changes: *code-backstage-patterns + .frontend:rules:default-frontend-jobs-as-if-foss: rules: - <<: *if-not-ee diff --git a/.gitlab/ci/test-metadata.gitlab-ci.yml b/.gitlab/ci/test-metadata.gitlab-ci.yml index 2d96fb6d4b07c61d149c663aefb439a72e3f0fcd..ac719977975b2c43b514c61836e33913a3c7abed 100644 --- a/.gitlab/ci/test-metadata.gitlab-ci.yml +++ b/.gitlab/ci/test-metadata.gitlab-ci.yml @@ -29,7 +29,8 @@ update-tests-metadata: - retrieve-tests-metadata - setup-test-env - rspec migration pg12 - - rspec-all frontend_fixture + - rspec frontend_fixture + - rspec-ee frontend_fixture - rspec unit pg12 - rspec integration pg12 - rspec system pg12 diff --git a/doc/development/pipelines.md b/doc/development/pipelines.md index 8a7add3e9e6a63d923591f9ddce76d79530992d2..f39461319145e1a282e817166a17bfced17d398e 100644 --- a/doc/development/pipelines.md +++ b/doc/development/pipelines.md @@ -252,7 +252,7 @@ graph RL; 2_1-1 & 2_1-2 & 2_1-3 & 2_1-4 --> 1-6; end - 2_2-2["rspec-all frontend_fixture (7 minutes)"]; + 2_2-2["rspec frontend_fixture/rspec-ee frontend_fixture (7 minutes)"]; class 2_2-2 criticalPath; click 2_2-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910143&udv=0" 2_2-4["memory-on-boot (3.5 minutes)"]; @@ -284,7 +284,7 @@ graph RL; 3_1-1["jest (14.5 minutes)"]; class 3_1-1 criticalPath; click 3_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914204&udv=0" - subgraph "Needs `rspec-all frontend_fixture`"; + subgraph "Needs `rspec frontend_fixture/rspec-ee frontend_fixture`"; 3_1-1 --> 2_2-2; end @@ -355,7 +355,7 @@ graph RL; 2_1-1 & 2_1-2 & 2_1-3 & 2_1-4 --> 1-6; end - 2_2-2["rspec-all frontend_fixture (7 minutes)"]; + 2_2-2["rspec frontend_fixture/rspec-ee frontend_fixture (7 minutes)"]; class 2_2-2 criticalPath; click 2_2-2 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=7910143&udv=0" 2_2-4["memory-on-boot (3.5 minutes)"]; @@ -395,7 +395,7 @@ graph RL; 3_1-1["jest (14.5 minutes)"]; class 3_1-1 criticalPath; click 3_1-1 "https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations?widget=6914204&udv=0" - subgraph "Needs `rspec-all frontend_fixture`"; + subgraph "Needs `rspec frontend_fixture/rspec-ee frontend_fixture`"; 3_1-1 --> 2_2-2; end diff --git a/scripts/rspec_helpers.sh b/scripts/rspec_helpers.sh index 280a1586de36132c9c433f77876e69aee8c0482d..797d9188f81c88b4e1a622e42fdb43de318cdbc4 100644 --- a/scripts/rspec_helpers.sh +++ b/scripts/rspec_helpers.sh @@ -109,18 +109,14 @@ function rspec_paralellized_job() { local test_level="${job_name[1]}" local report_name=$(echo "${CI_JOB_NAME}" | sed -E 's|[/ ]|_|g') # e.g. 'rspec unit pg12 1/24' would become 'rspec_unit_pg12_1_24' local rspec_opts="${1}" - local spec_folder_prefixes="" + local spec_folder_prefix="" if [[ "${test_tool}" =~ "-ee" ]]; then - spec_folder_prefixes="'ee/'" + spec_folder_prefix="ee/" fi if [[ "${test_tool}" =~ "-jh" ]]; then - spec_folder_prefixes="'jh/'" - fi - - if [[ "${test_tool}" =~ "-all" ]]; then - spec_folder_prefixes="['', 'ee/']" + spec_folder_prefix="jh/" fi export KNAPSACK_LOG_LEVEL="debug" @@ -135,7 +131,7 @@ function rspec_paralellized_job() { cp "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" "${KNAPSACK_REPORT_PATH}" if [[ -z "${KNAPSACK_TEST_FILE_PATTERN}" ]]; then - pattern=$(ruby -r./tooling/quality/test_level.rb -e "puts Quality::TestLevel.new(${spec_folder_prefixes}).pattern(:${test_level})") + pattern=$(ruby -r./tooling/quality/test_level.rb -e "puts Quality::TestLevel.new(%(${spec_folder_prefix})).pattern(:${test_level})") export KNAPSACK_TEST_FILE_PATTERN="${pattern}" fi diff --git a/spec/tooling/quality/test_level_spec.rb b/spec/tooling/quality/test_level_spec.rb index 0623a67a60ea6b8a1addd401c7681a283409a917..89abe337347d841b7a738080f1a454ad75a120c2 100644 --- a/spec/tooling/quality/test_level_spec.rb +++ b/spec/tooling/quality/test_level_spec.rb @@ -63,14 +63,7 @@ context 'with a prefix' do it 'returns a pattern' do expect(described_class.new('ee/').pattern(:system)) - .to eq("{ee/}spec/{features}{,/**/}*_spec.rb") - end - end - - context 'with several prefixes' do - it 'returns a pattern' do - expect(described_class.new(['', 'ee/', 'jh/']).pattern(:system)) - .to eq("{,ee/,jh/}spec/{features}{,/**/}*_spec.rb") + .to eq("ee/spec/{features}{,/**/}*_spec.rb") end end @@ -145,14 +138,7 @@ context 'with a prefix' do it 'returns a regexp' do expect(described_class.new('ee/').regexp(:system)) - .to eq(%r{(ee/)spec/(features)}) - end - end - - context 'with several prefixes' do - it 'returns a regexp' do - expect(described_class.new(['', 'ee/', 'jh/']).regexp(:system)) - .to eq(%r{(|ee/|jh/)spec/(features)}) + .to eq(%r{ee/spec/(features)}) end end diff --git a/tooling/quality/test_level.rb b/tooling/quality/test_level.rb index 83cbe7a1f19138c4ddca5f1db6c1781068aad70c..ad9de067375654aa11bfaf3411fdb4c976c60b31 100644 --- a/tooling/quality/test_level.rb +++ b/tooling/quality/test_level.rb @@ -60,20 +60,20 @@ class TestLevel system: ['features'] }.freeze - attr_reader :prefixes + attr_reader :prefix - def initialize(prefixes = nil) - @prefixes = Array(prefixes) + def initialize(prefix = nil) + @prefix = prefix @patterns = {} @regexps = {} end def pattern(level) - @patterns[level] ||= "#{prefixes_for_pattern}spec/#{folders_pattern(level)}{,/**/}*#{suffix(level)}" + @patterns[level] ||= "#{prefix}spec/#{folders_pattern(level)}{,/**/}*#{suffix(level)}" end def regexp(level) - @regexps[level] ||= Regexp.new("#{prefixes_for_regex}spec/#{folders_regex(level)}").freeze + @regexps[level] ||= Regexp.new("#{prefix}spec/#{folders_regex(level)}").freeze end def level_for(file_path) @@ -102,20 +102,6 @@ def background_migration?(file_path) private - def prefixes_for_pattern - return '' if prefixes.empty? - - "{#{prefixes.join(',')}}" - end - - def prefixes_for_regex - return '' if prefixes.empty? - - regex_prefix = prefixes.map(&Regexp.method(:escape)).join('|') - - "(#{regex_prefix})" - end - def suffix(level) case level when :frontend_fixture