gitlab-dangerfiles 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b25f2e8617ff29a3ea964b59774b02c395127c4800bfa1552affd2e71bf62a89
4
- data.tar.gz: 813ca1c6dbd433cd43f1f5ef0efc44a514af3edf7cf7ed07d75eea50640817da
3
+ metadata.gz: bf965c37aaf01dff0630442feecb4fbe6e8d96bb2c9f7f714c631487c9eb894e
4
+ data.tar.gz: 720fe1ddfd202e0b199dfbd63fdb360a8a7e58d355182b7055ff0fdebb74c886
5
5
  SHA512:
6
- metadata.gz: d5208cc7b7c588c5fe7403f3b79631313a71c64007ed572fe8a5848a1c229f59f9e653f0b263c5c73efc85a1339fda852d2f44f376cca19f2d2ecac8e406b111
7
- data.tar.gz: 4b31682875c0c7f5037463d035a57cb9ccd4215d68879105ce4a369539d1e155b6da7b620f942611d9d0fc92251bf58338614230bd16008dbd715974ffee57d9
6
+ metadata.gz: 31a832aa516290296662a7949b01a13c7dd47e7c05ad6c6e78cb1f189f2190b99094e97a07875d65f4cb6b5504a8816d1a26aa39a618480899f2026c58c2c311
7
+ data.tar.gz: 4f18f92c83494aff49ceec1a05f2b380bd9be7aee17a50a4126ec25c011cfc468a672da200d4a93420d4c47bbec19d6678dc389e083a56945d94d52a58862107
@@ -192,7 +192,10 @@ module Danger
192
192
  #
193
193
  # @return [Array<Gitlab::Dangerfiles::Teammate>]
194
194
  def project_team(project_name)
195
- company_members.select { |member| member.in_project?(project_name) }
195
+ company_members.select do |member|
196
+ member.in_project?(project_name) ||
197
+ member.in_project?("gitlab") # Used for backup reviewer
198
+ end
196
199
  rescue => err
197
200
  warn("Reviewer roulette failed to load team data: #{err.message}")
198
201
  []
@@ -60,37 +60,44 @@ def note_for_spin_role(spin, role)
60
60
  spin.public_send(role)&.markdown_name(author: roulette.team_mr_author)
61
61
  end
62
62
 
63
- def markdown_row_for_spins(category = nil, spins_array)
63
+ def markdown_row_for_spins(category = nil, spins_array, has_categories:)
64
64
  reviewer_note = note_for_spins_role(spins_array, :reviewer)
65
65
  maintainer_note = note_for_spins_role(spins_array, :maintainer)
66
66
 
67
67
  row = +"| #{reviewer_note} | #{maintainer_note} |"
68
- row.prepend("| #{helper.label_for_category(category)} ") if categories_defined?
69
-
68
+ row.prepend("| #{helper.label_for_category(category)} ") if has_categories
70
69
  row
71
70
  end
72
71
 
73
- def categories_defined?
74
- helper.config.files_to_category.any?
75
- end
72
+ changes = helper.changes_by_category
76
73
 
77
- def categories(changes)
78
- categories_defined? ? changes.keys : [nil]
79
- end
74
+ # Replicating label based categories from:
75
+ # https://gitlab.com/gitlab-org/gitlab/-/blob/master/danger/roulette/Dangerfile
76
+ categories = Set.new(changes.keys - [:unknown])
80
77
 
81
- def table_header
82
- categories_defined? ? TABLE_HEADER_WITH_CATEGORIES : TABLE_HEADER_WITHOUT_CATEGORIES
83
- end
78
+ # Ensure to spin for database reviewer/maintainer when ~database is applied (e.g. to review SQL queries)
79
+ categories << :database if helper.mr_labels.include?('database')
84
80
 
85
- changes = helper.changes_by_category
81
+ # Ensure to spin for UX reviewer when ~UX is applied (e.g. to review changes to the UI) except when it's from wider community contribution where we want to assign from the corresponding group
82
+ categories << :ux if helper.mr_labels.include?('UX') && !helper.mr_labels.include?('Community contribution')
83
+
84
+ # Ensure to spin for Product Intelligence reviewer when ~"product intelligence::review pending" is applied
85
+ categories << :product_intelligence if helper.mr_labels.include?("product intelligence::review pending")
86
+
87
+ # Skip Product intelligence reviews for growth experiment MRs
88
+ categories.delete(:product_intelligence) if helper.mr_labels.include?("growth experiment")
86
89
 
87
90
  if changes.any?
88
- random_roulette_spins = roulette.spin(nil, categories(changes))
91
+ has_categories = categories.any?
92
+ categories = [nil] unless has_categories
93
+ random_roulette_spins = roulette.spin(nil, categories)
89
94
 
90
95
  rows = random_roulette_spins.map do |spin|
91
- markdown_row_for_spins(spin.category, [spin])
96
+ markdown_row_for_spins(spin.category, [spin], has_categories: has_categories)
92
97
  end
93
98
 
99
+ table_header = has_categories ? TABLE_HEADER_WITH_CATEGORIES : TABLE_HEADER_WITHOUT_CATEGORIES
100
+
94
101
  markdown(MESSAGE)
95
102
  markdown(TABLE_MARKDOWN + table_header + rows.join("\n")) unless rows.empty?
96
103
  end
@@ -130,11 +130,22 @@ module Gitlab
130
130
  capabilities(project).include?("#{kind}")
131
131
  else
132
132
  capabilities(project).include?("#{kind} #{category}")
133
+ end || has_backup_capability?(category, kind, labels)
134
+ end
135
+
136
+ def has_backup_capability?(category, kind, labels)
137
+ case category
138
+ when :ux
139
+ capacity = "#{kind} #{category}"
140
+
141
+ projects.each_value.find do |capabilities|
142
+ capabilities.include?(capacity)
143
+ end
133
144
  end
134
145
  end
135
146
 
136
147
  def capabilities(project)
137
- Array(projects.fetch(project, []))
148
+ projects.fetch(project, [])
138
149
  end
139
150
 
140
151
  def pluralize(count, singular, plural)
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module Dangerfiles
3
- VERSION = "3.2.0"
3
+ VERSION = "3.3.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: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-14 00:00:00.000000000 Z
11
+ date: 2022-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake