gitlab-dangerfiles 4.8.1 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b42206a72b735d7a0016622666b37571d85d541a758d5454fbca3260e359f1f2
4
- data.tar.gz: ac570434fc3dee200d7656a557668454e2ceb5719c43d49b80c364688d3d0e13
3
+ metadata.gz: dc6047699d31bc320127f651d567ddf984b6189eeeb7646eb4f0d46b4185e9fd
4
+ data.tar.gz: 655da17704203a02f6f138b8493bb8cf2002c2121d1015a63da0677ebf23b48d
5
5
  SHA512:
6
- metadata.gz: '030678a153058f6c0ab3fdb198d109ca43b8693f763a6259585b2864c7d688faec108dbbe93285226a7b926ab6f99423b6b57d703f83004b588df27917582d22'
7
- data.tar.gz: 7a3398d6bc48bdbd28a43329c311088c211b6343e00200a782b0eef9503dae39befeaaa139710847d3a674e1032508b8c938ef889f7907d9739548919fa12c97
6
+ metadata.gz: 02613c71246a09f46d15e0117e3f304ae626618c5736ff9b02f5e15bfbeccaa4921cefa694c97548dc5af2f4611866b58eb29f9eb5e0305d7412461097980a2c
7
+ data.tar.gz: 6703f6fe3502ad2336c33a4296a67d3e7d77d0dd9e46db97f510f0bd4c17a729f1bb20afcbb4ab6a0d5b24da477e4e50378e76cb943b9fc474fbed29320e619b
@@ -2,7 +2,7 @@
2
2
  commit from this merge request, and `<NEW_VERSION>` with the upcoming version number. -->
3
3
  ## Diff
4
4
 
5
- https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/compare/v<PREVIOUS_VERSION>...<COMMIT_UPDATING_VERSION>
5
+ https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/compare/<PREVIOUS_VERSION>...<COMMIT_UPDATING_VERSION>
6
6
 
7
7
  ## Checklist
8
8
 
data/.gitlab-ci.yml CHANGED
@@ -23,7 +23,7 @@ default:
23
23
  - vendor/ruby
24
24
 
25
25
  .default-test-job:
26
- image: "ruby:${RUBY_VERSION}"
26
+ image: "${GITLAB_DEPENDENCY_PROXY}ruby:${RUBY_VERSION}"
27
27
  stage: test
28
28
  needs: []
29
29
  before_script:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-dangerfiles (4.8.1)
4
+ gitlab-dangerfiles (4.10.0)
5
5
  danger (>= 9.3.0)
6
6
  danger-gitlab (>= 8.0.0)
7
7
  rake (~> 13.0)
@@ -117,6 +117,7 @@ GEM
117
117
  parallel (1.22.1)
118
118
  parser (3.2.1.0)
119
119
  ast (~> 2.4.1)
120
+ racc
120
121
  proc_to_ast (0.1.0)
121
122
  coderay
122
123
  parser
@@ -125,6 +126,7 @@ GEM
125
126
  coderay (~> 1.1)
126
127
  method_source (~> 1.0)
127
128
  public_suffix (5.0.1)
129
+ racc (1.8.1)
128
130
  rack (3.0.4.1)
129
131
  rainbow (3.1.1)
130
132
  rake (13.0.6)
@@ -220,6 +222,7 @@ DEPENDENCIES
220
222
  gitlab-styles (~> 10.0)
221
223
  guard-rspec (~> 4.7.3)
222
224
  lefthook (~> 1.3)
225
+ racc (~> 1.8)
223
226
  rspec (~> 3.8)
224
227
  rspec-parameterized
225
228
  rubocop-rails (< 2.21.2)
data/README.md CHANGED
@@ -171,6 +171,15 @@ This rule ensures the merge request isn't too big to be reviewed, otherwise it s
171
171
 
172
172
  This rule posts a failure if the merge request has more than 20 commits.
173
173
 
174
+ #### `danger_code_review`
175
+
176
+ This rule posts a warning/failure when `@GitLabDuo` isn't assigned as a reviewer.
177
+
178
+ ##### Available configurations
179
+
180
+ - `duo_code_review`: Whether a review from GitLab Duo Code is `:mandatory` or `:optional`.
181
+ Default to `:optional`.
182
+
174
183
  #### `metadata`
175
184
 
176
185
  This rule ensures basic metadata such as assignee, milestone and description are set on the merge request.
