gitlab-dangerfiles 3.11.0 → 3.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/danger/plugins/roulette.rb +28 -34
- data/lib/gitlab/dangerfiles/config.rb +10 -0
- data/lib/gitlab/dangerfiles/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edf969f524278d280762935cb8a04c78a22180296c3b7e88deb342ab8f83c840
|
4
|
+
data.tar.gz: 6b3b3c493beb17172786cefaa6e6ac1dd1ef243234b5e90e632b79830a7fae9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56e849f993eec188646a8f06106855409146070234b158c8cd48abe0378008c9d1c957dafbb1af6dbee4f86744014d1a852bc426993337f8b9978b9e7cdcdd80
|
7
|
+
data.tar.gz: 19f31baf98812c924fc62d88cdc601f0f73a0c9e0c239647e25d6e79c6a1a4eaec831397658883b9cc9aff70e0fabee8e3f4df0908f119c0262788296097793e
|
@@ -11,11 +11,7 @@ module Danger
|
|
11
11
|
ROULETTE_DATA_URL = "https://gitlab-org.gitlab.io/gitlab-roulette/roulette.json"
|
12
12
|
HOURS_WHEN_PERSON_CAN_BE_PICKED = (6..14).freeze
|
13
13
|
|
14
|
-
|
15
|
-
database: false,
|
16
|
-
}.freeze
|
17
|
-
|
18
|
-
Spin = Struct.new(:category, :reviewer, :maintainer, :optional_role, :timezone_experiment)
|
14
|
+
Spin = Struct.new(:category, :reviewer, :maintainer, :optional_role)
|
19
15
|
HTTPError = Class.new(StandardError)
|
20
16
|
|
21
17
|
Approval = Struct.new(:category, :spin) do
|
@@ -73,26 +69,22 @@ module Danger
|
|
73
69
|
#
|
74
70
|
# @param project [String] A project path.
|
75
71
|
# @param categories [Array<Symbol>] An array of categories symbols.
|
76
|
-
# @param timezone_experiment [Boolean] Whether to select reviewers based in timezone or not.
|
77
72
|
#
|
78
73
|
# @return [Array<Spin>]
|
79
74
|
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
80
|
-
def spin(project = nil, categories = [:none]
|
75
|
+
def spin(project = nil, categories = [:none])
|
81
76
|
project = (project || config_project_name).downcase
|
82
77
|
categories = categories.map { |category| category&.downcase || :none }
|
83
78
|
categories.reject! { |category| import_and_integrate_reject_category?(category, project) }
|
84
79
|
|
85
80
|
spins = categories.sort_by(&:to_s).map do |category|
|
86
|
-
|
87
|
-
|
88
|
-
spin_for_category(project, category, timezone_experiment: including_timezone)
|
81
|
+
spin_for_category(project, category)
|
89
82
|
end
|
90
83
|
|
91
84
|
backend_spin = spins.find { |spin| spin.category == :backend }
|
92
85
|
frontend_spin = spins.find { |spin| spin.category == :frontend }
|
93
86
|
|
94
87
|
spins.each do |spin|
|
95
|
-
including_timezone = INCLUDE_TIMEZONE_FOR_CATEGORY.fetch(spin.category, timezone_experiment)
|
96
88
|
case spin.category
|
97
89
|
when :qa
|
98
90
|
# MR includes QA changes, but also other changes, and author isn't an SET
|
@@ -105,24 +97,24 @@ module Danger
|
|
105
97
|
|
106
98
|
if spin.reviewer.nil?
|
107
99
|
# Fetch an already picked backend reviewer, or pick one otherwise
|
108
|
-
spin.reviewer = backend_spin&.reviewer || spin_for_category(project, :backend
|
100
|
+
spin.reviewer = backend_spin&.reviewer || spin_for_category(project, :backend).reviewer
|
109
101
|
end
|
110
102
|
when :tooling, :engineering_productivity # Deprecated as of 2.3.0 in favor of tooling
|
111
103
|
if spin.maintainer.nil?
|
112
104
|
# Fetch an already picked backend maintainer, or pick one otherwise
|
113
|
-
spin.maintainer = backend_spin&.maintainer || spin_for_category(project, :backend
|
105
|
+
spin.maintainer = backend_spin&.maintainer || spin_for_category(project, :backend).maintainer
|
114
106
|
end
|
115
107
|
when :ci_template
|
116
108
|
if spin.maintainer.nil?
|
117
109
|
# Fetch an already picked backend maintainer, or pick one otherwise
|
118
|
-
spin.maintainer = backend_spin&.maintainer || spin_for_category(project, :backend
|
110
|
+
spin.maintainer = backend_spin&.maintainer || spin_for_category(project, :backend).maintainer
|
119
111
|
end
|
120
112
|
when :analytics_instrumentation
|
121
113
|
spin.optional_role = :maintainer
|
122
114
|
|
123
115
|
if spin.maintainer.nil?
|
124
116
|
# Fetch an already picked maintainer, or pick one otherwise
|
125
|
-
spin.maintainer = backend_spin&.maintainer || frontend_spin&.maintainer || spin_for_category(project, :backend
|
117
|
+
spin.maintainer = backend_spin&.maintainer || frontend_spin&.maintainer || spin_for_category(project, :backend).maintainer
|
126
118
|
end
|
127
119
|
when :import_integrate_be, :import_integrate_fe
|
128
120
|
spin.optional_role = :maintainer
|
@@ -136,7 +128,7 @@ module Danger
|
|
136
128
|
|
137
129
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
138
130
|
|
139
|
-
def
|
131
|
+
def codeowners_approvals
|
140
132
|
approval_rules = helper.mr_approval_state["rules"]
|
141
133
|
|
142
134
|
return [] unless approval_rules
|
@@ -156,13 +148,25 @@ module Danger
|
|
156
148
|
@teammate_pedroms ||= find_member("pedroms")
|
157
149
|
end
|
158
150
|
|
151
|
+
alias_method :required_approvals, :codeowners_approvals
|
152
|
+
|
159
153
|
private
|
160
154
|
|
161
155
|
def spin_for_approval_rule?(rule)
|
162
156
|
rule["rule_type"] == "code_owner" &&
|
163
|
-
rule
|
157
|
+
should_include_codeowners_rule?(rule) &&
|
164
158
|
# Exclude generic codeowners rule, which should be covered by others already
|
165
|
-
!generic_codeowners_rule?(rule)
|
159
|
+
!generic_codeowners_rule?(rule) &&
|
160
|
+
!excluded_required_codeowners_rule?(rule)
|
161
|
+
end
|
162
|
+
|
163
|
+
def should_include_codeowners_rule?(rule)
|
164
|
+
rule["approvals_required"] > 0 ||
|
165
|
+
helper.config.included_optional_codeowners_sections_for_roulette.include?(rule["section"])
|
166
|
+
end
|
167
|
+
|
168
|
+
def excluded_required_codeowners_rule?(rule)
|
169
|
+
helper.config.excluded_required_codeowners_sections_for_roulette.include?(rule["section"])
|
166
170
|
end
|
167
171
|
|
168
172
|
def generic_codeowners_rule?(rule)
|
@@ -191,12 +195,6 @@ module Danger
|
|
191
195
|
!mr_author?(person) && person.available
|
192
196
|
end
|
193
197
|
|
194
|
-
# @param [Gitlab::Dangerfiles::Teammate] person
|
195
|
-
# @return [Boolean]
|
196
|
-
def valid_person_with_timezone?(person)
|
197
|
-
valid_person?(person) && HOURS_WHEN_PERSON_CAN_BE_PICKED.cover?(person.local_hour)
|
198
|
-
end
|
199
|
-
|
200
198
|
# @param [Gitlab::Dangerfiles::Teammate] person
|
201
199
|
# @return [Boolean]
|
202
200
|
def mr_author?(person)
|
@@ -227,14 +225,10 @@ module Danger
|
|
227
225
|
# @param [Array<Gitlab::Dangerfiles::Teammate>] people
|
228
226
|
#
|
229
227
|
# @return [Gitlab::Dangerfiles::Teammate]
|
230
|
-
def spin_for_person(people
|
228
|
+
def spin_for_person(people)
|
231
229
|
shuffled_people = people.shuffle(random: random)
|
232
230
|
|
233
|
-
|
234
|
-
shuffled_people.find(&method(:valid_person_with_timezone?))
|
235
|
-
else
|
236
|
-
shuffled_people.find(&method(:valid_person?))
|
237
|
-
end
|
231
|
+
shuffled_people.find(&method(:valid_person?))
|
238
232
|
end
|
239
233
|
|
240
234
|
# Spin a reviewer for a particular approval rule
|
@@ -274,7 +268,7 @@ module Danger
|
|
274
268
|
fallback_approvers.sample(random: random)
|
275
269
|
end
|
276
270
|
|
277
|
-
def spin_for_category(project, category
|
271
|
+
def spin_for_category(project, category)
|
278
272
|
team = project_team(project)
|
279
273
|
reviewers, traintainers, maintainers =
|
280
274
|
%i[reviewer traintainer maintainer].map do |role|
|
@@ -284,10 +278,10 @@ module Danger
|
|
284
278
|
weighted_reviewers = Gitlab::Dangerfiles::Weightage::Reviewers.new(reviewers, traintainers).execute
|
285
279
|
weighted_maintainers = Gitlab::Dangerfiles::Weightage::Maintainers.new(maintainers).execute
|
286
280
|
|
287
|
-
reviewer = spin_for_person(weighted_reviewers
|
288
|
-
maintainer = spin_for_person(weighted_maintainers
|
281
|
+
reviewer = spin_for_person(weighted_reviewers)
|
282
|
+
maintainer = spin_for_person(weighted_maintainers)
|
289
283
|
|
290
|
-
Spin.new(category, reviewer, maintainer, false
|
284
|
+
Spin.new(category, reviewer, maintainer, false)
|
291
285
|
end
|
292
286
|
|
293
287
|
def prepare_ux_category!(categories)
|
@@ -33,6 +33,14 @@ module Gitlab
|
|
33
33
|
# @return [Array] indicating which categories would be disabled for the simple roulette. Default to `[]` (all categories are enabled)
|
34
34
|
attr_accessor :disabled_roulette_categories
|
35
35
|
|
36
|
+
# @!attribute included_optional_codeowners_sections_for_roulette
|
37
|
+
# @return [Array] indicating which optional codeowners sections should be included in roulette. Default to `[]`.
|
38
|
+
attr_accessor :included_optional_codeowners_sections_for_roulette
|
39
|
+
|
40
|
+
# @!attribute excluded_required_codeowners_sections_for_roulette
|
41
|
+
# @return [Array] indicating which required codeowners sections should be excluded from roulette. Default to `[]`.
|
42
|
+
attr_accessor :excluded_required_codeowners_sections_for_roulette
|
43
|
+
|
36
44
|
DEFAULT_CHANGES_SIZE_THRESHOLDS = { high: 2_000, medium: 500 }.freeze
|
37
45
|
DEFAULT_COMMIT_MESSAGES_MAX_COMMITS_COUNT = 10
|
38
46
|
|
@@ -44,6 +52,8 @@ module Gitlab
|
|
44
52
|
@code_size_thresholds = DEFAULT_CHANGES_SIZE_THRESHOLDS
|
45
53
|
@max_commits_count = DEFAULT_COMMIT_MESSAGES_MAX_COMMITS_COUNT
|
46
54
|
@disabled_roulette_categories = []
|
55
|
+
@included_optional_codeowners_sections_for_roulette = []
|
56
|
+
@excluded_required_codeowners_sections_for_roulette = []
|
47
57
|
end
|
48
58
|
end
|
49
59
|
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.
|
4
|
+
version: 3.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|