Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-25 00:18:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-25 00:18:05 +0300
commit3d911c6c1f34df47036f1d7e0838e4d5876ee923 (patch)
tree492dfc9e4a3d3ea6d4749f35a78abafe634889f6 /tooling
parent0bf82aa5cb3b1ed826dd5c0d46331e17aa60d9e9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'tooling')
-rwxr-xr-xtooling/lib/tooling/find_changes.rb4
-rw-r--r--tooling/lib/tooling/find_files_using_feature_flags.rb48
-rw-r--r--tooling/lib/tooling/find_tests.rb4
-rw-r--r--tooling/lib/tooling/helpers/predictive_tests_helper.rb (renamed from tooling/lib/tooling/mappings/base.rb)6
-rw-r--r--tooling/lib/tooling/mappings/graphql_base_type_mappings.rb6
-rw-r--r--tooling/lib/tooling/mappings/js_to_system_specs_mappings.rb6
-rw-r--r--tooling/lib/tooling/mappings/partial_to_views_mappings.rb6
-rw-r--r--tooling/lib/tooling/mappings/view_to_js_mappings.rb6
-rw-r--r--tooling/lib/tooling/mappings/view_to_system_specs_mappings.rb6
-rw-r--r--tooling/lib/tooling/predictive_tests.rb2
10 files changed, 77 insertions, 17 deletions
diff --git a/tooling/lib/tooling/find_changes.rb b/tooling/lib/tooling/find_changes.rb
index d8373d11245..25381e1a894 100755
--- a/tooling/lib/tooling/find_changes.rb
+++ b/tooling/lib/tooling/find_changes.rb
@@ -2,11 +2,11 @@
# frozen_string_literal: true
require 'gitlab'
-require_relative 'helpers/file_handler'
+require_relative 'helpers/predictive_tests_helper'
module Tooling
class FindChanges
- include Helpers::FileHandler
+ include Helpers::PredictiveTestsHelper
def initialize(
from:,
diff --git a/tooling/lib/tooling/find_files_using_feature_flags.rb b/tooling/lib/tooling/find_files_using_feature_flags.rb
new file mode 100644
index 00000000000..27cace60408
--- /dev/null
+++ b/tooling/lib/tooling/find_files_using_feature_flags.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+require 'test_file_finder'
+require_relative 'helpers/predictive_tests_helper'
+
+module Tooling
+ class FindFilesUsingFeatureFlags
+ include Helpers::PredictiveTestsHelper
+
+ def initialize(changed_files_pathname:, feature_flags_base_folder: 'config/feature_flags')
+ @changed_files_pathname = changed_files_pathname
+ @changed_files = read_array_from_file(changed_files_pathname)
+ @feature_flags_base_folders = folders_for_available_editions(feature_flags_base_folder)
+ end
+
+ def execute
+ ff_union_regexp = Regexp.union(feature_flag_filenames)
+
+ files_using_modified_feature_flags = ruby_files.select do |ruby_file|
+ ruby_file if ff_union_regexp.match?(File.read(ruby_file))
+ end
+
+ write_array_to_file(changed_files_pathname, files_using_modified_feature_flags.uniq)
+ end
+
+ def filter_files
+ @_filter_files ||= changed_files.select do |filename|
+ filename.start_with?(*feature_flags_base_folders) &&
+ File.basename(filename).end_with?('.yml') &&
+ File.exist?(filename)
+ end
+ end
+
+ private
+
+ def feature_flag_filenames
+ filter_files.map do |feature_flag_pathname|
+ File.basename(feature_flag_pathname).delete_suffix('.yml')
+ end
+ end
+
+ def ruby_files
+ Dir["**/*.rb"].reject { |pathname| pathname.start_with?('vendor') }
+ end
+
+ attr_reader :changed_files, :changed_files_pathname, :feature_flags_base_folders
+ end
+end
diff --git a/tooling/lib/tooling/find_tests.rb b/tooling/lib/tooling/find_tests.rb
index f26c1eacdc7..bf7a608878b 100644
--- a/tooling/lib/tooling/find_tests.rb
+++ b/tooling/lib/tooling/find_tests.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
require 'test_file_finder'
-require_relative 'helpers/file_handler'
+require_relative 'helpers/predictive_tests_helper'
module Tooling
class FindTests
- include Helpers::FileHandler
+ include Helpers::PredictiveTestsHelper
def initialize(changed_files_pathname, predictive_tests_pathname)
@predictive_tests_pathname = predictive_tests_pathname
diff --git a/tooling/lib/tooling/mappings/base.rb b/tooling/lib/tooling/helpers/predictive_tests_helper.rb
index 27a9a0925b0..b8e5a30024e 100644
--- a/tooling/lib/tooling/mappings/base.rb
+++ b/tooling/lib/tooling/helpers/predictive_tests_helper.rb
@@ -5,9 +5,9 @@ require_relative '../helpers/file_handler'
# Returns system specs files that are related to the JS files that were changed in the MR.
module Tooling
- module Mappings
- class Base
- include Helpers::FileHandler
+ module Helpers
+ module PredictiveTestsHelper
+ include FileHandler
# Input: A folder
# Output: An array of folders, each prefixed with a GitLab edition
diff --git a/tooling/lib/tooling/mappings/graphql_base_type_mappings.rb b/tooling/lib/tooling/mappings/graphql_base_type_mappings.rb
index 569a8278163..80aa99efc96 100644
--- a/tooling/lib/tooling/mappings/graphql_base_type_mappings.rb
+++ b/tooling/lib/tooling/mappings/graphql_base_type_mappings.rb
@@ -2,13 +2,15 @@
require 'active_support/inflector'
-require_relative 'base'
+require_relative '../helpers/predictive_tests_helper'
require_relative '../../../../lib/gitlab_edition'
# If a GraphQL type class changed, we try to identify the other GraphQL types that potentially include this type.
module Tooling
module Mappings
- class GraphqlBaseTypeMappings < Base
+ class GraphqlBaseTypeMappings
+ include Helpers::PredictiveTestsHelper
+
# Checks for the implements keyword, and graphql_base_types the class name
GRAPHQL_IMPLEMENTS_REGEXP = /implements[( ]([\w:]+)[)]?$/
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 b2fca3a765a..bc2cd259fdc 100644
--- a/tooling/lib/tooling/mappings/js_to_system_specs_mappings.rb
+++ b/tooling/lib/tooling/mappings/js_to_system_specs_mappings.rb
@@ -2,13 +2,15 @@
require 'active_support/inflector'
-require_relative 'base'
+require_relative '../helpers/predictive_tests_helper'
require_relative '../../../../lib/gitlab_edition'
# Returns system specs files that are related to the JS files that were changed in the MR.
module Tooling
module Mappings
- class JsToSystemSpecsMappings < Base
+ class JsToSystemSpecsMappings
+ include Helpers::PredictiveTestsHelper
+
def initialize(
changed_files_pathname, predictive_tests_pathname,
js_base_folder: 'app/assets/javascripts', system_specs_base_folder: 'spec/features')
diff --git a/tooling/lib/tooling/mappings/partial_to_views_mappings.rb b/tooling/lib/tooling/mappings/partial_to_views_mappings.rb
index 8b0a5ed4ecd..931cacea77f 100644
--- a/tooling/lib/tooling/mappings/partial_to_views_mappings.rb
+++ b/tooling/lib/tooling/mappings/partial_to_views_mappings.rb
@@ -1,12 +1,14 @@
# frozen_string_literal: true
-require_relative 'base'
+require_relative '../helpers/predictive_tests_helper'
require_relative '../../../../lib/gitlab_edition'
# Returns view files that include the potential rails partials from the changed files passed as input.
module Tooling
module Mappings
- class PartialToViewsMappings < Base
+ class PartialToViewsMappings
+ include Helpers::PredictiveTestsHelper
+
def initialize(changed_files_pathname, views_with_partials_pathname, view_base_folder: 'app/views')
@views_with_partials_pathname = views_with_partials_pathname
@changed_files = read_array_from_file(changed_files_pathname)
diff --git a/tooling/lib/tooling/mappings/view_to_js_mappings.rb b/tooling/lib/tooling/mappings/view_to_js_mappings.rb
index f2098d6acd5..b78c354f9d2 100644
--- a/tooling/lib/tooling/mappings/view_to_js_mappings.rb
+++ b/tooling/lib/tooling/mappings/view_to_js_mappings.rb
@@ -1,12 +1,14 @@
# frozen_string_literal: true
-require_relative 'base'
+require_relative '../helpers/predictive_tests_helper'
require_relative '../../../../lib/gitlab_edition'
# Returns JS files that are related to the Rails views files that were changed in the MR.
module Tooling
module Mappings
- class ViewToJsMappings < Base
+ class ViewToJsMappings
+ include Helpers::PredictiveTestsHelper
+
# The HTML attribute value pattern we're looking for to match an HTML file to a JS file.
HTML_ATTRIBUTE_VALUE_REGEXP = /js-[-\w]+/.freeze
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 6d840dcbd71..1542c817745 100644
--- a/tooling/lib/tooling/mappings/view_to_system_specs_mappings.rb
+++ b/tooling/lib/tooling/mappings/view_to_system_specs_mappings.rb
@@ -1,12 +1,14 @@
# frozen_string_literal: true
-require_relative 'base'
+require_relative '../helpers/predictive_tests_helper'
require_relative '../../../../lib/gitlab_edition'
# Returns system specs files that are related to the Rails views files that were changed in the MR.
module Tooling
module Mappings
- class ViewToSystemSpecsMappings < Base
+ class ViewToSystemSpecsMappings
+ include Helpers::PredictiveTestsHelper
+
def initialize(changed_files_pathname, predictive_tests_pathname, view_base_folder: 'app/views')
@predictive_tests_pathname = predictive_tests_pathname
@changed_files = read_array_from_file(changed_files_pathname)
diff --git a/tooling/lib/tooling/predictive_tests.rb b/tooling/lib/tooling/predictive_tests.rb
index 503426b5520..1ad63e111e3 100644
--- a/tooling/lib/tooling/predictive_tests.rb
+++ b/tooling/lib/tooling/predictive_tests.rb
@@ -2,6 +2,7 @@
require_relative 'find_changes'
require_relative 'find_tests'
+require_relative 'find_files_using_feature_flags'
require_relative 'mappings/graphql_base_type_mappings'
require_relative 'mappings/js_to_system_specs_mappings'
require_relative 'mappings/partial_to_views_mappings'
@@ -36,6 +37,7 @@ module Tooling
from: :api,
changed_files_pathname: rspec_changed_files_path
).execute
+ Tooling::FindFilesUsingFeatureFlags.new(changed_files_pathname: rspec_changed_files_path).execute
Tooling::FindTests.new(rspec_changed_files_path, rspec_matching_tests_path).execute
Tooling::Mappings::PartialToViewsMappings.new(
rspec_changed_files_path, rspec_views_including_partials_path).execute