@@ -193,6 +202,38 @@ project. To use it in your project, perform the following steps:
193
202
  dangerfiles.import_dangerfiles(only: %w[simple_roulette])
194
203
  end
195
204
  ```
205
+
206
+ ##### Auto-assignment
207
+
208
+ By default, the simple roulette only suggests reviewers in a comment. You can, optionally, configure it to automatically assign reviewers from the roulette to your merge requests.
209
+
210
+ Configure `auto_assign_for_roulette_roles` to specify which roles to assign (`:reviewer`, `:maintainer`, or both). If empty (default), no auto-assignment occurs.
211
+
212
+ Optionally, configure `auto_assign_for_roulette_labels` to only auto-assign for Merge Requests with specific labels. If empty (default), auto-assignment applies to all MRs.
213
+
214
+ ###### Examples
215
+
216
+ ``` ruby
217
+ # Auto-assign reviewers for all MRs
218
+ helper.config.auto_assign_for_roulette_roles = [:reviewer]
219
+
220
+ # Auto-assign both reviewer and maintainer for all MRs
221
+ helper.config.auto_assign_for_roulette_roles = [:reviewer, :maintainer]
222
+
223
+ # Auto-assign reviewers only for a specific MR label
224
+ helper.config.auto_assign_for_roulette_roles = [:reviewer]
225
+ helper.config.auto_assign_for_roulette_labels = ["maintenance::dependency"]
226
+ ```
227
+
228
+ ##### Available configurations
229
+
230
+ Note: These options aren't actually used in the `simple_roulette` rule, but can be used in your own
231
+ implementation of the roulette if you use `roulette.required_approvals`/`roulette.codeowners_approvals`.
232
+
233
+ - `included_optional_codeowners_sections_for_roulette`: Indicates which optional codeowners sections
234
+ should be included in roulette. Default to `[]`.
235
+ - `excluded_required_codeowners_sections_for_roulette`: Indicates which required codeowners sections
236
+ should be excluded from roulette. Default to `[]`.
196
237
 
197
238
  #### `type_label`
198
239
 
@@ -281,6 +322,16 @@ To run the Danger Rake task in a project that doesn't have `master` as the defau
281
322
  DANGER_LOCAL_BASE="origin/main" bundle exec rake danger_local
282
323
  ```
283
324
 
