Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2025-07-17 21:12:03 +00:00
parent 407107485a
commit 9c7ce66dac
38 changed files with 171 additions and 154 deletions

View File

@ -11,7 +11,6 @@ export default {
'app/assets/javascripts/behaviors/components/json_table.vue',
'app/assets/javascripts/behaviors/components/sandboxed_mermaid.vue',
'app/assets/javascripts/behaviors/shortcuts/shortcut.vue',
'app/assets/javascripts/blob/filepath_form/components/template_selector.vue',
'app/assets/javascripts/boards/components/board_add_new_column_form.vue',
'app/assets/javascripts/boards/components/board_card_inner.vue',
'app/assets/javascripts/boards/components/board_card_move_to_position.vue',

View File

@ -55,7 +55,6 @@ export default {
loading: false,
searchTerm: '',
selectedTemplate: undefined,
types: templateSelectors,
};
},
computed: {

View File

@ -17,6 +17,11 @@ module Enums # rubocop:disable Gitlab/BoundedContexts -- Existing module
cluster_image_scanning: 9
}.freeze
CONFIGURATION_SOURCE_TYPES = {
sbom: 0,
pmdb: 1
}.with_indifferent_access.freeze
def self.analyzer_types
ANALYZER_TYPES
end
@ -29,5 +34,9 @@ module Enums # rubocop:disable Gitlab/BoundedContexts -- Existing module
container_scanning_pipeline_based: 13
})
end
def self.configuration_source_types
CONFIGURATION_SOURCE_TYPES
end
end
end

View File

@ -28,19 +28,8 @@ class DescriptionVersion < ApplicationRecord
private
def parent_namespace_id
case issuable
when Issue
issuable.namespace_id
when MergeRequest
issuable.project.project_namespace_id
end
end
def ensure_namespace_id
return if namespace_id && namespace_id > 0
self.namespace_id = parent_namespace_id
self.namespace_id = Gitlab::Issuable::NamespaceGetter.new(issuable, allow_nil: true).namespace_id
end
def exactly_one_issuable

View File

@ -40,11 +40,7 @@ class ResourceMilestoneEvent < ResourceTimeboxEvent
def ensure_namespace_id
# Due to how these records are created. I think it's better to always assign the right namespace before validation
# instead of only doing it conditionally. These records never get updated.
self.namespace_id = if merge_request.present?
merge_request.project&.project_namespace_id
elsif issue.present?
issue.namespace_id
end
self.namespace_id = Gitlab::Issuable::NamespaceGetter.new(issuable, allow_nil: true).namespace_id
end
end

View File

@ -40,17 +40,8 @@ class ResourceStateEvent < ResourceEvent
private
def parent_namespace_id
case issuable
when Issue
issuable.namespace_id
when MergeRequest
issuable.project.project_namespace_id
end
end
def ensure_namespace_id
self.namespace_id = parent_namespace_id
self.namespace_id = Gitlab::Issuable::NamespaceGetter.new(issuable, allow_nil: true).namespace_id
end
def issue_usage_metrics

View File

@ -43,4 +43,4 @@ class ResourceTimeboxEvent < ResourceEvent
end
end
ResourceTimeboxEvent.prepend_mod_with('ResourceTimeboxEvent')
ResourceTimeboxEvent.prepend_mod

View File

@ -82,8 +82,7 @@ module BulkImports
if Import::BulkImports::EphemeralData.new(entity.bulk_import.id).importer_user_mapping_enabled?
Import::LoadPlaceholderReferencesWorker.perform_async(
Import::SOURCE_DIRECT_TRANSFER,
entity.bulk_import.id,
'current_user_id' => entity.bulk_import.user_id
entity.bulk_import.id
)
end
end

View File

@ -34,8 +34,7 @@ module Gitlab
def reschedule(project)
::Import::LoadPlaceholderReferencesWorker.perform_async(
project.import_type,
project.import_state.id,
{ current_user_id: project.creator_id }
project.import_state.id
)
self.class.perform_in(PLACEHOLDER_WAIT_INTERVAL.seconds, project.id)

View File

@ -59,8 +59,8 @@ module Gitlab
def load_references(project)
::Import::LoadPlaceholderReferencesWorker.perform_async(
::Import::SOURCE_GITHUB,
project.import_state.id,
{ 'current_user_id' => project.creator_id })
project.import_state.id
)
end
end
end

