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:
Diffstat (limited to 'qa/qa/tools/ci/qa_changes.rb')
-rw-r--r--qa/qa/tools/ci/qa_changes.rb51
1 files changed, 46 insertions, 5 deletions
diff --git a/qa/qa/tools/ci/qa_changes.rb b/qa/qa/tools/ci/qa_changes.rb
index 75274961efe..784923714d6 100644
--- a/qa/qa/tools/ci/qa_changes.rb
+++ b/qa/qa/tools/ci/qa_changes.rb
@@ -11,17 +11,25 @@ module QA
QA_PATTERN = %r{^qa/}.freeze
SPEC_PATTERN = %r{^qa/qa/specs/features/}.freeze
-
- def initialize(mr_diff, mr_labels)
+ DEPENDENCY_PATTERN = Regexp.union(
+ /_VERSION/,
+ /Gemfile\.lock/,
+ /yarn\.lock/,
+ /Dockerfile\.assets/
+ )
+
+ def initialize(mr_diff, mr_labels, additional_group_spec_list)
@mr_diff = mr_diff
@mr_labels = mr_labels
+ @additional_group_spec_list = additional_group_spec_list
end
# Specific specs to run
#
# @return [String]
def qa_tests
- return if mr_diff.empty?
+ return if mr_diff.empty? || dependency_changes
+
# make paths relative to qa directory
return changed_files&.map { |path| path.delete_prefix("qa/") }&.join(" ") if only_spec_changes?
return qa_spec_directories_for_devops_stage&.join(" ") if non_qa_changes? && mr_labels.any?
@@ -73,6 +81,9 @@ module QA
# @return [Array]
attr_reader :mr_labels
+ # @return [Hash<String, Array<String>>]
+ attr_reader :additional_group_spec_list
+
# Are the changed files only qa specs?
#
# @return [Boolean] whether the changes files are only qa specs
@@ -94,6 +105,13 @@ module QA
mr_labels.find { |label| label =~ /^devops::/ }&.delete_prefix('devops::')
end
+ # Extract group name from MR labels
+ #
+ # @return [String] a group name
+ def group_name_from_mr_labels
+ mr_labels.find { |label| label =~ /^group::/ }&.delete_prefix('group::')
+ end
+
# Get qa spec directories for devops stage
#
# @return [Array] qa spec directories
@@ -101,14 +119,37 @@ module QA
devops_stage = devops_stage_from_mr_labels
return unless devops_stage
- Dir.glob("qa/specs/**/*/").select { |dir| dir =~ %r{\d+_#{devops_stage}/$} }
+ spec_dirs = stage_specs(devops_stage)
+
+ grp_name = group_name_from_mr_labels
+ return spec_dirs if grp_name.nil?
+
+ additional_grp_specs = additional_group_spec_list[grp_name]
+ return spec_dirs if additional_grp_specs.nil?
+
+ spec_dirs + stage_specs(*additional_grp_specs)
+ end
+
+ # Changes to gitlab dependencies
+ #
+ # @return [Boolean]
+ def dependency_changes
+ changed_files.any? { |file| file.match?(DEPENDENCY_PATTERN) }
end
# Change files in merge request
#
# @return [Array<String>]
def changed_files
- @changed_files ||= mr_diff.map { |change| change[:path] } # rubocop:disable Rails/Pluck
+ @changed_files ||= mr_diff.map { |change| change[:path] }
+ end
+
+ # Devops stage specs
+ #
+ # @param [Array<String>] devops_stages
+ # @return [Array]
+ def stage_specs(*devops_stages)
+ Dir.glob("qa/specs/**/*/").select { |dir| dir =~ %r{\d+_(#{devops_stages.join('|')})/$} }
end
end
end