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-01-18 22:00:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 22:00:14 +0300
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /tooling/danger
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'tooling/danger')
-rw-r--r--tooling/danger/config_files.rb2
-rw-r--r--tooling/danger/specs.rb31
-rw-r--r--tooling/danger/user_types.rb31
3 files changed, 23 insertions, 41 deletions
diff --git a/tooling/danger/config_files.rb b/tooling/danger/config_files.rb
index 436335bfc06..914605a3783 100644
--- a/tooling/danger/config_files.rb
+++ b/tooling/danger/config_files.rb
@@ -7,7 +7,7 @@ module Tooling
module ConfigFiles
SUGGEST_INTRODUCED_BY_COMMENT = <<~SUGGEST_COMMENT
```suggestion
- introduced_by_url: "%<url>s"
+ introduced_by_url: %<url>
```
SUGGEST_COMMENT
diff --git a/tooling/danger/specs.rb b/tooling/danger/specs.rb
index c7baf920314..6c0459a4344 100644
--- a/tooling/danger/specs.rb
+++ b/tooling/danger/specs.rb
@@ -45,12 +45,12 @@ module Tooling
for background information and alternative options.
SUGGEST_COMMENT
- FEATURE_CATEGORY_REGEX = /^\+.?RSpec\.describe(.+)(?!feature_category)/.freeze
+ RSPEC_TOP_LEVEL_DESCRIBE_REGEX = /^\+.?RSpec\.describe(.+)/.freeze
FEATURE_CATEGORY_SUGGESTION = <<~SUGGESTION_MARKDOWN
Consider adding `feature_category: <feature_category_name>` for this example if it is not set already.
See [testing best practices](https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#feature-category-metadata).
SUGGESTION_MARKDOWN
- FEATURE_CATEGORY_EXCLUDE = 'feature_category'
+ FEATURE_CATEGORY_KEYWORD = 'feature_category'
def changed_specs_files(ee: :include)
changed_files = helper.all_changed_files
@@ -86,13 +86,26 @@ module Tooling
end
def add_suggestions_for_feature_category(filename)
- add_suggestion(
- filename,
- FEATURE_CATEGORY_REGEX,
- FEATURE_CATEGORY_SUGGESTION,
- nil,
- FEATURE_CATEGORY_EXCLUDE
- )
+ file_lines = project_helper.file_lines(filename)
+ changed_lines = helper.changed_lines(filename)
+
+ changed_lines.each_with_index do |changed_line, i|
+ next unless changed_line =~ RSPEC_TOP_LEVEL_DESCRIBE_REGEX
+
+ next_line_in_file = file_lines[file_lines.find_index(changed_line.delete_prefix('+')) + 1]
+
+ if changed_line.include?(FEATURE_CATEGORY_KEYWORD) || next_line_in_file.to_s.include?(FEATURE_CATEGORY_KEYWORD)
+ next
+ end
+
+ line_number = file_lines.find_index(changed_line.delete_prefix('+'))
+ next unless line_number
+
+ suggested_line = file_lines[line_number]
+
+ text = format(comment(FEATURE_CATEGORY_SUGGESTION), suggested_line: suggested_line)
+ markdown(text, file: filename, line: line_number + 1)
+ end
end
private
diff --git a/tooling/danger/user_types.rb b/tooling/danger/user_types.rb
deleted file mode 100644
index 8320c43ae93..00000000000
--- a/tooling/danger/user_types.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-module Tooling
- module Danger
- module UserTypes
- FILE_PATH = "app/models/concerns/has_user_type.rb"
- BOT_USER_TYPES_CHANGE_INDICATOR_REGEX = %r{BOT_USER_TYPES}.freeze
- BOT_USER_TYPES_CHANGED_WARNING = <<~MSG
- You are changing BOT_USER_TYPES in `app/models/concerns/has_user_type.rb`.
- If you are adding or removing new bots, remember to update the `active_billable_users` index with the new value.
- If the bot is not billable, remember to make sure that it's not counted as a billable user.
- MSG
-
- def bot_user_types_change_warning
- return unless impacted?
-
- warn BOT_USER_TYPES_CHANGED_WARNING if bot_user_types_impacted?
- end
-
- private
-
- def impacted?
- helper.modified_files.include?(FILE_PATH)
- end
-
- def bot_user_types_impacted?
- helper.changed_lines(FILE_PATH).any? { |change| change =~ BOT_USER_TYPES_CHANGE_INDICATOR_REGEX }
- end
- end
- end
-end