325
+ ## Warnings vs Errors
326
+
327
+ The following lint violations generate warnings:
328
+
329
+ 1. The commit subject is too short ([code](https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/blob/bccb167/lib/gitlab/dangerfiles/base_linter.rb#L74-76)).
330
+ 1. The commit changes too many lines across too many files without describing the changes in the commit body ([code](https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/blob/bccb167/lib/gitlab/dangerfiles/commit_linter.rb#L83-85)).
331
+ 1. The commit body contains too many characters per line ([code](https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/blob/bccb167/lib/gitlab/dangerfiles/commit_linter.rb#L87-96)).
332
+
333
+ All other lint violations generate errors, except when the MR has [Squash commits when merge request is accepted](https://docs.gitlab.com/ee/user/project/merge_requests/squash_and_merge.html#squash-commits-in-a-merge-request) enabled, which downgrades lint violations to warnings.
334
+
284
335
  ## Documentation
285
336
 
286
337
  Latest documentation can be found at <https://www.rubydoc.info/gems/gitlab-dangerfiles>.
@@ -307,8 +358,8 @@ For example, to test `gitlab-dangerfiles` changes from the `your-branch-name` br
307
358
 
308
359
  ```ruby
309
360
  group :development, :test, :danger do
310
- gem 'gitlab-dangerfiles', '~> 3.4.3', require: false,
311
- git: 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles.git',
361
+ gem 'gitlab-dangerfiles', require: false, feature_category: :tooling,
362
+ git: 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles.git', # rubocop:disable Cop/GemFetcher -- Testing unreleased changes
312
363
  ref: 'your-branch-name'
313
364
  end
314
365
  ```
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency "lefthook", "~> 1.3"
38
38
  spec.add_development_dependency "rspec-parameterized"
39
39
  spec.add_development_dependency "rspec", "~> 3.8"
40
+ spec.add_development_dependency "racc", "~> 1.8"
40
41
  # we do not commit the bundle lockfile, so this temporary workaround needs to be
41
42
  # present until 2.21.3 or 2.22.x is released
42
43
  # See https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/issues/63
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Danger
4
+ # Contains method to check if Duo code suggestion added to MR as a reviewer.
5
+ class DuoCode < Danger::Plugin
6
+ def suggestion_added?
7
+ return false unless helper.ci?
8
+
9
+ helper.mr_reviewers.include?("GitLabDuo")
10
+ end
11
+ end
12
+ end
@@ -30,7 +30,11 @@ module Danger
30
30
  Authentication: '~"group::authentication"',
31
31
  Authorization: '~"group::authorization"',
32
32
  Compliance: '~"group::compliance"',
33
- Verify: '~"devops::verify"'
33
+ Verify: '~"devops::verify"',
34
+ "AST:Composition Analysis": '~"group::composition analysis"',
35
+ "AST:Dynamic Analysis": '~"group::dynamic analysis"',
36
+ "AST:Secret Detection": '~"group::secret detection"',
37
+ "AST:Static Analysis": '~"group::static analysis"'
34
38
  }.freeze
35
39
  # rubocop:enable Style/HashSyntax
36
40
 
@@ -181,7 +185,9 @@ module Danger
181
185
  # @return [{Symbol => Array<String>}] a hash of the type +{ category1: ["file1", "file2"], category2: ["file3", "file4"] }+
182
186
  # using filename regex (+filename_regex+) and specific change regex (+changes_regex+) from the given +categories+ hash.
183
187
  def changes_by_category(categories = [])
184
- all_changed_files.each_with_object(Hash.new { |h, k| h[k] = [] }) do |file, hash|
188
+ changed_and_deleted_files = all_changed_files + changes.deleted.files
189
+
190
+ changed_and_deleted_files.each_with_object(Hash.new { |h, k| h[k] = [] }) do |file, hash|
185
191
  categories_for_file(file, categories).each { |category| hash[category] << file }
186
192
  end
187
193
  end
@@ -244,7 +250,7 @@ module Danger
244
250
  # @return [String] the GFM for a category label, making its best guess if it's not
245
251
  # a category we know about.
246
252
  def label_for_category(category)
247
- CATEGORY_LABELS[category] ||
253
+ helper.config.custom_labels_for_categories[category] || CATEGORY_LABELS[category] ||
248
254
 
249
255
  if category.start_with?("`")
250
256
  category.to_s
@@ -288,6 +294,13 @@ module Danger
288
294
  gitlab_helper.mr_json["assignees"]
289
295
  end
290
296
 
297
+ # @return [Array<Hash>] +[]+ when not in the CI context, and the MR reviewers otherwise.
298
+ def mr_reviewers
299
+ return [] unless ci?
300
+
301
+ gitlab_helper.mr_json["reviewers"]
302
+ end
303
+
291
304
  # @return [String] +""+ when not in the CI context, and the MR title otherwise.
292
305
  def mr_title
293
306
  return "" unless ci?
@@ -45,7 +45,7 @@ module Danger
45
45
  # @param categories [Array<Symbol>] An array of categories symbols.
46
46
  #
47
47
  # @return [Array<Spin>]
48
- def spin(project = nil, categories = [:none], ux_fallback_wider_community_reviewer: teammate_pedroms)
48
+ def spin(project = nil, categories = [:none], ux_fallback_wider_community_reviewer: ux_fallback_reviewer)
49
49
  # TODO: Deprecate the project argument. It prevents us from
50
50
  # memorizing Spinner and can cause unexpected results if it's
51
51
  # passing a different project than the merge request project.
@@ -87,10 +87,40 @@ module Danger
87
87
  Gitlab::Dangerfiles::Teammate.warnings
88
88
  end
89
89
 
90
+ # Automatically assigns reviewers from roulette spins if configured to do so
91
+ #
92
+ # @param spins [Array<Spin>] The roulette spins to potentially assign from
93
+ def assign_reviewers_from_roulette(spins)
94
+ return if helper.mr_reviewers.any?
95
+
96
+ reviewers_to_assign = find_reviewers_to_assign(spins)
97
+
98
+ if reviewers_to_assign.any?
99
+ post_assignment_message(reviewers_to_assign)
100
+ else
101
+ warn("No reviewers available for assignment")
102
+ end
103
+ end
104
+
105
+ # Determines if auto-assignment should happen based on configuration
106
+ #
107
+ # @return [Boolean]
108
+ def auto_assign_reviewers?
109
+ return false if helper.config.auto_assign_for_roulette_roles.empty?
110
+
111
+ configured_labels = helper.config.auto_assign_for_roulette_labels
112
+
113
+ return true if configured_labels.empty?
114
+
115
+ mr_labels = helper.mr_labels
116
+ configured_labels.any? { |label| mr_labels.include?(label) }
117
+ end
118
+
90
119
  private
91
120
 
92
- def teammate_pedroms
93
- @teammate_pedroms ||= Gitlab::Dangerfiles::Teammate.find_member("pedroms")
121
+ def ux_fallback_reviewer
122
+ teammates = %w[pedroms annabeldunstone seggenberger jmiocene clavimoniere]
123
+ Gitlab::Dangerfiles::Teammate.find_member(teammates.sample)
94
124
  end
95
125
 
96
126
  def spin_for_approval_rule?(rule)
@@ -157,5 +187,41 @@ module Danger
157
187
  def labels
158
188
  @labels ||= helper.mr_labels
159
189
  end
190
+
191
+ # Find reviewers to assign based on configured roles
192
+ #
193
+ # @param spins [Array<Spin>] The roulette spins
194
+ # @return [Array<String>] Array of usernames to assign
195
+ def find_reviewers_to_assign(spins)
196
+ roles_to_assign = helper.config.auto_assign_for_roulette_roles
197
+ reviewers_to_assign = []
198
+
199
+ spins.each do |spin|
200
+ if roles_to_assign.include?(:reviewer) && spin.reviewer&.username
201
+ reviewers_to_assign << spin.reviewer.username
202
+ end
203
+
204
+ if roles_to_assign.include?(:maintainer) && spin.maintainer&.username
205
+ reviewers_to_assign << spin.maintainer.username
206
+ end
207
+
208
+ if reviewers_to_assign.any?
209
+ break
210
+ end
211
+ end
212
+
213
+ reviewers_to_assign
214
+ end
215
+
216
+ # Posts the assignment message with the selected reviewers
217
+ #
218
+ # @param reviewers_to_assign [Array<String>] Array of usernames to assign
219
+ def post_assignment_message(reviewers_to_assign)
220
+ role_text = helper.config.auto_assign_for_roulette_roles.map(&:to_s).join(' and ')
221
+ message = "🎲 Assigned #{role_text}s based on reviewer roulette.\n/assign_reviewer #{reviewers_to_assign.map { |u| "@#{u}" }.join(' ')}"
222
+ markdown(message)
223
+ rescue StandardError => e
224
+ warn("Failed to assign reviewers: #{e.message}")
225
+ end
160
226
  end
161
227
  end
@@ -113,7 +113,7 @@ def warn_or_fail_commits(failed_linters, default_to_fail: true)
113
113
  Array(failed_linters).each do |linter|
114
114
  linter.problems.each do |problem_key, problem_desc|
115
115
  case problem_key
116
- when :subject_too_short, :subject_above_warning, :details_too_many_changes, :details_line_too_long
116
+ when :subject_too_short, :details_too_many_changes, :details_line_too_long
117
117
  warn_commit(linter.commit, problem_desc)
118
118
  else
119
119
  self.__send__(:"#{level}_commit", linter.commit, problem_desc)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ return if duo_code.suggestion_added?
4
+
5
+ case helper.config.duo_code_review
6
+ when :optional
7
+ markdown("We advise getting a review from GitLab Duo Code. You can assign `@GitLabDuo` as a reviewer to this merge request.")
8
+ when :mandatory
9
+ failure("A review from GitLab Duo Code is mandatory. Please assign `@GitLabDuo` as a reviewer to this merge request.")
10
+ end
@@ -8,9 +8,6 @@ MESSAGE = <<MARKDOWN
8
8
  Changes that require review have been detected! A merge request is normally
9
9
  reviewed by both a reviewer and a maintainer in its primary category and by a
10
10
  maintainer in all other categories.
11
- MARKDOWN
12
-
13
- TABLE_MARKDOWN = <<MARKDOWN
14
11
 
15
12
  To spread load more evenly across eligible reviewers, Danger has picked a candidate for each
16
13
  review slot. Feel free to
@@ -26,9 +23,11 @@ Please consider assigning a reviewer or maintainer who is a
26
23
  [domain expert](https://about.gitlab.com/handbook/engineering/projects/##{PROJECT_NAME})
27
24
  in the area of the merge request.
28
25
 
26
+ MARKDOWN
27
+
28
+ NO_AUTO_ASSIGN = <<MARKDOWN
29
29
  Once you've decided who will review this merge request, mention them as you
30
30
  normally would! Danger does not automatically notify them for you.
31
-
32
31
  MARKDOWN
33
32
 
34
33
  TABLE_HEADER_WITH_CATEGORIES = <<MARKDOWN
@@ -101,5 +100,11 @@ if changes.any?
101
100
 
102
101
  markdown(format(WARNING_MESSAGE, warnings: warnings)) if warnings
103
102
 
104
- markdown(TABLE_MARKDOWN + table_header + rows.join("\n")) unless rows.empty?
103
+ markdown(table_header + rows.join("\n")) unless rows.empty?
104
+
105
+ if roulette.auto_assign_reviewers?
106
+ roulette.assign_reviewers_from_roulette(random_roulette_spins)
107
+ else
108
+ markdown(NO_AUTO_ASSIGN)
109
+ end
105
110
  end
@@ -62,15 +62,13 @@ module Gitlab
62
62
 
63
63
  class ImportIntegrateBE < Capability
64
64
  def has_capability?(teammate)
65
- kind == :reviewer &&
66
- teammate.role.match?(/Backend Engineer.+Manage:Import and Integrate/)
65
+ kind == :reviewer && teammate.role.match?(/Backend Engineer.+:Import and Integrate/)
67
66
  end
68
67
  end
69
68
 
70
69
  class ImportIntegrateFE < Capability
71
70
  def has_capability?(teammate)
72
- kind == :reviewer &&
73
- teammate.role.match?(/Frontend Engineer.+Manage:Import and Integrate/)
71
+ kind == :reviewer && teammate.role.match?(/Frontend Engineer.+:Import and Integrate/)
74
72
  end
75
73
  end
76
74
 
@@ -21,31 +21,54 @@ module Gitlab
21
21
  # match changed lines in files that match +filename_regex+. Used in `helper.changes_by_category`, `helper.changes`, and `helper.categories_for_file`.
22
22
  attr_accessor :files_to_category
23
23
 
24
+ # @!attribute custom_labels_for_categories
25
+ # @return [{String => String}] A hash of the form +{ category_name => label }+.
26
+ # Used in `helper.custom_labels_for_categories`.
27
+ attr_accessor :custom_labels_for_categories
28
+
29
+ # @!attribute disabled_roulette_categories
30
+ # @return [Array] indicating which categories would be disabled for the simple roulette. Default to `[]` (all categories are enabled)
31
+ attr_accessor :disabled_roulette_categories
32
+
33
+ # Rule: changes_size
24
34
  # @!attribute code_size_thresholds
25
35
  # @return [{ high: Integer, medium: Integer }] a hash of the form +{ high: 42, medium: 12 }+ where +:high+ is the lines changed threshold which triggers an error, and +:medium+ is the lines changed threshold which triggers a warning. Also, see +DEFAULT_CHANGES_SIZE_THRESHOLDS+ for the format of the hash.
26
36
  attr_accessor :code_size_thresholds
27
37
 
38
+ # Rule: commit_messages
28
39
  # @!attribute max_commits_count
29
40
  # @return [Integer] the maximum number of allowed non-squashed/non-fixup commits for a given MR. A warning is triggered if the MR has more commits.
30
41
  attr_accessor :max_commits_count
31
42
 
32
- # @!attribute disabled_roulette_categories
33
- # @return [Array] indicating which categories would be disabled for the simple roulette. Default to `[]` (all categories are enabled)
34
- attr_accessor :disabled_roulette_categories
43
+ # Rule: duo_code_review
44
+ # @!attribute duo_code_review
45
+ # @return [Symbol] whether a review from GitLab Duo Code is `:mandatory` or `:optional`. Default to `:optional`.
46
+ attr_accessor :duo_code_review
35
47
 
48
+ # Rule: simple_roulette
36
49
  # @!attribute included_optional_codeowners_sections_for_roulette
37
50
  # @return [Array] indicating which optional codeowners sections should be included in roulette. Default to `[]`.
38
51
  attr_accessor :included_optional_codeowners_sections_for_roulette
39
52
 
53
+ # Rule: simple_roulette
40
54
  # @!attribute excluded_required_codeowners_sections_for_roulette
41
55
  # @return [Array] indicating which required codeowners sections should be excluded from roulette. Default to `[]`.
42
56
  attr_accessor :excluded_required_codeowners_sections_for_roulette
43
57
 
58
+ # @!attribute auto_assign_for_roulette_roles
59
+ # @return [Array<Symbol>] which roles to auto assign as reviewers, given roulette recommendations (:reviewer, :maintainer, or both). If empty, auto-assignment is disabled. Default to `[]`.
60
+ attr_accessor :auto_assign_for_roulette_roles
61
+
62
+ # @!attribute auto_assign_for_roulette_labels
63
+ # @return [Array<String>] MR labels that allow auto reviewer assignment. If empty, applies to all MRs, provided :auto_assign_for_roulette_roles is not empty. Default to `[]`.
64
+ attr_accessor :auto_assign_for_roulette_labels
65
+
44
66
  DEFAULT_CHANGES_SIZE_THRESHOLDS = { high: 2_000, medium: 500 }.freeze
45
67
  DEFAULT_COMMIT_MESSAGES_MAX_COMMITS_COUNT = 10
46
68
 
47
69
  def initialize
48
70
  @files_to_category = {}
71
+ @custom_labels_for_categories = {}
49
72
  @project_root = nil
50
73
  @project_name = ENV["CI_PROJECT_NAME"]
51
74
  @ci_only_rules = []
@@ -54,6 +77,9 @@ module Gitlab
54
77
  @disabled_roulette_categories = []
55
78
  @included_optional_codeowners_sections_for_roulette = []
56
79
  @excluded_required_codeowners_sections_for_roulette = []
80
+ @auto_assign_for_roulette_roles = []
81
+ @auto_assign_for_roulette_labels = []
82
+ @duo_code_review = :optional
57
83
  end
58
84
  end
59
85
  end
@@ -168,8 +168,8 @@ RSpec.shared_context "with teammates" do
168
168
  let(:software_engineer_in_import_integrate_fe) do
169
169
  Gitlab::Dangerfiles::Teammate.new(
170
170
  "username" => "software-engineer-in-import-and-integrate-fe",
171
- "name" => "Software Engineer in Import and Integrate FE",
172
- "role" => "Frontend Engineer, Manage:Import and Integrate",
171
+ "name" => "Frontend Engineer in Import and Integrate",
172
+ "role" => "AnyRole Frontend Engineer, AnyStage:Import and Integrate",
173
173
  "projects" => { "gitlab" => "reviewer frontend" },
174
174
  "available" => true,
175
175
  "tz_offset_hours" => 2.0
@@ -179,8 +179,8 @@ RSpec.shared_context "with teammates" do
179
179
  let(:software_engineer_in_import_integrate_be) do
180
180
  Gitlab::Dangerfiles::Teammate.new(
181
181
  "username" => "software-engineer-in-import-and-integrate-be",
182
- "name" => "Software Engineer in Import and Integrate BE",
183
- "role" => "Backend Engineer, Manage:Import and Integrate",
182
+ "name" => "Backend Engineer in Import and Integrate",
183
+ "role" => "AnyRole Backend Engineer, AnyStage:Import and Integrate",
184
184
  "projects" => { "gitlab" => "reviewer backend" },
185
185
  "available" => true,
186
186
  "tz_offset_hours" => 2.0
@@ -224,7 +224,7 @@ RSpec.shared_context "with teammates" do
224
224
  Gitlab::Dangerfiles::Teammate.new(
225
225
  "username" => "import-and-integrate-backend-reviewer",
226
226
  "name" => "Import and Integrate BE engineer",
227
- "role" => "Backend Engineer, Manage:Import and Integrate",
227
+ "role" => "AnyRole Backend Engineer, AnyStage:Import and Integrate",
228
228
  "projects" => { "gitlab" => "reviewer backend" },
229
229
  "available" => backend_reviewer_available,
230
230
  "tz_offset_hours" => 2.0
@@ -235,7 +235,7 @@ RSpec.shared_context "with teammates" do
235
235
  Gitlab::Dangerfiles::Teammate.new(
236
236
  "username" => "import-and-integrate-frontend-reviewer",
237
237
  "name" => "Import and Integrate FE engineer",
238
- "role" => "Frontend Engineer, Manage:Import and Integrate",
238
+ "role" => "AnyRole Frontend Engineer, AnyStage:Import and Integrate",
239
239
  "projects" => { "gitlab" => "reviewer frontend" },
240
240
  "available" => true,
241
241
  "tz_offset_hours" => 2.0
@@ -285,7 +285,7 @@ RSpec.shared_context "with teammates" do
285
285
  end
286
286
 
287
287
  let(:teammate_json) { teammates.to_json }
288
- let(:teammate_pedroms) { instance_double(Gitlab::Dangerfiles::Teammate, name: "Pedro") }
288
+ let(:ux_fallback_reviewer) { instance_double(Gitlab::Dangerfiles::Teammate) }
289
289
  let(:company_members) { Gitlab::Dangerfiles::Teammate.fetch_company_members }
290
290
 
291
291
  before do
@@ -18,7 +18,7 @@ module Gitlab
18
18
  @team_author = team_author
19
19
  @labels = labels
20
20
  @categories = categories.reject do |category|
21
- import_and_integrate_reject_category?(category)
21
+ import_and_integrate_reject_category?(project, category, labels)
22
22
  end
23
23
  @random = random
24
24
  @ux_fallback_wider_community_reviewer = ux_fallback_wider_community_reviewer
@@ -98,12 +98,13 @@ module Gitlab
98
98
 
99
99
  attr_reader :random, :ux_fallback_wider_community_reviewer
100
100
 
101
+ # Reject Import and Integrate categories if the MR author has reviewing abilities for the category.
102
+ #
101
103
  # @param [String] category name
102
104
  # @return [Boolean]
103
- def import_and_integrate_reject_category?(category)
104
- # Reject Import and Integrate categories if the MR author has reviewing abilities for the category.
105
- team_author&.import_integrate_be?(project, category, labels) ||
106
- team_author&.import_integrate_fe?(project, category, labels)
105
+ def import_and_integrate_reject_category?(project, category, labels)
106
+ [:import_integrate_be, :import_integrate_fe].include?(category) && team_author &&
107
+ (team_author.reviewer?(project, category, labels) || team_author.maintainer?(project, category, labels))
107
108
  end
108
109
 
109
110
  # MR includes QA changes, but also other changes, and author isn't an SET
@@ -141,18 +141,6 @@ module Gitlab
141
141
  has_capability?(project, category, :maintainer, labels)
142
142
  end
143
143
 
144
- def import_integrate_be?(project, category, labels)
145
- return false unless category == :import_integrate_be
146
-
147
- has_capability?(project, category, :reviewer, labels)
148
- end
149
-
150
- def import_integrate_fe?(project, category, labels)
151
- return false unless category == :import_integrate_fe
152
-
153
- has_capability?(project, category, :reviewer, labels)
154
- end
155
-
156
144
  def markdown_name(author: nil)
157
145
  "#{@markdown_name}#{utc_offset_text(author)}"
158
146
  end
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module Dangerfiles
3
- VERSION = "4.8.1"
3
+ VERSION = "4.10.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-dangerfiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.1
4
+ version: 4.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-09 00:00:00.000000000 Z
11
+ date: 2025-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '3.8'
139
+ - !ruby/object:Gem::Dependency
140
+ name: racc
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.8'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.8'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rubocop-rails
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -225,12 +239,14 @@ files:
225
239
  - gitlab-dangerfiles.gemspec
226
240
  - lefthook.yml
227
241
  - lib/danger/plugins/changelog.rb
242
+ - lib/danger/plugins/duo_code.rb
228
243
  - lib/danger/plugins/internal/helper.rb
229
244
  - lib/danger/plugins/roulette.rb
230
245
  - lib/danger/rules/changelog/Dangerfile
231
246
  - lib/danger/rules/changes_size/Dangerfile
232
247
  - lib/danger/rules/commit_messages/Dangerfile
233
248
  - lib/danger/rules/commits_counter/Dangerfile
249
+ - lib/danger/rules/duo_code_review/Dangerfile
234
250
  - lib/danger/rules/metadata/Dangerfile
235
251
  - lib/danger/rules/simple_roulette/Dangerfile
236
252
  - lib/danger/rules/type_label/Dangerfile
@@ -282,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
298
  - !ruby/object:Gem::Version
283
299
  version: '0'
284
300
  requirements: []
285
- rubygems_version: 3.3.27
301
+ rubygems_version: 3.5.22
286
302
  signing_key:
287
303
  specification_version: 4
288
304
  summary: This gem provides common Dangerfile and plugins for GitLab projects.