From fa9b569f05a62b0855bc9656fe271bed1cfcd7d1 Mon Sep 17 00:00:00 2001 From: Peter Leitzen <pleitzen@gitlab.com> Date: Tue, 5 Dec 2023 14:56:12 +0100 Subject: [PATCH] Map every_model_spec to every model change This way `spec/models/every_model_spec.rb` is run in "fast fail" job(s) whenever a model changes. --- scripts/verify-tff-mapping | 12 ++++++++++++ spec/tooling/lib/tooling/predictive_tests_spec.rb | 3 ++- tests.yml | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/verify-tff-mapping b/scripts/verify-tff-mapping index f4872276b949..fe99272e5369 100755 --- a/scripts/verify-tff-mapping +++ b/scripts/verify-tff-mapping @@ -154,6 +154,18 @@ tests = [ expected: ['spec/haml_lint/linter/documentation_links_spec.rb'] }, + { + explanation: 'Spec for FOSS model', + changed_file: 'app/models/some_new_model.rb', + expected: ['spec/models/every_model_spec.rb'] + }, + + { + explanation: 'Spec for EE model', + changed_file: 'ee/app/models/some_new_model.rb', + expected: ['spec/models/every_model_spec.rb'] + }, + { explanation: 'Spec for FOSS sidekiq worker', changed_file: 'app/workers/new_worker.rb', diff --git a/spec/tooling/lib/tooling/predictive_tests_spec.rb b/spec/tooling/lib/tooling/predictive_tests_spec.rb index fdb7d09a3e23..e49daa702952 100644 --- a/spec/tooling/lib/tooling/predictive_tests_spec.rb +++ b/spec/tooling/lib/tooling/predictive_tests_spec.rb @@ -106,6 +106,7 @@ context 'when some files used for frontend fixtures were changed' do let(:changed_files_content) { 'app/models/todo.rb' } let(:changed_files_matching_test) { 'spec/models/todo_spec.rb' } + let(:additional_matching_tests) { 'spec/models/every_model_spec.rb' } let(:matching_frontend_fixture) { 'tmp/tests/frontend/fixtures-ee/todos/todos.html' } let(:fixtures_mapping_content) do JSON.dump(changed_files_matching_test => [matching_frontend_fixture]) # rubocop:disable Gitlab/Json @@ -120,7 +121,7 @@ it 'appends the spec file to RSPEC_MATCHING_TESTS_PATH' do expect { subject }.to change { File.read(matching_tests.path) } .from(matching_tests_initial_content) - .to("#{matching_tests_initial_content} #{changed_files_matching_test}") + .to("#{matching_tests_initial_content} #{additional_matching_tests} #{changed_files_matching_test}") end it 'does not change files other than RSPEC_CHANGED_FILES_PATH nor RSPEC_MATCHING_TESTS_PATH' do diff --git a/tests.yml b/tests.yml index 31713d030b07..83558b392183 100644 --- a/tests.yml +++ b/tests.yml @@ -79,6 +79,9 @@ mapping: - source: 'doc/index\.md' test: 'spec/haml_lint/linter/documentation_links_spec.rb' + - source: '(ee/)?app/models/.+\.rb' + test: 'spec/models/every_model_spec.rb' + - source: '(ee/)?app/workers/.+\.rb' test: 'spec/workers/every_sidekiq_worker_spec.rb' -- GitLab