+
+### User setting to disable exact code search
+
+
+
+- Announced in GitLab 18.3
+- Removal in GitLab 18.6
+- To discuss this change or learn more, see the [deprecation issue](https://gitlab.com/gitlab-org/gitlab/-/issues/554933).
+
+
+
+The user setting to disable exact code search is now deprecated. On GitLab.com, you can no longer disable exact code search in profile preferences.
+
+Exact code search provides a better user experience and is compatible with existing search APIs. This user setting is planned for removal in GitLab 18.6 to ensure all users benefit from improved search functionality.
+
diff --git a/doc/user/get_started/_index.md b/doc/user/get_started/_index.md
index b050fb74a04..684dae11d6d 100644
--- a/doc/user/get_started/_index.md
+++ b/doc/user/get_started/_index.md
@@ -15,6 +15,7 @@ If you're new to GitLab, get started learning about how GitLab works.
- [Get started planning work](get_started_planning_work.md)
- [Get started managing code](get_started_managing_code.md)
- [Get started with GitLab CI/CD](../../ci/_index.md)
+- [Get started with GitLab Runner](get_started_runner.md)
- [Get started securing your application](../application_security/get-started-security.md)
- [Get started deploying and releasing your application](get_started_deploy_release.md)
- [Get started managing your infrastructure](get_started_managing_infrastructure.md)
diff --git a/doc/user/get_started/get_started_runner.md b/doc/user/get_started/get_started_runner.md
index 718682b2807..d97a7210bda 100644
--- a/doc/user/get_started/get_started_runner.md
+++ b/doc/user/get_started/get_started_runner.md
@@ -2,6 +2,7 @@
stage: Verify
group: Runner
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments
+description: Learn how to set up and manage GitLab Runner.
title: Get started with GitLab Runner
---
diff --git a/doc/user/profile/preferences.md b/doc/user/profile/preferences.md
index 1dec647cf1f..7e042fe6dd1 100644
--- a/doc/user/profile/preferences.md
+++ b/doc/user/profile/preferences.md
@@ -354,7 +354,9 @@ To customize the time format:
1. Under **Time format**, select either the **System**, **12-hour**, or **24-hour** option.
1. Select **Save changes**.
-## Disable exact code search
+
+
+## Disable exact code search (deprecated)
{{< details >}}
@@ -364,6 +366,13 @@ To customize the time format:
{{< /details >}}
+{{< alert type="warning" >}}
+
+This feature was [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/554933) in GitLab 18.3
+and is planned for removal in 18.6.
+
+{{< /alert >}}
+
{{< history >}}
- [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105049) as a [beta](../../policy/development_stages_support.md#beta) in GitLab 15.9 [with flags](../../administration/feature_flags/_index.md) named `index_code_with_zoekt` and `search_code_with_zoekt`. Disabled by default.
@@ -392,6 +401,8 @@ To disable [exact code search](../search/exact_code_search.md) in user preferenc
1. Clear the **Enable exact code search** checkbox.
1. Select **Save changes**.
+
+
## User identities in CI job JSON web tokens
{{< history >}}
diff --git a/doc/user/search/exact_code_search.md b/doc/user/search/exact_code_search.md
index 60e75f0933b..12a7b0bd0a0 100644
--- a/doc/user/search/exact_code_search.md
+++ b/doc/user/search/exact_code_search.md
@@ -55,9 +55,6 @@ To use exact code search:
You can also use exact code search in a project or group.
-In user preferences, you can [disable exact code search](../profile/preferences.md#disable-exact-code-search)
-to use [advanced search](advanced_search.md) instead.
-
## Available scopes
Scopes describe the type of data you're searching.
diff --git a/lib/gitlab/sidekiq_middleware/concurrency_limit/workers_map.rb b/lib/gitlab/sidekiq_middleware/concurrency_limit/workers_map.rb
index 09cc8ba3d9c..b17966b584b 100644
--- a/lib/gitlab/sidekiq_middleware/concurrency_limit/workers_map.rb
+++ b/lib/gitlab/sidekiq_middleware/concurrency_limit/workers_map.rb
@@ -4,11 +4,11 @@ module Gitlab
module SidekiqMiddleware
module ConcurrencyLimit
class WorkersMap
+ @data = {}
class << self
def set_limit_for(worker:, max_jobs:)
raise ArgumentError, 'max_jobs must be a Proc instance' if max_jobs && !max_jobs.is_a?(Proc)
- @data ||= {}
@data[worker] = max_jobs
end
@@ -17,11 +17,17 @@ module Gitlab
# - 0 value is returned for workers without concurrency limits
# - negative value is returned for paused workers
def limit_for(worker:)
- return 0 unless data
return 0 if Feature.disabled?(:sidekiq_concurrency_limit_middleware, Feature.current_request, type: :ops)
worker_class = worker.is_a?(Class) ? worker : worker.class
- data[worker_class]&.call.to_i
+ limit = data[worker_class]&.call.to_i
+ return limit unless limit == 0
+
+ if Feature.enabled?(:use_max_concurrency_limit_percentage_as_default_limit, Feature.current_request)
+ default_limit_from_max_percentage(worker_class)
+ else
+ limit
+ end
end
def over_the_limit?(worker:)
@@ -48,6 +54,19 @@ module Gitlab
::Gitlab::SidekiqMiddleware::ConcurrencyLimit::ConcurrencyLimitService.concurrent_worker_count(worker_name)
end
+ # Default limit based on urgency and number of total Sidekiq threads in the fleet.
+ # e.g. for low urgency worker class, maximum 20% of all Sidekiq workers can run concurrently.
+ def default_limit_from_max_percentage(worker)
+ return 0 unless worker.ancestors.include?(WorkerAttributes)
+
+ max_replicas = ENV.fetch('SIDEKIQ_MAX_REPLICAS', 0).to_i
+ concurrency = ENV.fetch('SIDEKIQ_CONCURRENCY', 0).to_i
+ max_total_threads = max_replicas * concurrency
+ percentage = worker.get_max_concurrency_limit_percentage
+
+ (percentage * max_total_threads).ceil
+ end
+
attr_reader :data
end
end
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 00202bd4f49..ecb165d87d3 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -58077,6 +58077,12 @@ msgstr ""
msgid "SecurityReports|No vulnerabilities to report"
msgstr ""
+msgid "SecurityReports|Not available"
+msgstr ""
+
+msgid "SecurityReports|Not found"
+msgstr ""
+
msgid "SecurityReports|Oops, something doesn't seem right."
msgstr ""
@@ -58101,6 +58107,9 @@ msgstr ""
msgid "SecurityReports|Projects added"
msgstr ""
+msgid "SecurityReports|Reachability"
+msgstr ""
+
msgid "SecurityReports|Reachable:"
msgstr ""
@@ -58268,6 +58277,9 @@ msgstr ""
msgid "SecurityReports|Warning parsing security reports"
msgstr ""
+msgid "SecurityReports|Yes"
+msgstr ""
+
msgid "SecurityReports|scanned resources"
msgstr ""
diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb
index c09779faec7..bf57dd73a34 100644
--- a/spec/controllers/projects/compare_controller_spec.rb
+++ b/spec/controllers/projects/compare_controller_spec.rb
@@ -77,7 +77,6 @@ RSpec.describe Projects::CompareController, feature_category: :source_code_manag
let(:page) { nil }
before do
- stub_feature_flags(rapid_diffs: false)
stub_feature_flags(rapid_diffs_on_compare_show: false)
end
diff --git a/spec/controllers/projects/merge_requests/creations_controller_spec.rb b/spec/controllers/projects/merge_requests/creations_controller_spec.rb
index 7e92659bd39..d4db56b9b59 100644
--- a/spec/controllers/projects/merge_requests/creations_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests/creations_controller_spec.rb
@@ -141,7 +141,7 @@ RSpec.describe Projects::MergeRequests::CreationsController, feature_category: :
let(:params) { get_diff_params }
before do
- stub_feature_flags(rapid_diffs: true, rapid_diffs_on_mr_creation: true, rapid_diffs_debug: true)
+ stub_feature_flags(rapid_diffs_on_mr_creation: true, rapid_diffs_debug: true)
end
include_examples 'renders rapid diffs'
@@ -165,7 +165,7 @@ RSpec.describe Projects::MergeRequests::CreationsController, feature_category: :
let(:params) { get_diff_params }
before do
- stub_feature_flags(rapid_diffs: false, rapid_diffs_on_mr_creation: false)
+ stub_feature_flags(rapid_diffs_on_mr_creation: false)
end
include_examples 'renders default new template'
diff --git a/spec/features/merge_request/rapid_diffs/user_views_diffs_spec.rb b/spec/features/merge_request/rapid_diffs/user_views_diffs_spec.rb
index 3f9080e048c..4b93d60c2ef 100644
--- a/spec/features/merge_request/rapid_diffs/user_views_diffs_spec.rb
+++ b/spec/features/merge_request/rapid_diffs/user_views_diffs_spec.rb
@@ -11,7 +11,6 @@ RSpec.describe 'User views rapid diffs', :js, feature_category: :code_review_wor
let(:diffs) { merge_request.diffs }
before do
- stub_feature_flags(rapid_diffs: true)
visit(diffs_project_merge_request_path(project, merge_request, rapid_diffs: true))
wait_for_requests
diff --git a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb
index aa36174a2f1..7f476e5996a 100644
--- a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb
+++ b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb
@@ -127,28 +127,6 @@ RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_
it_behaves_like 'Rapid Diffs application'
end
- context 'without rapid diffs' do
- before do
- stub_feature_flags(rapid_diffs: false)
- end
-
- it 'allows to change the diff view' do
- visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'fix' })
-
- click_link 'Changes'
-
- expect(page).to have_css('a.btn.selected', text: 'Inline')
- expect(page).not_to have_css('a.btn.selected', text: 'Side-by-side')
-
- click_link 'Side-by-side'
-
- within '.merge-request' do
- expect(page).not_to have_css('a.btn.selected', text: 'Inline')
- expect(page).to have_css('a.btn.selected', text: 'Side-by-side')
- end
- end
- end
-
it 'does not allow non-existing branches' do
visit project_new_merge_request_path(project, merge_request: { target_branch: 'non-exist-target', source_branch: 'non-exist-source' })
diff --git a/spec/features/projects/compare_spec.rb b/spec/features/projects/compare_spec.rb
index 3688d52ce76..ef574a6fccf 100644
--- a/spec/features/projects/compare_spec.rb
+++ b/spec/features/projects/compare_spec.rb
@@ -95,7 +95,7 @@ RSpec.describe "Compare", :js, feature_category: :source_code_management do
context 'with legacy diffs' do
before do
- stub_feature_flags(rapid_diffs: false, rapid_diffs_on_compare_show: false)
+ stub_feature_flags(rapid_diffs_on_compare_show: false)
end
it 'renders additions info when click unfold diff' do
diff --git a/spec/features/projects/view_on_env_spec.rb b/spec/features/projects/view_on_env_spec.rb
index 2554c811a60..a790a64ee8c 100644
--- a/spec/features/projects/view_on_env_spec.rb
+++ b/spec/features/projects/view_on_env_spec.rb
@@ -50,7 +50,7 @@ RSpec.describe 'View on environment', :js, feature_category: :groups_and_project
context 'with legacy diffs' do
before do
- stub_feature_flags(rapid_diffs: false, rapid_diffs_on_compare_show: false)
+ stub_feature_flags(rapid_diffs_on_compare_show: false)
end
context 'when visiting a comparison for the branch' do
diff --git a/spec/lib/gitlab/sidekiq_middleware/concurrency_limit/server_spec.rb b/spec/lib/gitlab/sidekiq_middleware/concurrency_limit/server_spec.rb
index c7b0cde3b7b..2f36fa8184e 100644
--- a/spec/lib/gitlab/sidekiq_middleware/concurrency_limit/server_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/concurrency_limit/server_spec.rb
@@ -176,10 +176,6 @@ RSpec.describe Gitlab::SidekiqMiddleware::ConcurrencyLimit::Server, feature_cate
end
context 'when limit is not defined' do
- before do
- ::Gitlab::SidekiqMiddleware::ConcurrencyLimit::WorkersMap.remove_instance_variable(:@data)
- end
-
it_behaves_like 'track execution'
end
end
@@ -225,10 +221,6 @@ RSpec.describe Gitlab::SidekiqMiddleware::ConcurrencyLimit::Server, feature_cate
end
context 'when limit is not defined' do
- before do
- ::Gitlab::SidekiqMiddleware::ConcurrencyLimit::WorkersMap.remove_instance_variable(:@data)
- end
-
it_behaves_like 'track execution'
end
end
diff --git a/spec/lib/gitlab/sidekiq_middleware/concurrency_limit/workers_map_spec.rb b/spec/lib/gitlab/sidekiq_middleware/concurrency_limit/workers_map_spec.rb
index b860331688f..1d0976d4870 100644
--- a/spec/lib/gitlab/sidekiq_middleware/concurrency_limit/workers_map_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/concurrency_limit/workers_map_spec.rb
@@ -24,24 +24,133 @@ RSpec.describe Gitlab::SidekiqMiddleware::ConcurrencyLimit::WorkersMap, feature_
end
describe '.limit_for' do
- let(:expected_limit) { 60 }
+ context 'with concurrency_limit attribute defined' do
+ let(:expected_limit) { 60 }
- it 'accepts worker instance' do
- expect(described_class.limit_for(worker: worker_class.new)).to eq(expected_limit)
+ it 'accepts worker instance and return defined limit' do
+ expect(described_class.limit_for(worker: worker_class.new)).to eq(expected_limit)
+ end
+
+ it 'accepts worker class and return defined limit' do
+ expect(described_class.limit_for(worker: worker_class)).to eq(expected_limit)
+ end
+
+ it 'returns 0 for unknown worker' do
+ expect(described_class.limit_for(worker: described_class)).to eq(0)
+ end
+
+ it 'returns 0 if the feature flag is disabled' do
+ stub_feature_flags(sidekiq_concurrency_limit_middleware: false)
+
+ expect(described_class.limit_for(worker: worker_class)).to eq(0)
+ end
end
- it 'accepts worker class' do
- expect(described_class.limit_for(worker: worker_class)).to eq(expected_limit)
+ context 'with concurrency_limit and max_concurrency_limit_percentage attributes defined' do
+ let(:expected_limit) { 60 }
+
+ before do
+ worker_class.class_eval do
+ max_concurrency_limit_percentage 0.5
+ end
+ end
+
+ it 'returns the concurrency_limit value' do
+ expect(described_class.limit_for(worker: worker_class)).to eq(expected_limit)
+ end
end
- it 'returns 0 for unknown worker' do
- expect(described_class.limit_for(worker: described_class)).to eq(0)
- end
+ context 'for worker class without concurrency_limit attribute' do
+ using RSpec::Parameterized::TableSyntax
- it 'returns 0 if the feature flag is disabled' do
- stub_feature_flags(sidekiq_concurrency_limit_middleware: false)
+ let(:worker_class) do
+ Class.new do
+ def self.name
+ 'Gitlab::Foo::Bar::DummyWorker'
+ end
- expect(described_class.limit_for(worker: worker_class)).to eq(0)
+ include ApplicationWorker
+ end
+ end
+
+ where(:urgency, :sidekiq_max_replicas, :sidekiq_concurrency, :expected_concurrency_limit) do
+ :high | 10 | 10 | 35
+ :high | 0 | 10 | 0
+ :high | 10 | 0 | 0
+ :high | 0 | 0 | 0
+ :low | 10 | 10 | 25
+ :low | 0 | 10 | 0
+ :low | 10 | 0 | 0
+ :low | 0 | 0 | 0
+ :throttled | 10 | 10 | 15
+ :throttled | 0 | 10 | 0
+ :throttled | 10 | 0 | 0
+ :throttled | 0 | 0 | 0
+ end
+
+ with_them do
+ before do
+ worker_class.urgency urgency
+ stub_env("SIDEKIQ_MAX_REPLICAS", sidekiq_max_replicas)
+ stub_env("SIDEKIQ_CONCURRENCY", sidekiq_concurrency)
+ end
+
+ it 'returns expected limit' do
+ expect(described_class.limit_for(worker: worker_class)).to eq(expected_concurrency_limit)
+ end
+ end
+
+ context 'with max_concurrency_limit_percentage attribute' do
+ let(:worker_class) do
+ Class.new do
+ def self.name
+ 'Gitlab::Foo::Bar::DummyWorker'
+ end
+
+ include ApplicationWorker
+ max_concurrency_limit_percentage 0.4
+ end
+ end
+
+ before do
+ stub_env("SIDEKIQ_MAX_REPLICAS", 10)
+ stub_env("SIDEKIQ_CONCURRENCY", 10)
+ end
+
+ it 'returns expected limit' do
+ expect(described_class.limit_for(worker: worker_class)).to eq(40)
+ end
+ end
+
+ context 'with only SIDEKIQ_CONCURRENCY environment variable defined' do
+ before do
+ stub_env("SIDEKIQ_CONCURRENCY", 10)
+ end
+
+ it 'returns 0' do
+ expect(described_class.limit_for(worker: worker_class)).to eq(0)
+ end
+ end
+
+ context 'with only SIDEKIQ_MAX_REPLICAS environment variable defined' do
+ before do
+ stub_env("SIDEKIQ_MAX_REPLICAS", 10)
+ end
+
+ it 'returns 0' do
+ expect(described_class.limit_for(worker: worker_class)).to eq(0)
+ end
+ end
+
+ context 'when use_max_concurrency_limit_percentage_as_default_limit FF is disabled' do
+ before do
+ stub_feature_flags(use_max_concurrency_limit_percentage_as_default_limit: false)
+ end
+
+ it 'returns 0' do
+ expect(described_class.limit_for(worker: worker_class)).to eq(0)
+ end
+ end
end
end
diff --git a/spec/requests/projects/blob_controller_spec.rb b/spec/requests/projects/blob_controller_spec.rb
index 6efe99c8af6..a59598b17b5 100644
--- a/spec/requests/projects/blob_controller_spec.rb
+++ b/spec/requests/projects/blob_controller_spec.rb
@@ -93,18 +93,6 @@ RSpec.describe 'Projects blob controller', feature_category: :code_review_workfl
expect(response).to have_gitlab_http_status(:not_found)
end
end
-
- context 'when rapid_diffs FF is disabled' do
- before do
- stub_feature_flags(rapid_diffs: false)
- end
-
- it 'returns 404' do
- do_get(since: 2, to: 6, offset: 10, closest_line_number: 1)
-
- expect(response).to have_gitlab_http_status(:not_found)
- end
- end
end
describe 'POST preview' do
diff --git a/spec/requests/projects/commit_controller_spec.rb b/spec/requests/projects/commit_controller_spec.rb
index 3c3615b5aca..a806feb2006 100644
--- a/spec/requests/projects/commit_controller_spec.rb
+++ b/spec/requests/projects/commit_controller_spec.rb
@@ -24,25 +24,6 @@ RSpec.describe Projects::CommitController, feature_category: :source_code_manage
sign_in(user)
end
- context 'when the feature flag rapid_diffs is disabled' do
- before do
- stub_feature_flags(rapid_diffs: false)
- end
-
- it 'returns 404' do
- send_request
-
- expect(response).to have_gitlab_http_status(:not_found)
- end
-
- it 'uses show action when rapid_diffs query parameter doesnt exist' do
- get project_commit_path(project, commit)
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(response.body).to include('data-page="projects:commit:show"')
- end
- end
-
it 'returns 200' do
send_request
diff --git a/spec/requests/projects/merge_requests/creations_controller_spec.rb b/spec/requests/projects/merge_requests/creations_controller_spec.rb
index 6040598ed05..cdcc4078d76 100644
--- a/spec/requests/projects/merge_requests/creations_controller_spec.rb
+++ b/spec/requests/projects/merge_requests/creations_controller_spec.rb
@@ -26,19 +26,6 @@ RSpec.describe 'Merge Request Creation', feature_category: :code_review_workflow
get namespace_project_new_merge_request_diffs_path(params.merge(extra_params))
end
- context 'when the feature flag rapid_diffs is disabled' do
- before do
- stub_feature_flags(rapid_diffs: false)
- end
-
- it 'uses default action' do
- get_diffs
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(response.body).to include('data-page="projects:merge_requests:creations:new"')
- end
- end
-
context 'when rapid_diffs_disabled param is present' do
it 'uses default action' do
get_diffs(rapid_diffs_disabled: true)
diff --git a/spec/requests/projects/merge_requests/diffs_stream_spec.rb b/spec/requests/projects/merge_requests/diffs_stream_spec.rb
index 04c14ffcc99..8cba26992f8 100644
--- a/spec/requests/projects/merge_requests/diffs_stream_spec.rb
+++ b/spec/requests/projects/merge_requests/diffs_stream_spec.rb
@@ -113,18 +113,6 @@ RSpec.describe 'Merge Requests Diffs stream', feature_category: :code_review_wor
end
end
- context 'when rapid_diffs FF is disabled' do
- before do
- stub_feature_flags(rapid_diffs: false)
- end
-
- it 'returns 404' do
- go
-
- expect(response).to have_gitlab_http_status(:not_found)
- end
- end
-
include_examples 'with diffs_blobs param'
end
end
diff --git a/spec/requests/projects/merge_requests_controller_spec.rb b/spec/requests/projects/merge_requests_controller_spec.rb
index 62b36da0f6b..24ac68b9a3d 100644
--- a/spec/requests/projects/merge_requests_controller_spec.rb
+++ b/spec/requests/projects/merge_requests_controller_spec.rb
@@ -255,25 +255,6 @@ RSpec.describe Projects::MergeRequestsController, feature_category: :source_code
end
describe '#rapid_diffs' do
- context 'when the feature flag rapid_diffs is disabled' do
- before do
- stub_feature_flags(rapid_diffs: false)
- end
-
- it 'returns 404' do
- get diffs_project_merge_request_path(project, merge_request, rapid_diffs: 'true')
-
- expect(response).to have_gitlab_http_status(:not_found)
- end
-
- it 'uses diffs action when rapid_diffs query parameter doesnt exist' do
- get diffs_project_merge_request_path(project, merge_request)
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(response.body).to include('data-page="projects:merge_requests:diffs"')
- end
- end
-
it 'returns 200' do
get diffs_project_merge_request_path(project, merge_request, rapid_diffs: 'true')
diff --git a/spec/services/projects/participants_service_spec.rb b/spec/services/projects/participants_service_spec.rb
index 6dcf33added..1b0e54cd390 100644
--- a/spec/services/projects/participants_service_spec.rb
+++ b/spec/services/projects/participants_service_spec.rb
@@ -7,8 +7,9 @@ RSpec.describe Projects::ParticipantsService, feature_category: :groups_and_proj
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:noteable) { create(:issue, project: project) }
+ let_it_be(:organization) { project.organization }
let_it_be(:org_user_detail) do
- create(:organization_user_detail, organization: project.organization, username: 'spec_bot')
+ create(:organization_user_detail, organization: organization, username: 'spec_bot')
end
let_it_be(:other_org_user_detail) do
@@ -254,6 +255,28 @@ RSpec.describe Projects::ParticipantsService, feature_category: :groups_and_proj
end
end
end
+
+ context 'when groups are in other organizations' do
+ let!(:other_organization) { create(:organization) }
+ let(:group_1) { create(:group, organization: organization) }
+ let(:group_2) { create(:group, organization: other_organization) }
+
+ before do
+ group_1.add_owner(user)
+ group_1.add_owner(create(:user))
+
+ group_2.add_owner(user)
+ end
+
+ it 'only includes groups in the projects organization' do
+ expect(group_items).to contain_exactly(
+ a_hash_including(name: group_1.full_name, count: 2)
+ )
+ expect(group_items).not_to include(
+ a_hash_including(name: group_2.full_name)
+ )
+ end
+ end
end
context 'when `disable_all_mention` FF is enabled' do
diff --git a/spec/support/helpers/user_with_namespace_shim.yml b/spec/support/helpers/user_with_namespace_shim.yml
index 917362c58b8..9a94bc4dd1d 100644
--- a/spec/support/helpers/user_with_namespace_shim.yml
+++ b/spec/support/helpers/user_with_namespace_shim.yml
@@ -246,7 +246,6 @@
- ee/spec/services/ee/users/migrate_records_to_ghost_user_service_spec.rb
- ee/spec/services/epics/issue_promote_service_spec.rb
- ee/spec/services/epics/transfer_service_spec.rb
-- ee/spec/services/epics/update_service_spec.rb
- ee/spec/services/namespaces/service_accounts/create_service_spec.rb
- ee/spec/services/projects/create_from_template_service_spec.rb
- ee/spec/services/projects/create_service_spec.rb
diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml
index 87fe06420b6..22948979d52 100644
--- a/spec/support/rspec_order_todo.yml
+++ b/spec/support/rspec_order_todo.yml
@@ -2027,7 +2027,6 @@
- './ee/spec/services/epics/reopen_service_spec.rb'
- './ee/spec/services/epics/transfer_service_spec.rb'
- './ee/spec/services/epics/update_dates_service_spec.rb'
-- './ee/spec/services/epics/update_service_spec.rb'
- './ee/spec/services/external_status_checks/create_service_spec.rb'
- './ee/spec/services/external_status_checks/destroy_service_spec.rb'
- './ee/spec/services/external_status_checks/dispatch_service_spec.rb'
diff --git a/spec/support/shared_examples/diff_file_shared_examples.rb b/spec/support/shared_examples/diff_file_shared_examples.rb
index 71cc027ed76..e62b256f2b6 100644
--- a/spec/support/shared_examples/diff_file_shared_examples.rb
+++ b/spec/support/shared_examples/diff_file_shared_examples.rb
@@ -1,18 +1,6 @@
# frozen_string_literal: true
RSpec.shared_examples 'diff file endpoint' do
- context 'when the rapid_diffs feature flag is disabled' do
- before do
- stub_feature_flags(rapid_diffs: false)
- end
-
- it 'returns a 404 status' do
- send_request
-
- expect(response).to have_gitlab_http_status(:not_found)
- end
- end
-
context 'when diff_file is not found' do
let(:old_path) { 'bad/path' }
let(:new_path) { 'bad/path' }
diff --git a/spec/support/shared_examples/diff_files_metadata_shared_examples.rb b/spec/support/shared_examples/diff_files_metadata_shared_examples.rb
index ef02a0313f2..3a9b7fbd85b 100644
--- a/spec/support/shared_examples/diff_files_metadata_shared_examples.rb
+++ b/spec/support/shared_examples/diff_files_metadata_shared_examples.rb
@@ -7,18 +7,6 @@ RSpec.shared_examples 'diff files metadata' do
expect(response).to have_gitlab_http_status(:success)
expect(json_response['diff_files']).to be_an Array
end
-
- context 'when the rapid_diffs feature flag is disabled' do
- before do
- stub_feature_flags(rapid_diffs: false)
- end
-
- it 'returns a 404 status' do
- send_request
-
- expect(response).to have_gitlab_http_status(:not_found)
- end
- end
end
RSpec.shared_examples 'missing diff files metadata' do
diff --git a/spec/support/shared_examples/diffs_stats_shared_examples.rb b/spec/support/shared_examples/diffs_stats_shared_examples.rb
index d0c2747d643..b46033c96da 100644
--- a/spec/support/shared_examples/diffs_stats_shared_examples.rb
+++ b/spec/support/shared_examples/diffs_stats_shared_examples.rb
@@ -15,18 +15,6 @@ RSpec.shared_examples 'diffs stats' do
expect(response).to have_gitlab_http_status(:success)
expect(json_response['diffs_stats']).to be_an Hash
end
-
- context 'when the rapid_diffs feature flag is disabled' do
- before do
- stub_feature_flags(rapid_diffs: false)
- end
-
- it 'returns a 404 status' do
- send_request
-
- expect(response).to have_gitlab_http_status(:not_found)
- end
- end
end
RSpec.shared_examples 'overflow' do
diff --git a/spec/support/shared_examples/diffs_stream_shared_examples.rb b/spec/support/shared_examples/diffs_stream_shared_examples.rb
index 6a982475f05..2f24f35f3f1 100644
--- a/spec/support/shared_examples/diffs_stream_shared_examples.rb
+++ b/spec/support/shared_examples/diffs_stream_shared_examples.rb
@@ -44,16 +44,4 @@ RSpec.shared_examples 'diffs stream tests' do
expect(response.body).to include('something went wrong')
end
end
-
- context 'when the rapid_diffs feature flag is disabled' do
- before do
- stub_feature_flags(rapid_diffs: false)
- end
-
- it 'returns a 404 status' do
- go
-
- expect(response).to have_gitlab_http_status(:not_found)
- end
- end
end
diff --git a/spec/tooling/lib/tooling/find_tests_spec.rb b/spec/tooling/lib/tooling/find_tests_spec.rb
index c23b35f4173..986dd23f95d 100644
--- a/spec/tooling/lib/tooling/find_tests_spec.rb
+++ b/spec/tooling/lib/tooling/find_tests_spec.rb
@@ -1,16 +1,12 @@
# frozen_string_literal: true
-require 'tempfile'
require_relative '../../../../tooling/lib/tooling/find_tests'
require 'fast_spec_helper'
RSpec.describe Tooling::FindTests, feature_category: :tooling do
- attr_accessor :predictive_tests_file
-
let(:instance) do
described_class.new(
changed_files,
- predictive_tests_pathname,
mappings_file: mappings_file,
mappings_limit_percentage: 50
)
@@ -18,40 +14,20 @@ RSpec.describe Tooling::FindTests, feature_category: :tooling do
let(:mock_test_file_finder) { instance_double(TestFileFinder::FileFinder) }
let(:new_matching_tests) { ["new_matching_spec.rb"] }
- let(:predictive_tests_pathname) { predictive_tests_file.path }
let(:changed_files) { %w[changed_file1 changed_file2] }
- let(:predictive_tests_content) { "previously_matching_spec.rb" }
let(:mappings_file) { nil }
- around do |example|
- self.predictive_tests_file = Tempfile.new('predictive_tests_file')
-
- # See https://ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/
- # Tempfile.html#class-Tempfile-label-Explicit+close
- begin
- example.run
- ensure
- predictive_tests_file.close
- predictive_tests_file.unlink
- end
- end
-
before do
allow(mock_test_file_finder).to receive(:use)
allow(mock_test_file_finder).to receive(:test_files).and_return(new_matching_tests)
allow(TestFileFinder::FileFinder).to receive(:new).and_return(mock_test_file_finder)
-
- # We write into the temp files initially, to later check how the code modified those files
- File.write(predictive_tests_pathname, predictive_tests_content)
end
describe '#execute' do
subject { instance.execute }
- it 'does not overwrite the output file' do
- expect { subject }.to change { File.read(predictive_tests_pathname) }
- .from(predictive_tests_content)
- .to("#{predictive_tests_content} #{new_matching_tests.uniq.join(' ')}")
+ it 'returns matched files list' do
+ expect(subject).to match_array(new_matching_tests.uniq)
end
it 'loads the tests.yml file with a pattern matching mapping' do
@@ -81,12 +57,8 @@ RSpec.describe Tooling::FindTests, feature_category: :tooling do
]
end
- it 'writes uniquely matching specs to the output' do
- subject
-
- expect(File.read(predictive_tests_pathname).split(' ')).to match_array(
- predictive_tests_content.split(' ') + new_matching_tests.uniq
- )
+ it 'return only unique specs' do
+ expect(subject).to match_array(new_matching_tests.uniq)
end
end
end
diff --git a/spec/tooling/lib/tooling/mappings/graphql_base_type_mappings_spec.rb b/spec/tooling/lib/tooling/mappings/graphql_base_type_mappings_spec.rb
index 600fe73496f..2333572e7ec 100644
--- a/spec/tooling/lib/tooling/mappings/graphql_base_type_mappings_spec.rb
+++ b/spec/tooling/lib/tooling/mappings/graphql_base_type_mappings_spec.rb
@@ -6,16 +6,11 @@ require_relative '../../../../../tooling/lib/tooling/mappings/graphql_base_type_
RSpec.describe Tooling::Mappings::GraphqlBaseTypeMappings, feature_category: :tooling do
# We set temporary folders, and those readers give access to those folder paths
attr_accessor :foss_folder, :ee_folder, :jh_folder
- attr_accessor :predictive_tests_file
- let(:predictive_tests_pathname) { predictive_tests_file.path }
- let(:instance) { described_class.new(changed_files, predictive_tests_pathname) }
+ let(:instance) { described_class.new(changed_files) }
let(:changed_files) { %w[changed_file1 changed_file2] }
- let(:predictive_tests_initial_content) { "previously_matching_spec.rb" }
around do |example|
- self.predictive_tests_file = Tempfile.new('predictive_tests_file')
-
Dir.mktmpdir('FOSS') do |foss_folder|
Dir.mktmpdir('EE') do |ee_folder|
Dir.mktmpdir('JH') do |jh_folder|
@@ -23,14 +18,7 @@ RSpec.describe Tooling::Mappings::GraphqlBaseTypeMappings, feature_category: :to
self.ee_folder = ee_folder
self.jh_folder = jh_folder
- # See https://ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/
- # Tempfile.html#class-Tempfile-label-Explicit+close
- begin
- example.run
- ensure
- predictive_tests_file.close
- predictive_tests_file.unlink
- end
+ example.run
end
end
end
@@ -42,9 +30,6 @@ RSpec.describe Tooling::Mappings::GraphqlBaseTypeMappings, feature_category: :to
'ee' => [foss_folder, ee_folder],
'jh' => [foss_folder, ee_folder, jh_folder]
})
-
- # We write into the temp files initially, to later check how the code modified those files
- File.write(predictive_tests_pathname, predictive_tests_initial_content)
end
describe '#execute' do
@@ -53,8 +38,8 @@ RSpec.describe Tooling::Mappings::GraphqlBaseTypeMappings, feature_category: :to
context 'when no GraphQL files were changed' do
let(:changed_files) { [] }
- it 'does not change the output file' do
- expect { subject }.not_to change { File.read(predictive_tests_pathname) }
+ it 'returns empty file list' do
+ expect(subject).to be_empty
end
end
@@ -73,7 +58,7 @@ RSpec.describe Tooling::Mappings::GraphqlBaseTypeMappings, feature_category: :to
end
it 'does not change the output file' do
- expect { subject }.not_to change { File.read(predictive_tests_pathname) }
+ expect(subject).to be_empty
end
end
@@ -89,9 +74,7 @@ RSpec.describe Tooling::Mappings::GraphqlBaseTypeMappings, feature_category: :to
end
it 'writes the correct specs in the output' do
- expect { subject }.to change { File.read(predictive_tests_pathname) }
- .from(predictive_tests_initial_content)
- .to("#{predictive_tests_initial_content} spec/my_graphql_file_spec.rb")
+ expect(subject).to match_array(['spec/my_graphql_file_spec.rb'])
end
end
end
diff --git a/spec/tooling/lib/tooling/mappings/js_to_system_specs_mappings_spec.rb b/spec/tooling/lib/tooling/mappings/js_to_system_specs_mappings_spec.rb
index d34261a54f5..f49793552ed 100644
--- a/spec/tooling/lib/tooling/mappings/js_to_system_specs_mappings_spec.rb
+++ b/spec/tooling/lib/tooling/mappings/js_to_system_specs_mappings_spec.rb
@@ -6,54 +6,36 @@ require_relative '../../../../../tooling/lib/tooling/mappings/js_to_system_specs
RSpec.describe Tooling::Mappings::JsToSystemSpecsMappings, feature_category: :tooling do
# We set temporary folders, and those readers give access to those folder paths
attr_accessor :js_base_folder, :system_specs_base_folder
- attr_accessor :predictive_tests_file
let(:changed_files) { %w[changed_file1 changed_file2] }
- let(:predictive_tests_pathname) { predictive_tests_file.path }
- let(:predictive_tests_content) { "previously_matching_spec.rb" }
let(:instance) do
described_class.new(
changed_files,
- predictive_tests_pathname,
system_specs_base_folder: system_specs_base_folder,
js_base_folder: js_base_folder
)
end
around do |example|
- self.predictive_tests_file = Tempfile.new('predictive_tests_file')
-
Dir.mktmpdir do |tmp_js_base_folder|
Dir.mktmpdir do |tmp_system_specs_base_folder|
self.system_specs_base_folder = tmp_system_specs_base_folder
self.js_base_folder = tmp_js_base_folder
- # See https://ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/
- # Tempfile.html#class-Tempfile-label-Explicit+close
- begin
- example.run
- ensure
- predictive_tests_file.close
- predictive_tests_file.unlink
- end
+ example.run
end
end
end
- before do
- # We write into the temp files initially, to later check how the code modified those files
- File.write(predictive_tests_pathname, predictive_tests_content)
- end
-
describe '#execute' do
subject { instance.execute }
context 'when no JS files were changed' do
let(:changed_files) { [] }
- it 'does not change the output file' do
- expect { subject }.not_to change { File.read(predictive_tests_pathname) }
+ it 'returns empty array' do
+ expect(subject).to be_empty
end
end
@@ -61,8 +43,8 @@ RSpec.describe Tooling::Mappings::JsToSystemSpecsMappings, feature_category: :to
let(:changed_files) { ["#{js_base_folder}/issues/secret_values.js"] }
context 'when the JS files are not present on disk' do
- it 'does not change the output file' do
- expect { subject }.not_to change { File.read(predictive_tests_pathname) }
+ it 'return empty array' do
+ expect(subject).to be_empty
end
end
@@ -73,8 +55,8 @@ RSpec.describe Tooling::Mappings::JsToSystemSpecsMappings, feature_category: :to
end
context 'when no system specs match the JS keyword' do
- it 'does not change the output file' do
- expect { subject }.not_to change { File.read(predictive_tests_pathname) }
+ it 'returns empty array' do
+ expect(subject).to be_empty
end
end
@@ -85,9 +67,7 @@ RSpec.describe Tooling::Mappings::JsToSystemSpecsMappings, feature_category: :to
end
it 'adds the new specs to the output file' do
- expect { subject }.to change { File.read(predictive_tests_pathname) }
- .from(predictive_tests_content)
- .to("#{predictive_tests_content} #{system_specs_base_folder}/confidential_issues/issues_spec.rb")
+ expect(subject).to match_array(["#{system_specs_base_folder}/confidential_issues/issues_spec.rb"])
end
end
end
@@ -140,7 +120,7 @@ RSpec.describe Tooling::Mappings::JsToSystemSpecsMappings, feature_category: :to
end
describe '#construct_js_keywords' do
- subject { described_class.new(changed_files, predictive_tests_file).construct_js_keywords(js_files) }
+ subject { described_class.new(changed_files).construct_js_keywords(js_files) }
let(:js_files) do
%w[
diff --git a/spec/tooling/lib/tooling/mappings/view_to_js_mappings_spec.rb b/spec/tooling/lib/tooling/mappings/view_to_js_mappings_spec.rb
index 492ca7febab..60236a04ba0 100644
--- a/spec/tooling/lib/tooling/mappings/view_to_js_mappings_spec.rb
+++ b/spec/tooling/lib/tooling/mappings/view_to_js_mappings_spec.rb
@@ -6,46 +6,28 @@ require_relative '../../../../../tooling/lib/tooling/mappings/view_to_js_mapping
RSpec.describe Tooling::Mappings::ViewToJsMappings, feature_category: :tooling do
# We set temporary folders, and those readers give access to those folder paths
attr_accessor :view_base_folder, :js_base_folder
- attr_accessor :predictive_tests_file
let(:changed_files) { %w[changed_file1 changed_file2] }
- let(:predictive_tests_pathname) { predictive_tests_file.path }
- let(:predictive_tests_content) { "previously_matching_spec.rb" }
let(:instance) do
described_class.new(
changed_files,
- predictive_tests_pathname,
view_base_folder: view_base_folder,
js_base_folder: js_base_folder
)
end
around do |example|
- self.predictive_tests_file = Tempfile.new('matching_tests')
-
Dir.mktmpdir do |tmp_js_base_folder|
Dir.mktmpdir do |tmp_views_base_folder|
self.js_base_folder = tmp_js_base_folder
self.view_base_folder = tmp_views_base_folder
- # See https://ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/
- # Tempfile.html#class-Tempfile-label-Explicit+close
- begin
- example.run
- ensure
- predictive_tests_file.close
- predictive_tests_file.unlink
- end
+ example.run
end
end
end
- before do
- # We write into the temp files initially, to later check how the code modified those files
- File.write(predictive_tests_pathname, predictive_tests_content)
- end
-
describe '#execute' do
let(:changed_files) { %W[#{view_base_folder}/index.html] }
@@ -56,8 +38,8 @@ RSpec.describe Tooling::Mappings::ViewToJsMappings, feature_category: :tooling d
allow(instance).to receive(:filter_files).and_return([])
end
- it 'does not change the output file' do
- expect { subject }.not_to change { File.read(predictive_tests_pathname) }
+ it 'returns empty array' do
+ expect(subject).to be_empty
end
end
@@ -74,8 +56,8 @@ RSpec.describe Tooling::Mappings::ViewToJsMappings, feature_category: :tooling d
FILE
end
- it 'does not change the output file' do
- expect { subject }.not_to change { File.read(predictive_tests_pathname) }
+ it 'returns empty array' do
+ expect(subject).to be_empty
end
end
@@ -91,8 +73,8 @@ RSpec.describe Tooling::Mappings::ViewToJsMappings, feature_category: :tooling d
end
context 'when no matching JS files are found' do
- it 'does not change the output file' do
- expect { subject }.not_to change { File.read(predictive_tests_pathname) }
+ it 'returns empty array' do
+ expect(subject).to be_empty
end
end
@@ -112,9 +94,7 @@ RSpec.describe Tooling::Mappings::ViewToJsMappings, feature_category: :tooling d
end
it 'adds the matching JS files to the output' do
- expect { subject }.to change { File.read(predictive_tests_pathname) }
- .from(predictive_tests_content)
- .to("#{predictive_tests_content} #{js_base_folder}/index.js")
+ expect(subject).to match_array(["#{js_base_folder}/index.js"])
end
end
end
@@ -158,9 +138,7 @@ RSpec.describe Tooling::Mappings::ViewToJsMappings, feature_category: :tooling d
end
it 'scans those partials for the HTML attribute value' do
- expect { subject }.to change { File.read(predictive_tests_pathname) }
- .from(predictive_tests_content)
- .to("#{predictive_tests_content} #{js_base_folder}/index.js")
+ expect(subject).to match_array(["#{js_base_folder}/index.js"])
end
end
end
diff --git a/spec/tooling/lib/tooling/mappings/view_to_system_specs_mappings_spec.rb b/spec/tooling/lib/tooling/mappings/view_to_system_specs_mappings_spec.rb
index f95094186f5..ba971c853dd 100644
--- a/spec/tooling/lib/tooling/mappings/view_to_system_specs_mappings_spec.rb
+++ b/spec/tooling/lib/tooling/mappings/view_to_system_specs_mappings_spec.rb
@@ -5,43 +5,29 @@ require 'fileutils'
require_relative '../../../../../tooling/lib/tooling/mappings/view_to_system_specs_mappings'
RSpec.describe Tooling::Mappings::ViewToSystemSpecsMappings, feature_category: :tooling do
- attr_accessor :view_base_folder, :predictive_tests_file
+ attr_accessor :view_base_folder
let(:instance) do
- described_class.new(changed_files, predictive_tests_pathname, view_base_folder: view_base_folder)
+ described_class.new(changed_files, view_base_folder: view_base_folder)
end
let(:changed_files_content) { %w[changed_file1 changed_file2] }
- let(:predictive_tests_pathname) { predictive_tests_file.path }
- let(:predictive_tests_initial_content) { "previously_added_spec.rb" }
around do |example|
- self.predictive_tests_file = Tempfile.new('predictive_tests_file')
-
- # See https://ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/
- # Tempfile.html#class-Tempfile-label-Explicit+close
- begin
- Dir.mktmpdir do |tmp_views_base_folder|
- self.view_base_folder = tmp_views_base_folder
- example.run
- end
- ensure
- predictive_tests_file.close
- predictive_tests_file.unlink
+ Dir.mktmpdir do |tmp_views_base_folder|
+ self.view_base_folder = tmp_views_base_folder
+ example.run
end
end
before do
FileUtils.mkdir_p("#{view_base_folder}/app/views/dashboard")
-
- # We write into the temp files initially, to check how the code modified those files
- File.write(predictive_tests_pathname, predictive_tests_initial_content)
end
describe '#execute' do
subject { instance.execute }
- let(:changed_files) { ["#{view_base_folder}/app/views/dashboard/my_view.html.haml"] }
+ let(:changed_files) { ["#{view_base_folder}/app/views/dashboard/my_view.html.haml"] }
before do
# We create all of the changed_files, so that they are part of the filtered files
@@ -60,10 +46,8 @@ RSpec.describe Tooling::Mappings::ViewToSystemSpecsMappings, feature_category: :
allow(File).to receive(:exist?).with(expected_feature_spec).and_return(true)
end
- it 'writes that feature spec to the output file' do
- expect { subject }.to change { File.read(predictive_tests_pathname) }
- .from(predictive_tests_initial_content)
- .to("#{predictive_tests_initial_content} #{expected_feature_spec}")
+ it 'returns feature spec' do
+ expect(subject).to match_array([expected_feature_spec])
end
end
@@ -83,10 +67,8 @@ RSpec.describe Tooling::Mappings::ViewToSystemSpecsMappings, feature_category: :
end
end
- it 'writes all of the feature specs for the parent folder to the output file' do
- expect { subject }.to change { File.read(predictive_tests_pathname) }
- .from(predictive_tests_initial_content)
- .to("#{predictive_tests_initial_content} #{expected_feature_specs.join(' ')}")
+ it 'returns all of the feature specs for the parent folder' do
+ expect(subject).to match_array(expected_feature_specs)
end
end
end
diff --git a/spec/tooling/lib/tooling/predictive_tests/metrics_exporter_spec.rb b/spec/tooling/lib/tooling/predictive_tests/metrics_exporter_spec.rb
index 674c494b47d..c2c7dcf1274 100644
--- a/spec/tooling/lib/tooling/predictive_tests/metrics_exporter_spec.rb
+++ b/spec/tooling/lib/tooling/predictive_tests/metrics_exporter_spec.rb
@@ -21,8 +21,16 @@ RSpec.describe Tooling::PredictiveTests::MetricsExporter, feature_category: :too
end
let(:event_tracker) { instance_double(Tooling::Events::TrackPipelineEvents, send_event: nil) }
- let(:test_selector) { instance_double(Tooling::PredictiveTests::TestSelector, execute: nil) }
- let(:logger) { instance_double(Logger, info: nil, error: nil) }
+ let(:logger) { Logger.new(log_output) }
+ let(:log_output) { StringIO.new } # useful for debugging to print out all log output
+
+ let(:test_selector_described) do
+ instance_double(Tooling::PredictiveTests::TestSelector, rspec_spec_list: matching_tests_described_class_specs)
+ end
+
+ let(:test_selector_coverage) do
+ instance_double(Tooling::PredictiveTests::TestSelector, rspec_spec_list: matching_tests_coverage_specs)
+ end
let(:event_name) { "glci_predictive_tests_metrics" }
let(:extra_properties) { { ci_job_id: "123", test_type: "backend" } }
@@ -50,8 +58,8 @@ RSpec.describe Tooling::PredictiveTests::MetricsExporter, feature_category: :too
end
let(:changed_files) { mappings.values.pluck(:model) }
- let(:matching_tests_described_class_content) { mappings.dig(:user, :spec) }
- let(:matching_tests_coverage_content) { mappings.values.pluck(:spec).join(" ") }
+ let(:matching_tests_described_class_specs) { [mappings.dig(:user, :spec)] }
+ let(:matching_tests_coverage_specs) { mappings.values.pluck(:spec) }
let(:failed_tests_content) { "#{mappings.dig(:user, :spec)}\n#{mappings.dig(:todo, :spec)}" }
let(:described_class_mapping_content) do
@@ -101,40 +109,30 @@ RSpec.describe Tooling::PredictiveTests::MetricsExporter, feature_category: :too
# create files used as input for exporting selected test metrics
File.write(failed_tests_file, failed_tests_content)
- File.write(matching_tests_described_class_file, matching_tests_described_class_content)
- File.write(matching_tests_coverage_file, matching_tests_coverage_content)
File.write(coverage_mapping_file, coverage_mapping_content)
File.write(described_class_mapping_file, described_class_mapping_content)
- allow(Tooling::PredictiveTests::ChangedFiles).to receive(:fetch)
- .with(frontend_fixtures_file: frontend_fixtures_file)
- .and_return(changed_files)
- allow(Tooling::PredictiveTests::TestSelector).to receive(:new).and_return(test_selector)
- allow(Tooling::Events::TrackPipelineEvents).to receive(:new).and_return(event_tracker)
allow(Logger).to receive(:new).with($stdout, progname: "rspec predictive testing").and_return(logger)
+ allow(Tooling::Events::TrackPipelineEvents).to receive(:new).and_return(event_tracker)
+
+ allow(Tooling::PredictiveTests::ChangedFiles).to receive(:fetch).with(
+ frontend_fixtures_file: frontend_fixtures_file
+ ).and_return(changed_files)
+
+ allow(Tooling::PredictiveTests::TestSelector).to receive(:new).with(
+ changed_files: changed_files,
+ rspec_test_mapping_path: coverage_mapping_file,
+ rspec_mappings_limit_percentage: nil
+ ).and_return(test_selector_coverage)
+
+ allow(Tooling::PredictiveTests::TestSelector).to receive(:new).with(
+ changed_files: changed_files,
+ rspec_test_mapping_path: described_class_mapping_file,
+ rspec_mappings_limit_percentage: nil
+ ).and_return(test_selector_described)
end
describe "#execute" do
- it "creates selected test list for each strategy" do
- exporter.execute
-
- expect(Tooling::PredictiveTests::TestSelector).to have_received(:new).with(
- changed_files: changed_files,
- rspec_test_mapping_path: coverage_mapping_file,
- rspec_matching_test_files_path: matching_tests_coverage_file,
- rspec_matching_js_files_path: File.join(output_dir, "coverage", "js_matching_files.txt"),
- rspec_mappings_limit_percentage: nil
- )
- expect(Tooling::PredictiveTests::TestSelector).to have_received(:new).with(
- changed_files: changed_files,
- rspec_test_mapping_path: described_class_mapping_file,
- rspec_matching_test_files_path: matching_tests_described_class_file,
- rspec_matching_js_files_path: File.join(output_dir, "described_class", "js_matching_files.txt"),
- rspec_mappings_limit_percentage: nil
- )
- expect(test_selector).to have_received(:execute).twice
- end
-
it "exports metrics for described_class strategy", :aggregate_failures do
exporter.execute
diff --git a/spec/tooling/lib/tooling/predictive_tests/test_selector_spec.rb b/spec/tooling/lib/tooling/predictive_tests/test_selector_spec.rb
index e9ffac13dbd..726de206463 100644
--- a/spec/tooling/lib/tooling/predictive_tests/test_selector_spec.rb
+++ b/spec/tooling/lib/tooling/predictive_tests/test_selector_spec.rb
@@ -1,68 +1,61 @@
# frozen_string_literal: true
-require 'tempfile'
-require 'fileutils'
-
-require_relative '../../../../../tooling/lib/tooling/predictive_tests/test_selector'
+require_relative "../../../../../tooling/lib/tooling/predictive_tests/test_selector"
RSpec.describe Tooling::PredictiveTests::TestSelector, :aggregate_failures, feature_category: :tooling do
subject(:test_selector) do
- described_class.new(
- changed_files: changed_files,
- rspec_matching_test_files_path: test_files_path,
- rspec_matching_js_files_path: matching_js_files_path,
- rspec_test_mapping_path: crystalball_mapping_path
- )
+ described_class.new(changed_files: changed_files, rspec_test_mapping_path: crystalball_mapping_path)
end
- let(:test_files_path) { 'matching_test_files.txt' }
- let(:matching_js_files_path) { 'matching_js_files.txt' }
- let(:views_with_partials_path) { 'views_with_partials.txt' }
- let(:crystalball_mapping_path) { 'crystalball_mapping.txt' }
+ let(:crystalball_mapping_path) { "crystalball_mapping.txt" }
+ let(:changed_files) { ["app/models/user.rb", "app/models/todo.rb"] }
let(:rspec_mappings_limit_percentage) { 50 }
- let(:find_tests) { instance_double(Tooling::FindTests, execute: nil) }
- let(:graphql_mappings) { instance_double(Tooling::Mappings::GraphqlBaseTypeMappings, execute: nil) }
- let(:view_to_system_mappings) { instance_double(Tooling::Mappings::ViewToSystemSpecsMappings, execute: nil) }
- let(:view_to_js_mappings) { instance_double(Tooling::Mappings::ViewToJsMappings, execute: nil) }
- let(:js_to_system_mappings) { instance_double(Tooling::Mappings::JsToSystemSpecsMappings, execute: nil) }
+ let(:find_tests) { instance_double(Tooling::FindTests, execute: ["specs_from_mapping"]) }
+ let(:view_to_js_mappings) { instance_double(Tooling::Mappings::ViewToJsMappings, execute: ["jest_spec_list"]) }
- let(:changed_files) { ['app/models/user.rb', 'app/models/todo.rb'] }
+ let(:graphql_mappings) do
+ instance_double(Tooling::Mappings::GraphqlBaseTypeMappings, execute: ["specs_from_graphql"])
+ end
+
+ let(:view_to_system_mappings) do
+ instance_double(Tooling::Mappings::ViewToSystemSpecsMappings, execute: ["specs_from_views"])
+ end
+
+ let(:js_to_system_mappings) do
+ instance_double(Tooling::Mappings::JsToSystemSpecsMappings, execute: ["specs_from_js"])
+ end
before do
allow(Tooling::FindTests).to receive(:new).and_return(find_tests)
allow(Tooling::Mappings::GraphqlBaseTypeMappings).to receive(:new).and_return(graphql_mappings)
allow(Tooling::Mappings::ViewToSystemSpecsMappings).to receive(:new).and_return(view_to_system_mappings)
- allow(Tooling::Mappings::ViewToJsMappings).to receive(:new).and_return(view_to_js_mappings)
allow(Tooling::Mappings::JsToSystemSpecsMappings).to receive(:new).and_return(js_to_system_mappings)
+ allow(Tooling::Mappings::ViewToJsMappings).to receive(:new).and_return(view_to_js_mappings)
allow(Logger).to receive(:new).and_return(Logger.new(StringIO.new))
end
- it 'generates predictive rspec test list by calling correct helpers' do
- test_selector.execute
+ it "generates predictive rspec test list" do
+ expect(test_selector.rspec_spec_list).to match_array(%w[
+ specs_from_graphql
+ specs_from_views
+ specs_from_js
+ specs_from_mapping
+ ])
+ expect(Tooling::Mappings::GraphqlBaseTypeMappings).to have_received(:new).with(changed_files)
+ expect(Tooling::Mappings::ViewToSystemSpecsMappings).to have_received(:new).with(changed_files)
+ expect(Tooling::Mappings::JsToSystemSpecsMappings).to have_received(:new).with(changed_files)
expect(Tooling::FindTests).to have_received(:new).with(
changed_files,
- test_files_path,
mappings_file: crystalball_mapping_path,
mappings_limit_percentage: rspec_mappings_limit_percentage
)
- expect(find_tests).to have_received(:execute)
-
- expect(Tooling::Mappings::GraphqlBaseTypeMappings).to have_received(:new).with(changed_files, test_files_path)
- expect(graphql_mappings).to have_received(:execute)
-
- expect(Tooling::Mappings::ViewToSystemSpecsMappings).to have_received(:new).with(changed_files, test_files_path)
- expect(view_to_system_mappings).to have_received(:execute)
-
- expect(Tooling::Mappings::JsToSystemSpecsMappings).to have_received(:new).with(changed_files, test_files_path)
- expect(js_to_system_mappings).to have_received(:execute)
end
- it 'generates predictive js test list by calling correct helpers' do
- test_selector.execute
-
- expect(Tooling::Mappings::ViewToJsMappings).to have_received(:new).with(changed_files, matching_js_files_path)
+ it "generates predictive js test" do
+ expect(test_selector.js_spec_list).to match_array(["jest_spec_list"])
+ expect(Tooling::Mappings::ViewToJsMappings).to have_received(:new).with(changed_files)
end
end
diff --git a/spec/workers/concerns/application_worker_spec.rb b/spec/workers/concerns/application_worker_spec.rb
index 0148035d485..eba6725fdf1 100644
--- a/spec/workers/concerns/application_worker_spec.rb
+++ b/spec/workers/concerns/application_worker_spec.rb
@@ -540,18 +540,6 @@ RSpec.describe ApplicationWorker, feature_category: :shared do
end
end
- describe 'concurrency_limit' do
- before do
- stub_const(worker.name, worker)
- end
-
- it 'sets concurrency_limit by default' do
- expect(::Gitlab::SidekiqMiddleware::ConcurrencyLimit::WorkersMap.workers).to include(Gitlab::Foo::Bar::DummyWorker)
- expect(::Gitlab::SidekiqMiddleware::ConcurrencyLimit::WorkersMap.limit_for(worker: Gitlab::Foo::Bar::DummyWorker))
- .to eq 0
- end
- end
-
describe '.concurrency_limit_resume' do
around do |example|
Sidekiq::Testing.fake!(&example)
diff --git a/spec/workers/concerns/worker_attributes_spec.rb b/spec/workers/concerns/worker_attributes_spec.rb
index 4670f31a359..6782879d863 100644
--- a/spec/workers/concerns/worker_attributes_spec.rb
+++ b/spec/workers/concerns/worker_attributes_spec.rb
@@ -67,6 +67,7 @@ RSpec.describe WorkerAttributes, feature_category: :shared do
:get_weight | :weight | 1 | [3] | {} | 3
:get_tags | :tags | [] | [:foo, :bar] | {} | [:foo, :bar]
:get_deduplicate_strategy | :deduplicate | :until_executing | [:none] | {} | :none
+ :get_max_concurrency_limit_percentage | :max_concurrency_limit_percentage | 0.25 | 0.5 | {} | 0.5
:get_deduplication_options | :deduplicate | {} | [:none, { including_scheduled: true }] | {} | { including_scheduled: true }
:database_health_check_attrs | :defer_on_database_health_signal | nil | [:gitlab_main, [:users], 1.minute] | {} | { gitlab_schema: :gitlab_main, tables: [:users], delay_by: 1.minute, block: nil }
@@ -349,4 +350,34 @@ RSpec.describe WorkerAttributes, feature_category: :shared do
it { is_expected.to be(false) }
end
end
+
+ describe '.max_concurrency_limit_percentage' do
+ subject(:max_concurrency_limit_percentage) { worker.max_concurrency_limit_percentage(percentage) }
+
+ context 'when value is invalid' do
+ shared_examples 'invalid argument' do
+ it 'raises ArgumentError' do
+ expect { max_concurrency_limit_percentage }.to raise_error(ArgumentError)
+ end
+ end
+
+ context 'with negative value' do
+ let(:percentage) { -1 }
+
+ it_behaves_like 'invalid argument'
+ end
+
+ context 'with value > 1' do
+ let(:percentage) { 1.1 }
+
+ it_behaves_like 'invalid argument'
+ end
+
+ context 'with non Numeric type' do
+ let(:percentage) { "asd" }
+
+ it_behaves_like 'invalid argument'
+ end
+ end
+ end
end
diff --git a/tooling/bin/predictive_tests b/tooling/bin/predictive_tests
index 7da161a246d..fd5bcf482a7 100755
--- a/tooling/bin/predictive_tests
+++ b/tooling/bin/predictive_tests
@@ -73,15 +73,15 @@ if options[:select_tests]
changed_files = Tooling::PredictiveTests::ChangedFiles.fetch(
frontend_fixtures_file: ENV['FRONTEND_FIXTURES_MAPPING_PATH']
)
-
- Tooling::PredictiveTests::TestSelector.new(
+ test_selector = Tooling::PredictiveTests::TestSelector.new(
changed_files: changed_files,
- rspec_matching_test_files_path: ENV['RSPEC_MATCHING_TEST_FILES_PATH'],
- rspec_matching_js_files_path: ENV['RSPEC_MATCHING_JS_FILES_PATH'],
rspec_test_mapping_path: test_mapping_file
- ).execute
+ )
- # File with a list of mr changes is also used by frontend related pipelines/jobs
+ # Used to generate predictive rspec test pipelines
+ File.write(ENV['RSPEC_MATCHING_TEST_FILES_PATH'], test_selector.rspec_spec_list.join(" "))
+ # Used by frontend related pipelines/jobs
+ File.write(ENV['RSPEC_MATCHING_JS_FILES_PATH'], test_selector.js_spec_list.join(" "))
File.write(ENV['RSPEC_CHANGED_FILES_PATH'], changed_files.join("\n"))
elsif options[:export_rspec_metrics]
require_relative '../lib/tooling/predictive_tests/metrics_exporter'
diff --git a/tooling/lib/tooling/find_tests.rb b/tooling/lib/tooling/find_tests.rb
index 9ef9256168c..1512e0055e9 100644
--- a/tooling/lib/tooling/find_tests.rb
+++ b/tooling/lib/tooling/find_tests.rb
@@ -9,11 +9,9 @@ module Tooling
def initialize(
changed_files,
- predictive_tests_pathname,
mappings_file: nil,
mappings_limit_percentage: nil
)
- @predictive_tests_pathname = predictive_tests_pathname
@changed_files = changed_files
@mappings_file = mappings_file
@mappings_limit_percentage = mappings_limit_percentage
@@ -32,11 +30,11 @@ module Tooling
file_finder.use TestFileFinder::MappingStrategies::PatternMatching.load('tests.yml')
end
- write_array_to_file(predictive_tests_pathname, tff.test_files.uniq)
+ tff.test_files.uniq
end
private
- attr_reader :changed_files, :predictive_tests_pathname, :mappings_file, :mappings_limit_percentage
+ attr_reader :changed_files, :mappings_file, :mappings_limit_percentage
end
end
diff --git a/tooling/lib/tooling/mappings/graphql_base_type_mappings.rb b/tooling/lib/tooling/mappings/graphql_base_type_mappings.rb
index 4a0c8c96577..e8acc5a54f0 100644
--- a/tooling/lib/tooling/mappings/graphql_base_type_mappings.rb
+++ b/tooling/lib/tooling/mappings/graphql_base_type_mappings.rb
@@ -25,16 +25,15 @@ module Tooling
'jh' => GRAPHQL_TYPES_FOLDERS_JH
}.freeze
- def initialize(changed_files, predictive_tests_pathname)
- @changed_files = changed_files
- @predictive_tests_pathname = predictive_tests_pathname
+ def initialize(changed_files)
+ @changed_files = changed_files
end
def execute
# We go through the available editions when searching for base types
#
# `nil` is the FOSS edition
- matching_graphql_tests = ([nil] + ::GitlabEdition.extensions).flat_map do |edition|
+ ([nil] + ::GitlabEdition.extensions).flat_map do |edition|
hierarchy = types_hierarchies[edition]
filter_files.flat_map do |graphql_file|
@@ -45,8 +44,6 @@ module Tooling
children_types.map { |filename| filename_to_spec_filename(filename) }
end
end.compact.uniq
-
- write_array_to_file(predictive_tests_pathname, matching_graphql_tests)
end
def filter_files
@@ -113,12 +110,12 @@ module Tooling
def filename_to_spec_filename(filename)
spec_file = filename.sub('app', 'spec').sub('.rb', '_spec.rb')
- return spec_file if File.exist?(spec_file)
+ spec_file if File.exist?(spec_file)
end
private
- attr_reader :changed_files, :predictive_tests_pathname
+ attr_reader :changed_files
end
end
end
diff --git a/tooling/lib/tooling/mappings/js_to_system_specs_mappings.rb b/tooling/lib/tooling/mappings/js_to_system_specs_mappings.rb
index 8ae64cce1c6..63baae0a465 100644
--- a/tooling/lib/tooling/mappings/js_to_system_specs_mappings.rb
+++ b/tooling/lib/tooling/mappings/js_to_system_specs_mappings.rb
@@ -11,12 +11,10 @@ module Tooling
def initialize(
changed_files,
- predictive_tests_pathname,
js_base_folder: 'app/assets/javascripts',
system_specs_base_folder: 'spec/features'
)
@changed_files = changed_files
- @predictive_tests_pathname = predictive_tests_pathname
@js_base_folder = js_base_folder
@js_base_folders = folders_for_available_editions(js_base_folder)
@system_specs_base_folder = system_specs_base_folder
@@ -31,15 +29,13 @@ module Tooling
end
def execute
- matching_system_tests = filter_files.flat_map do |edition, js_files|
+ filter_files.flat_map do |edition, js_files|
js_keywords_regexp = Regexp.union(construct_js_keywords(js_files))
system_specs_for_edition(edition).select do |system_spec_file|
system_spec_file if js_keywords_regexp.match?(system_spec_file)
end
end
-
- write_array_to_file(predictive_tests_pathname, matching_system_tests)
end
# Keep the files that are in the @js_base_folders folders
@@ -84,7 +80,7 @@ module Tooling
private
- attr_reader :changed_files, :predictive_tests_pathname
+ attr_reader :changed_files
end
end
end
diff --git a/tooling/lib/tooling/mappings/view_to_js_mappings.rb b/tooling/lib/tooling/mappings/view_to_js_mappings.rb
index dc07b0f8a00..11b00c77229 100644
--- a/tooling/lib/tooling/mappings/view_to_js_mappings.rb
+++ b/tooling/lib/tooling/mappings/view_to_js_mappings.rb
@@ -15,16 +15,10 @@ module Tooling
# Search for Rails partials included in an HTML file
RAILS_PARTIAL_INVOCATION_REGEXP = %r{(?:render|render_if_exists)(?: |\()(?:partial: ?)?['"]([\w/-]+)['"]}
- def initialize(
- changed_files,
- predictive_tests_pathname,
- view_base_folder: 'app/views',
- js_base_folder: 'app/assets/javascripts'
- )
- @changed_files = changed_files
- @predictive_tests_pathname = predictive_tests_pathname
- @view_base_folders = folders_for_available_editions(view_base_folder)
- @js_base_folders = folders_for_available_editions(js_base_folder)
+ def initialize(changed_files, view_base_folder: 'app/views', js_base_folder: 'app/assets/javascripts')
+ @changed_files = changed_files
+ @view_base_folders = folders_for_available_editions(view_base_folder)
+ @js_base_folders = folders_for_available_editions(js_base_folder)
end
def execute
@@ -38,14 +32,12 @@ module Tooling
end
js_tags_regexp = Regexp.union(js_tags)
- matching_js_files = @js_base_folders.flat_map do |js_base_folder|
+ @js_base_folders.flat_map do |js_base_folder|
Dir["#{js_base_folder}/**/*.{js,vue}"].select do |js_file|
file_content = File.read(js_file)
js_tags_regexp.match?(file_content)
end
end
-
- write_array_to_file(predictive_tests_pathname, matching_js_files)
end
# Keep the files that are in the @view_base_folders folder
@@ -81,7 +73,7 @@ module Tooling
private
- attr_reader :changed_files, :predictive_tests_pathname
+ attr_reader :changed_files
end
end
end
diff --git a/tooling/lib/tooling/mappings/view_to_system_specs_mappings.rb b/tooling/lib/tooling/mappings/view_to_system_specs_mappings.rb
index 9c10661d3d9..3f52b5b874a 100644
--- a/tooling/lib/tooling/mappings/view_to_system_specs_mappings.rb
+++ b/tooling/lib/tooling/mappings/view_to_system_specs_mappings.rb
@@ -9,10 +9,9 @@ module Tooling
class ViewToSystemSpecsMappings
include Helpers::PredictiveTestsHelper
- def initialize(changed_files, predictive_tests_pathname, view_base_folder: 'app/views')
- @changed_files = changed_files
- @predictive_tests_pathname = predictive_tests_pathname
- @view_base_folders = folders_for_available_editions(view_base_folder)
+ def initialize(changed_files, view_base_folder: 'app/views')
+ @changed_files = changed_files
+ @view_base_folders = folders_for_available_editions(view_base_folder)
end
def execute
@@ -29,12 +28,12 @@ module Tooling
end
end
- write_array_to_file(predictive_tests_pathname, found_system_specs.compact.uniq.sort)
+ found_system_specs.compact.uniq.sort
end
private
- attr_reader :changed_files, :predictive_tests_pathname, :view_base_folders
+ attr_reader :changed_files, :view_base_folders
# Keep the views files that are in the @view_base_folders folder
def filter_files
diff --git a/tooling/lib/tooling/predictive_tests/metrics_exporter.rb b/tooling/lib/tooling/predictive_tests/metrics_exporter.rb
index 38ac149dd6f..ca7ff00ce7a 100644
--- a/tooling/lib/tooling/predictive_tests/metrics_exporter.rb
+++ b/tooling/lib/tooling/predictive_tests/metrics_exporter.rb
@@ -40,7 +40,6 @@ module Tooling
def execute
STRATEGIES.each do |strategy|
logger.info("Running metrics export for '#{strategy}' strategy ...")
- create_test_list!(strategy)
generate_and_record_metrics(strategy)
rescue StandardError => e
logger.error("Failed to export test metrics for strategy '#{strategy}': #{e.message}")
@@ -110,18 +109,16 @@ module Tooling
File.join(output_path, strategy.to_s, *args)
end
- # Create selected test list using specific strategy mapping
+ # Predictive spec list selector
#
# @param strategy [Symbol]
- # @return [void]
- def create_test_list!(strategy)
+ # @return [TestSelector]
+ def test_selector(strategy)
Tooling::PredictiveTests::TestSelector.new(
changed_files: changed_files,
rspec_test_mapping_path: mapping_file_path(strategy),
- rspec_matching_test_files_path: matching_rspec_test_files_path(strategy),
- rspec_matching_js_files_path: path_for_strategy(strategy, "js_matching_files.txt"),
rspec_mappings_limit_percentage: nil # always return all tests in the mapping
- ).execute
+ )
end
# Create, save and export metrics for selected RSpec tests for specific strategy
@@ -132,7 +129,7 @@ module Tooling
logger.info("Generating metrics for mapping strategy '#{strategy}' ...")
# based on the predictive test selection strategy
- predicted_test_files = read_array_from_file(matching_rspec_test_files_path(strategy))
+ predicted_test_files = test_selector(strategy).rspec_spec_list
# actual failed tests from tier-3 run
failed_test_files = read_array_from_file(rspec_all_failed_tests_file)
# crystalball mapping file
diff --git a/tooling/lib/tooling/predictive_tests/test_selector.rb b/tooling/lib/tooling/predictive_tests/test_selector.rb
index 4256b1341d7..009a78343f6 100644
--- a/tooling/lib/tooling/predictive_tests/test_selector.rb
+++ b/tooling/lib/tooling/predictive_tests/test_selector.rb
@@ -10,78 +10,61 @@ require_relative '../mappings/js_to_system_specs_mappings'
require_relative '../mappings/view_to_js_mappings'
require_relative '../mappings/view_to_system_specs_mappings'
+# rubocop:disable Gitlab/Json -- not rails
module Tooling
module PredictiveTests
class TestSelector
def initialize(
changed_files:,
- rspec_matching_test_files_path:,
- rspec_matching_js_files_path:,
rspec_test_mapping_path: nil,
# See https://gitlab.com/gitlab-org/gitlab/-/issues/450374#note_1836131381 on why limit might be used
rspec_mappings_limit_percentage: 50
)
@changed_files = changed_files
- @rspec_matching_test_files_path = rspec_matching_test_files_path
- @rspec_matching_js_files_path = rspec_matching_js_files_path
@rspec_test_mapping_path = rspec_test_mapping_path
@rspec_mappings_limit_percentage = rspec_mappings_limit_percentage
@logger = Logger.new($stdout, progname: "predictive testing")
end
- def execute
- logger.info(
- "Creating predictive test list based on following changed files: #{JSON.pretty_generate(changed_files)}" # rubocop:disable Gitlab/Json -- not rails
- )
+ # Predictive rspec test files specs list
+ #
+ # @return [Array]
+ def rspec_spec_list
+ logger.info "Creating predictive rspec test files specs list ..."
+ specs = {
+ crystalball_mapping_specs: specs_from_mapping,
+ graphql_type_mapping_specs: specs_from_graphql_base_types,
+ js_changes_specs: system_specs_from_js_changes,
+ view_changes_specs: system_specs_from_view_changes
+ }
- create_rspec_spec_list!
- create_js_spec_list!
+ logger.info("Generated following rspec specs list: #{JSON.pretty_generate(specs)}")
+ specs.values.flatten
+ end
+
+ # Predictive js test files specs list
+ #
+ # @return [Array]
+ def js_spec_list
+ logger.info "Creating predictive js test files specs list ..."
+ Tooling::Mappings::ViewToJsMappings.new(changed_files).execute.tap do |specs|
+ logger.info "Generated following jest spec list: #{JSON.pretty_generate(specs)}"
+ end
end
private
attr_reader :changed_files,
- :rspec_matching_test_files_path,
- :rspec_matching_js_files_path,
:rspec_test_mapping_path,
:rspec_mappings_limit_percentage,
:logger
- # Create predictive rspec test files specs list
- #
- # @return [void]
- def create_rspec_spec_list!
- logger.info "Creating predictive rspec test files specs list ..."
- # TODO: Remove appending to file and work with arrays directly
- append_specs_from_mapping!
- append_specs_from_graphql_base_types!
- append_system_specs_from_js_changes!
- append_system_specs_from_view_changes!
- end
-
- # Create predictive js test files specs list
- #
- # @return [void]
- def create_js_spec_list!
- logger.info "Creating predictive js test files specs list ..."
- Tooling::Mappings::ViewToJsMappings.new(changed_files, rspec_matching_js_files_path).execute
- end
-
- # Create list of view files that include the potential rails partials
- #
- # @return [void]
- def create_view_partials_mapping_file!
- logger.info "Creating list of view files that include the potential rails partials ..."
- Tooling::Mappings::PartialToViewsMappings.new(changed_files, rspec_views_including_partials_path).execute
- end
-
# Add specs based on crystalball mapping or static tests.yml file
#
# @return [void]
- def append_specs_from_mapping!
- Tooling::FindTests.new(
+ def specs_from_mapping
+ @specs_from_mapping ||= Tooling::FindTests.new(
changed_files,
- rspec_matching_test_files_path,
mappings_file: rspec_test_mapping_path,
mappings_limit_percentage: rspec_mappings_limit_percentage
).execute
@@ -90,23 +73,24 @@ module Tooling
# Add system specs based on changes to JS files.
#
# @return [void]
- def append_system_specs_from_js_changes!
- Tooling::Mappings::JsToSystemSpecsMappings.new(changed_files, rspec_matching_test_files_path).execute
+ def system_specs_from_js_changes
+ @system_specs_from_js_changes ||= Tooling::Mappings::JsToSystemSpecsMappings.new(changed_files).execute
end
# Add specs based on potential changes to the GraphQL base types
#
# @return [void]
- def append_specs_from_graphql_base_types!
- Tooling::Mappings::GraphqlBaseTypeMappings.new(changed_files, rspec_matching_test_files_path).execute
+ def specs_from_graphql_base_types
+ @specs_from_graphql_base_types ||= Tooling::Mappings::GraphqlBaseTypeMappings.new(changed_files).execute
end
# Add system specs based on changes to views.
#
# @return [void]
- def append_system_specs_from_view_changes!
- Tooling::Mappings::ViewToSystemSpecsMappings.new(changed_files, rspec_matching_test_files_path).execute
+ def system_specs_from_view_changes
+ @system_specs_from_view_changes ||= Tooling::Mappings::ViewToSystemSpecsMappings.new(changed_files).execute
end
end
end
end
+# rubocop:enable Gitlab/Json -- not rails
diff --git a/workhorse/.tool-versions b/workhorse/.tool-versions
index 49aa26531dd..addf7042386 100644
--- a/workhorse/.tool-versions
+++ b/workhorse/.tool-versions
@@ -1 +1 @@
-golang 1.24.4
+golang 1.24.5