View File

@ -32,8 +32,7 @@ module Gitlab
::Import::LoadPlaceholderReferencesWorker.perform_async(
::Import::SOURCE_GITHUB,
project.import_state.id,
{ 'current_user_id' => project.creator.id }
project.import_state.id
)
info(

View File

@ -8,14 +8,6 @@ description: Join table for approved approvers and ApprovalMergeRequestRule
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/8497
milestone: '11.7'
gitlab_schema: gitlab_main_cell
desired_sharding_key:
project_id:
references: projects
backfill_via:
parent:
foreign_key: approval_merge_request_rule_id
table: approval_merge_request_rules
sharding_key: project_id
belongs_to: approval_merge_request_rule
sharding_key:
project_id: projects
table_size: medium
desired_sharding_key_migration_job_name: BackfillApprovalMergeRequestRulesApprovedApproversProjectId

View File

@ -0,0 +1,13 @@
# frozen_string_literal: true
class AddLicenseConfigurationToProjectSecuritySettings < Gitlab::Database::Migration[2.3]
milestone '18.3'
def up
add_column :project_security_settings, :license_configuration_source, :smallint, default: 0, null: false
end
def down
remove_column :project_security_settings, :license_configuration_source
end
end

View File

@ -0,0 +1,14 @@
# frozen_string_literal: true
class AddApprovalMergeRequestRulesApprovedApproversProjectIdNotNull < Gitlab::Database::Migration[2.3]
milestone '18.3'
disable_ddl_transaction!
def up
add_not_null_constraint :approval_merge_request_rules_approved_approvers, :project_id
end
def down
remove_not_null_constraint :approval_merge_request_rules_approved_approvers, :project_id
end
end

View File

@ -0,0 +1 @@
344de3005dc78a98c4bafe9f06d30794978c43ca40beef5a190376fdad822d9f

View File

@ -0,0 +1 @@
6c113181be48ce430ad7104facd0f956f6cddbf37eabc733cef1f0e306e44b73

View File

@ -9888,7 +9888,8 @@ CREATE TABLE approval_merge_request_rules_approved_approvers (
id bigint NOT NULL,
approval_merge_request_rule_id bigint NOT NULL,
user_id bigint NOT NULL,
project_id bigint
project_id bigint,
CONSTRAINT check_4e73655ce3 CHECK ((project_id IS NOT NULL))
);
CREATE SEQUENCE approval_merge_request_rules_approved_approvers_id_seq
@ -21939,6 +21940,7 @@ CREATE TABLE project_security_settings (
pre_receive_secret_detection_enabled boolean DEFAULT false NOT NULL,
secret_push_protection_enabled boolean DEFAULT false,
validity_checks_enabled boolean DEFAULT false NOT NULL,
license_configuration_source smallint DEFAULT 0 NOT NULL,
CONSTRAINT check_20a23efdb6 CHECK ((secret_push_protection_enabled IS NOT NULL))
);

View File

@ -9,14 +9,14 @@ title: GitLab Duo Agent Platform
- Tier: Premium, Ultimate
- Add-on: GitLab Duo Core, Pro, or Enterprise
- Offering: GitLab.com, GitLab Self-Managed
- Status: Experiment
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
- Status: Beta
{{< /details >}}
{{< history >}}
- Introduced as [an experiment](../../policy/development_stages_support.md) in GitLab 18.2.
- Introduced as [a beta](../../policy/development_stages_support.md) in GitLab 18.2.
{{< /history >}}

View File

@ -9,8 +9,8 @@ title: Agent flows
- Tier: Premium, Ultimate
- Add-on: GitLab Duo Core, Pro, or Enterprise
- Offering: GitLab.com, GitLab Self-Managed
- Status: Experiment
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
- Status: Beta
- LLM: Anthropic [Claude Sonnet 4](https://www.anthropic.com/claude/sonnet)
{{< /details >}}
@ -18,7 +18,7 @@ title: Agent flows
{{< history >}}
- [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/14153) in GitLab 17.4 [with a flag](../../administration/feature_flags/_index.md) named `duo_workflow`. Enabled for GitLab team members only. This feature is a [private beta](../../policy/development_stages_support.md).
- [Changed name](https://gitlab.com/gitlab-org/gitlab/-/issues/551382) and `duo_workflow` [flag enabled](../../administration/feature_flags/_index.md) in GitLab 18.2.
- [Changed name](https://gitlab.com/gitlab-org/gitlab/-/issues/551382), `duo_workflow` [flag enabled](../../administration/feature_flags/_index.md), and status changed to beta in GitLab 18.2.
{{< /history >}}

View File

@ -9,8 +9,8 @@ title: Troubleshooting the software development flow
- Tier: Premium, Ultimate
- Add-on: GitLab Duo Core, Pro, or Enterprise
- Offering: GitLab.com, GitLab Self-Managed
- Status: Experiment
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
- Status: Beta
{{< /details >}}

View File

@ -9,8 +9,8 @@ title: GitLab Duo Agentic Chat
- Tier: Premium, Ultimate
- Add-on: GitLab Duo Core, Pro, or Enterprise
- Offering: GitLab.com, GitLab Self-Managed
- Status: Experiment
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
- Status: Beta
- LLMs: Anthropic [Claude Sonnet 4](https://console.cloud.google.com/vertex-ai/publishers/anthropic/model-garden/claude-sonnet-4)
{{< /details >}}
@ -22,6 +22,7 @@ title: GitLab Duo Agentic Chat
- GitLab UI [introduced on GitLab.com and GitLab Self-Managed](https://gitlab.com/gitlab-org/gitlab/-/issues/546140) in GitLab 18.2 [with flags](../../administration/feature_flags/_index.md) named `duo_workflow_workhorse` and `duo_workflow_web_chat_mutation_tools`. Both flags are enabled by default.
- Feature flag `duo_agentic_chat` enabled by default in GitLab 18.2.
- JetBrains IDEs [introduced](https://gitlab.com/gitlab-org/editor-extensions/gitlab-jetbrains-plugin/-/issues/1077) in GitLab 18.2.
- GitLab Duo Agentic Chat changed to beta in GitLab 18.2.
{{< /history >}}

View File

@ -26,7 +26,7 @@ You can create and manage your snippets with:
- The [GitLab Workflow extension for VS Code](../editor_extensions/visual_studio_code/_index.md#create-a-snippet).
- The [`glab` CLI](../editor_extensions/gitlab_cli/_index.md).
![Example of a snippet](img/snippet_sample_v16_6.png)
![A code snippet showing sample content in GitLab.](img/snippet_sample_v16_6.png)
GitLab provides two types of snippets:
@ -152,7 +152,7 @@ subscription levels, and [groups](project/wiki/group.md) for
Snippets with multiple files display a file count in the [snippet list](https://gitlab.com/dashboard/snippets):
![Example of snippet](img/snippet_tooltip_v17_4.png)
![A tooltip displaying details of a GitLab snippet.](img/snippet_tooltip_v17_4.png)
You can manage snippets with Git (because they're [versioned](#versioned-snippets)
by a Git repository), through the [Snippets API](../api/snippets.md), and in the GitLab UI.

View File

@ -341,8 +341,7 @@ module Gitlab
::Import::LoadPlaceholderReferencesWorker.perform_async(
project.import_type,
project.import_state.id,
'current_user_id' => project.creator_id
project.import_state.id
)
end

View File

@ -219,8 +219,7 @@ RSpec.describe Gitlab::LegacyGithubImport::Importer, :clean_gitlab_redis_shared_
stages_that_push_placeholder_references.length
).times.with(
project.import_type,
project.import_state.id,
'current_user_id' => project.creator_id
project.import_state.id
)
importer.execute

View File

@ -45,20 +45,6 @@ RSpec.describe DescriptionVersion do
expect(version.namespace_id).to eq(issue.namespace.id)
end
context 'when namespace_id is 0' do
before do
version.namespace_id = 0
end
it 'sets the namespace id from the issue namespace id' do
expect(version.namespace_id).to eq(0)
version.valid?
expect(version.namespace_id).to eq(issue.namespace.id)
end
end
end
context 'when version belongs to a group issue' do

View File

@ -35,6 +35,12 @@ RSpec.describe GroupGroupLink, feature_category: :groups_and_projects do
it { is_expected.to belong_to(:shared_with_group) }
end
describe '.default_access' do
it 'returns DEVELOPER access level' do
expect(described_class.default_access).to eq(Gitlab::Access::DEVELOPER)
end
end
describe 'scopes' do
context 'for scopes fetching records based on access levels' do
let_it_be(:group_group_link_guest) { create :group_group_link, :guest }

View File

@ -5,60 +5,48 @@ require_relative '../../../../../tooling/lib/tooling/predictive_tests/changed_fi
RSpec.describe Tooling::PredictiveTests::ChangedFiles, :aggregate_failures, feature_category: :tooling do
subject(:changed_files) { described_class }
let(:mr_changes) { ['app/models/user.rb', 'app/models/todo.rb'] }
let(:base_changes) { ['app/models/user.rb', 'app/models/todo.rb'] }
let(:ff_files) { ['app/features/dummy_feature_2.rb'] }
let(:views) { ['app/views/todos/show.html.haml', 'app/views/todos/_todo.haml'] }
let(:find_changes) { instance_double(Tooling::FindChanges, execute: mr_changes) }
let(:find_files_using_feature_flags) { instance_double(Tooling::FindFilesUsingFeatureFlags, execute: ff_files) }
let(:partial_to_views_mappings) { instance_double(Tooling::Mappings::PartialToViewsMappings, execute: views) }
before do
allow(Tooling::FindChanges).to receive(:new).and_return(find_changes)
allow(Tooling::FindFilesUsingFeatureFlags).to receive(:new).and_return(find_files_using_feature_flags)
allow(Tooling::Mappings::PartialToViewsMappings).to receive(:new).and_return(partial_to_views_mappings)
end
it "returns changes and related files by default" do
expect(Tooling::FindChanges).to receive(:new).with(from: :api, frontend_fixtures_mapping_pathname: nil).once
expect(Tooling::FindFilesUsingFeatureFlags).to receive(:new).with(changed_files: mr_changes).once
expect(Tooling::Mappings::PartialToViewsMappings).to receive(:new).with([*mr_changes, *ff_files]).once
it "returns feature flag and view related changes" do
expect(changed_files.fetch(changes: base_changes)).to match_array(base_changes + ff_files + views)
expect(changed_files.fetch).to match_array([*mr_changes, *ff_files, *views])
expect(Tooling::FindFilesUsingFeatureFlags).to have_received(:new).with(changed_files: base_changes).once
expect(Tooling::Mappings::PartialToViewsMappings).to have_received(:new).with(base_changes).once
end
it "skips feature flag related file fetching" do
expect(Tooling::FindChanges).to receive(:new).with(from: :api, frontend_fixtures_mapping_pathname: nil)
expect(Tooling::Mappings::PartialToViewsMappings).to receive(:new).with(mr_changes)
expect(Tooling::FindFilesUsingFeatureFlags).not_to receive(:new)
expect(changed_files.fetch(changes: base_changes, with_ff_related_files: false)).to match_array(
base_changes + views
)
expect(changed_files.fetch(with_ff_related_files: false)).to match_array([*mr_changes, *views])
expect(Tooling::Mappings::PartialToViewsMappings).to have_received(:new).with(base_changes)
expect(Tooling::FindFilesUsingFeatureFlags).not_to have_received(:new)
end
it "skips view file fetching" do
expect(Tooling::FindChanges).to receive(:new).with(from: :api, frontend_fixtures_mapping_pathname: nil)
expect(Tooling::FindFilesUsingFeatureFlags).to receive(:new).with(changed_files: mr_changes).once
expect(Tooling::Mappings::PartialToViewsMappings).not_to receive(:new)
expect(changed_files.fetch(changes: base_changes, with_views: false)).to match_array(
base_changes + ff_files
)
expect(changed_files.fetch(with_views: false)).to match_array([*mr_changes, *ff_files])
expect(Tooling::FindFilesUsingFeatureFlags).to have_received(:new).with(changed_files: base_changes).once
expect(Tooling::Mappings::PartialToViewsMappings).not_to have_received(:new)
end
context "with duplicate files" do
let(:ff_files) { ['app/models/user.rb'] }
it "returns only unique files" do
expect(changed_files.fetch).to match_array([*mr_changes, *views])
end
end
context "with frontend fixtures" do
it "uses frontend fixtures mapping file when provided" do
changed_files.fetch(frontend_fixtures_file: "path/to/frontend_fixtures_mapping.txt")
expect(Tooling::FindChanges).to have_received(:new).with(
from: :api,
frontend_fixtures_mapping_pathname: "path/to/frontend_fixtures_mapping.txt"
)
expect(changed_files.fetch(changes: base_changes)).to match_array(base_changes + views)
end
end
end

View File

@ -30,6 +30,10 @@ RSpec.describe Tooling::PredictiveTests::MetricsExporter, feature_category: :too
)
end
let(:find_changes) do
instance_double(Tooling::FindChanges, execute: ["base_changes"])
end
let(:test_selector_described) do
instance_double(Tooling::PredictiveTests::TestSelector, rspec_spec_list: matching_tests_described_class_specs)
end
@ -120,9 +124,13 @@ RSpec.describe Tooling::PredictiveTests::MetricsExporter, feature_category: :too
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::FindChanges).to receive(:new).with(
from: :api,
frontend_fixtures_mapping_pathname: frontend_fixtures_file
).and_return(find_changes)
allow(Tooling::PredictiveTests::MappingFetcher).to receive(:new).with(logger: logger).and_return(mapping_fetcher)
allow(Tooling::PredictiveTests::ChangedFiles).to receive(:fetch).with(
frontend_fixtures_file: frontend_fixtures_file
changes: ["base_changes"]
).and_return(changed_files)
allow(Tooling::PredictiveTests::TestSelector).to receive(:new).with(

View File

@ -103,8 +103,7 @@ RSpec.describe BulkImports::EntityWorker, feature_category: :importers do
.to receive(:perform_async)
.with(
Import::SOURCE_DIRECT_TRANSFER,
entity.bulk_import_id,
'current_user_id' => entity.bulk_import.user_id
entity.bulk_import_id
)
subject

View File

@ -50,8 +50,7 @@ RSpec.describe Gitlab::BitbucketServerImport::Stage::FinishImportWorker, feature
it 'queues LoadPlaceholderReferencesWorker' do
expect(Import::LoadPlaceholderReferencesWorker).to receive(:perform_async).with(
project.import_type,
project.import_state.id,
{ current_user_id: project.creator.id }
project.import_state.id
)
worker.perform(project.id)

View File

@ -24,8 +24,7 @@ RSpec.describe Gitlab::GithubImport::AdvanceStageWorker, feature_category: :impo
it 'enqueues LoadPlaceholderReferencesWorker to save placeholder references' do
expect(::Import::LoadPlaceholderReferencesWorker).to receive(:perform_async).with(
::Import::SOURCE_GITHUB,
project.import_state.id,
{ 'current_user_id' => project.creator_id }
project.import_state.id
)
worker.perform(project.id, { '123' => 2 }, 'finish')

View File

@ -6,10 +6,9 @@ RSpec.describe Import::LoadPlaceholderReferencesWorker, feature_category: :impor
let(:user) { create(:user) }
let(:import_source) { 'test_source' }
let(:uid) { 123 }
let(:params) { { 'current_user_id' => user.id } }
describe '#perform' do
subject(:perform) { described_class.new.perform(import_source, uid, params) }
subject(:perform) { described_class.new.perform(import_source, uid) }
it 'executes LoadService' do
expect_next_instance_of(Import::PlaceholderReferences::LoadService) do |service|
@ -20,7 +19,7 @@ RSpec.describe Import::LoadPlaceholderReferencesWorker, feature_category: :impor
end
it_behaves_like 'an idempotent worker' do
let(:job_args) { [import_source, uid, params] }
let(:job_args) { [import_source, uid] }
end
end

View File

@ -19,17 +19,20 @@ end
require 'fileutils'
require 'tmpdir'
require 'json'
require 'open3'
require_relative '../lib/tooling/predictive_tests/test_selector'
require_relative '../lib/tooling/predictive_tests/changed_files'
require_relative '../lib/tooling/predictive_tests/mapping_fetcher'
require_relative '../lib/tooling/find_changes'
class PredictiveTests # rubocop:disable Gitlab/NamespacedClass -- standalone non rails script
# rubocop:disable Gitlab/Json, Gitlab/NamespacedClass -- non rails
class PredictiveTests
def initialize(options)
@with_crystalball_mappings = options[:with_crystalball_mappings]
@mapping_type = options[:mapping_type] || :described_class
@with_frontend_fixture_mappings = options[:with_frontend_fixture_mappings]
@changed_files = options[:changed_files]
@changed_files = options[:changed_files]&.split(' ')
@changed_files_path = options[:changed_files_path]
@matching_foss_rspec_test_files_path = options[:matching_foss_rspec_test_files_path]
@matching_ee_rspec_test_files_path = options[:matching_ee_rspec_test_files_path]
@ -90,22 +93,19 @@ class PredictiveTests # rubocop:disable Gitlab/NamespacedClass -- standalone non
)
end
def changed_file_list
@changed_file_list ||= if @changed_files
@changed_files.split(" ")
else
Tooling::PredictiveTests::ChangedFiles.fetch(
frontend_fixtures_file: frontend_fixtures_mapping_file
)
end
def changed_files
@changed_files ||= @ci ? mr_diff : git_diff
end
def test_selector
@test_selector ||= Tooling::PredictiveTests::TestSelector.new(
changed_files: changed_file_list,
rspec_test_mapping_path: test_mapping_file,
logger: logger
)
@test_selector ||= begin
logger.info("Generating predictive test list based on changed files: #{JSON.pretty_generate(changed_files)}")
Tooling::PredictiveTests::TestSelector.new(
changed_files: changed_files,
rspec_test_mapping_path: test_mapping_file,
logger: logger
)
end
end
def rspec_spec_list
@ -116,10 +116,31 @@ class PredictiveTests # rubocop:disable Gitlab/NamespacedClass -- standalone non
@js_spec_list ||= test_selector.js_spec_list
end
# rubocop:disable Gitlab/Json -- non rails
def mr_diff
logger.debug('Fetching list of changes in gitlab merge request')
Tooling::FindChanges.new(
from: :api,
frontend_fixtures_mapping_pathname: frontend_fixtures_mapping_file
).execute
end
def git_diff
logger.debug('Fetching list of changes in local git repository')
out, status = Open3.capture2e('git rev-parse --abbrev-ref HEAD')
raise("Failed to fetch current branch name! Output: #{out}") unless status.success?
# get changes for the whole feature branch when not in master
cmd = out.strip != 'master' ? 'git diff --name-only master...HEAD' : 'git diff --name-only HEAD'
out, status = Open3.capture2e(cmd)
raise("Failed to fetch changed file list from git! Output: #{out}") unless status.success?
out.split("\n")
end
def create_output_files
# Used by frontend related pipelines/jobs
save_output(changed_file_list.join("\n"), @changed_files_path) if valid_file_path?(@changed_files_path)
save_output(changed_files.join("\n"), @changed_files_path) if valid_file_path?(@changed_files_path)
# Used by predictive rspec pipelines
if valid_file_path?(@matching_foss_rspec_test_files_path)
@ -138,7 +159,6 @@ class PredictiveTests # rubocop:disable Gitlab/NamespacedClass -- standalone non
save_output(js_spec_list.join(" "), @matching_jest_test_files_path)
end
# rubocop:enable Gitlab/Json
def save_output(output, file_path)
logger.debug("Writing #{file_path}")
@ -150,6 +170,7 @@ class PredictiveTests # rubocop:disable Gitlab/NamespacedClass -- standalone non
!(file_path.nil? || file_path.empty?)
end
end
# rubocop:enable Gitlab/Json, Gitlab/NamespacedClass
if __FILE__ == $PROGRAM_NAME
require 'optparse'
@ -208,5 +229,10 @@ if __FILE__ == $PROGRAM_NAME
end
end.parse!
PredictiveTests.new(options).execute
begin
PredictiveTests.new(options).execute
rescue StandardError => e
warn "[predictive tests] ERROR: #{e.message}"
exit 1
end
end

View File

@ -13,8 +13,9 @@ module Tooling
end
def execute
ff_union_regexp = Regexp.union(feature_flag_filenames)
return [] unless filter_files.any?
ff_union_regexp = Regexp.union(feature_flag_filenames)
ruby_files.select { |ruby_file| ruby_file if ff_union_regexp.match?(File.read(ruby_file)) }.uniq
end

View File

@ -1,6 +1,5 @@
# frozen_string_literal: true
require_relative '../find_changes'
require_relative '../find_files_using_feature_flags'
require_relative '../mappings/partial_to_views_mappings'
@ -8,21 +7,15 @@ module Tooling
module PredictiveTests
class ChangedFiles
class << self
def fetch(with_ff_related_files: true, with_views: true, frontend_fixtures_file: nil)
changes = []
changes.push(*mr_changes(frontend_fixtures_file))
changes.push(*feature_related_files(changes)) if with_ff_related_files
changes.push(*view_files(changes)) if with_views
def fetch(changes:, with_ff_related_files: true, with_views: true)
ff_related_files = with_ff_related_files ? feature_related_files(changes) : []
view_files = with_views ? view_files(changes) : []
changes.uniq
(changes + ff_related_files + view_files).uniq
end
private
def mr_changes(frontend_fixtures_file)
Tooling::FindChanges.new(from: :api, frontend_fixtures_mapping_pathname: frontend_fixtures_file).execute
end
def feature_related_files(changes)
Tooling::FindFilesUsingFeatureFlags.new(changed_files: changes).execute
end

View File

@ -6,6 +6,7 @@ require_relative "mapping_fetcher"
require_relative "../helpers/file_handler"
require_relative "../events/track_pipeline_events"
require_relative "../find_changes"
require "logger"
require "tmpdir"
@ -76,7 +77,12 @@ module Tooling
#
# @return [String]
def changed_files
@changed_files ||= ChangedFiles.fetch(frontend_fixtures_file: frontend_fixtures_mapping_file)
@changed_files ||= ChangedFiles.fetch(
changes: Tooling::FindChanges.new(
from: :api,
frontend_fixtures_mapping_pathname: frontend_fixtures_mapping_file
).execute
)
end
# Mapping file fetcher

View File

@ -33,7 +33,7 @@ module Tooling
def rspec_spec_list
logger.info "Creating predictive rspec test files specs list ..."
specs = {
crystalball_mapping_specs: specs_from_mapping,
test_file_finder_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

View File

@ -1425,7 +1425,7 @@
resolved "https://registry.yarnpkg.com/@gitlab/fonts/-/fonts-1.3.0.tgz#df89c1bb6714e4a8a5d3272568aa4de7fb337267"
integrity sha512-DoMUIN3DqjEn7wvcxBg/b7Ite5fTdF5EmuOZoBRo2j0UBGweDXmNBi+9HrTZs4cBU660dOxcf1hATFcG3npbPg==
"@gitlab/noop@^1.0.1", jackspeak@^3.1.2, "jackspeak@npm:@gitlab/noop@1.0.1":
"@gitlab/noop@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@gitlab/noop/-/noop-1.0.1.tgz#71a831146ee02732b4a61d2d3c11204564753454"
integrity sha512-s++4wjMYeDvBp9IO59DBrWjy8SE/gFkjTDO5ck2W0S6Vv7OlqgErwL7pHngAnrSmTJAzyUG8wHGqo0ViS4jn5Q==
@ -9495,6 +9495,11 @@ istanbul-reports@^3.1.3:
html-escaper "^2.0.0"
istanbul-lib-report "^3.0.0"
jackspeak@^3.1.2, "jackspeak@npm:@gitlab/noop@1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@gitlab/noop/-/noop-1.0.1.tgz#71a831146ee02732b4a61d2d3c11204564753454"
integrity sha512-s++4wjMYeDvBp9IO59DBrWjy8SE/gFkjTDO5ck2W0S6Vv7OlqgErwL7pHngAnrSmTJAzyUG8wHGqo0ViS4jn5Q==
jed@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/jed/-/jed-1.1.1.tgz#7a549bbd9ffe1585b0cd0a191e203055bee574b4"
@ -14244,9 +14249,9 @@ tapable@^2.2.0, tapable@^2.2.1:
integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==
tar-fs@^2.0.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.2.tgz#425f154f3404cb16cb8ff6e671d45ab2ed9596c5"
integrity sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA==
version "2.1.3"
resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.3.tgz#fb3b8843a26b6f13a08e606f7922875eb1fbbf92"
integrity sha512-090nwYJDmlhwFwEW3QQl+vaNnxsO2yVsd45eTKRBzSzu+hlb1w2K9inVq5b0ngXuLVqQ4ApvsUHHnu/zQNkWAg==
dependencies:
chownr "^1.1.1"
mkdirp-classic "^0.5.2"