gitlab-dangerfiles 4.15.0 → 4.16.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/danger/plugins/roulette.rb +11 -2
- data/lib/gitlab/dangerfiles/spinner.rb +23 -2
- data/lib/gitlab/dangerfiles/version.rb +1 -1
- data/lib/gitlab/dangerfiles/weightage/maintainers.rb +16 -6
- 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: de8c5634c5610dde9ee47b4446474cd2eb6c85b1422f75669d521013a2e98fa9
|
|
4
|
+
data.tar.gz: 37875a0979e3b2a998fbbed0bd152041b52c16f9b268ca7dfa5c441e261b790a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9119973d7af2b7dc6905e630aea45ac782a8554b26e487ad9707a97f621a9f8f4ce558fe025f192ca0c1327a72739bd1fd0e0855951dab5383d4711a5d90ce87
|
|
7
|
+
data.tar.gz: e566d1510219544f7b88a795b5ce9250d58577ec4f35df5e748a889ae4048b5ba40d6a740282b872daebdac575409d3cab8cf4c73b8f16fcee34cace85320cd3
|
data/Gemfile.lock
CHANGED
|
@@ -44,9 +44,16 @@ module Danger
|
|
|
44
44
|
#
|
|
45
45
|
# @param project [String] A project path.
|
|
46
46
|
# @param categories [Array<Symbol>] An array of categories symbols.
|
|
47
|
+
# @param maintainer_pool [Symbol] Who can fill the maintainer slot: +:maintainers+ (default) or
|
|
48
|
+
# +:maintainers_and_traintainers+. Trainee maintainers cannot merge, so they review and then assign a maintainer.
|
|
49
|
+
# @param traintainer_boost [Integer] Extra base weight for trainee maintainers in the
|
|
50
|
+
# +:maintainers_and_traintainers+ pool. The default gives them 3 entries for each maintainer entry;
|
|
51
|
+
# 0 gives both groups the same weight. Reduced capacity drops the boost.
|
|
47
52
|
#
|
|
48
53
|
# @return [Array<Spin>]
|
|
49
|
-
def spin(
|
|
54
|
+
def spin(
|
|
55
|
+
project = nil, categories = [:none], ux_fallback_wider_community_reviewer: ux_fallback_reviewer, maintainer_pool: :maintainers,
|
|
56
|
+
traintainer_boost: Gitlab::Dangerfiles::Spinner::DEFAULT_TRAINTAINER_BOOST)
|
|
50
57
|
# TODO: Deprecate the project argument. It prevents us from
|
|
51
58
|
# memorizing Spinner and can cause unexpected results if it's
|
|
52
59
|
# passing a different project than the merge request project.
|
|
@@ -65,7 +72,9 @@ module Danger
|
|
|
65
72
|
ux_fallback_wider_community_reviewer,
|
|
66
73
|
codeowners_usernames: co_usernames,
|
|
67
74
|
codeowners_reviewer_boost: reviewer_boost,
|
|
68
|
-
codeowners_maintainer_boost: maintainer_boost
|
|
75
|
+
codeowners_maintainer_boost: maintainer_boost,
|
|
76
|
+
maintainer_pool: maintainer_pool,
|
|
77
|
+
traintainer_boost: traintainer_boost)
|
|
69
78
|
.spin
|
|
70
79
|
end
|
|
71
80
|
|
|
@@ -8,16 +8,26 @@ require_relative "weightage/reviewers"
|
|
|
8
8
|
module Gitlab
|
|
9
9
|
module Dangerfiles
|
|
10
10
|
class Spinner
|
|
11
|
+
MAINTAINER_POOLS = %i[maintainers maintainers_and_traintainers].freeze
|
|
12
|
+
DEFAULT_TRAINTAINER_BOOST = 2
|
|
13
|
+
|
|
11
14
|
attr_reader :project, :author, :team_author, :labels, :categories
|
|
12
15
|
|
|
13
16
|
# @param codeowners_usernames [Set<String>] usernames of CODEOWNERS-eligible approvers for the MR
|
|
14
17
|
# @param codeowners_reviewer_boost [Integer] extra weight entries for CODEOWNERS-eligible reviewers
|
|
15
18
|
# @param codeowners_maintainer_boost [Integer] extra weight entries for CODEOWNERS-eligible maintainers
|
|
19
|
+
# @param maintainer_pool [Symbol] one of MAINTAINER_POOLS
|
|
20
|
+
# @param traintainer_boost [Integer] extra base weight for trainee maintainers in the
|
|
21
|
+
# +:maintainers_and_traintainers+ pool. The default gives them 3 entries for each maintainer
|
|
22
|
+
# entry. Reduced capacity drops the boost.
|
|
16
23
|
def initialize( # rubocop:disable Metrics/ParameterLists -- CODEOWNERS boost params extend the existing signature
|
|
17
24
|
project:, author:, team_author: nil, labels: [], categories: [],
|
|
18
25
|
random: Random.new, ux_fallback_wider_community_reviewer: nil,
|
|
19
26
|
codeowners_usernames: Set.new, codeowners_reviewer_boost: 0,
|
|
20
|
-
codeowners_maintainer_boost: 0
|
|
27
|
+
codeowners_maintainer_boost: 0, maintainer_pool: :maintainers,
|
|
28
|
+
traintainer_boost: DEFAULT_TRAINTAINER_BOOST)
|
|
29
|
+
raise ArgumentError, "Unknown maintainer_pool: #{maintainer_pool.inspect}" unless MAINTAINER_POOLS.include?(maintainer_pool)
|
|
30
|
+
|
|
21
31
|
@project = project
|
|
22
32
|
@author = author
|
|
23
33
|
@team_author = team_author
|
|
@@ -28,6 +38,8 @@ module Gitlab
|
|
|
28
38
|
@codeowners_usernames = codeowners_usernames
|
|
29
39
|
@codeowners_reviewer_boost = codeowners_reviewer_boost
|
|
30
40
|
@codeowners_maintainer_boost = codeowners_maintainer_boost
|
|
41
|
+
@maintainer_pool = maintainer_pool
|
|
42
|
+
@traintainer_boost = traintainer_boost
|
|
31
43
|
end
|
|
32
44
|
|
|
33
45
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
@@ -96,7 +108,8 @@ module Gitlab
|
|
|
96
108
|
private
|
|
97
109
|
|
|
98
110
|
attr_reader :random, :ux_fallback_wider_community_reviewer,
|
|
99
|
-
:codeowners_usernames, :codeowners_reviewer_boost, :codeowners_maintainer_boost
|
|
111
|
+
:codeowners_usernames, :codeowners_reviewer_boost, :codeowners_maintainer_boost,
|
|
112
|
+
:maintainer_pool, :traintainer_boost
|
|
100
113
|
|
|
101
114
|
def spin_for_category(category)
|
|
102
115
|
reviewers, traintainers, maintainers =
|
|
@@ -111,6 +124,8 @@ module Gitlab
|
|
|
111
124
|
).execute
|
|
112
125
|
weighted_maintainers = Weightage::Maintainers.new(
|
|
113
126
|
maintainers,
|
|
127
|
+
traintainers: maintainer_pool == :maintainers_and_traintainers ? traintainers : [],
|
|
128
|
+
traintainer_boost: traintainer_boost,
|
|
114
129
|
codeowners_usernames: codeowners_usernames,
|
|
115
130
|
codeowners_boost: codeowners_maintainer_boost
|
|
116
131
|
).execute
|
|
@@ -118,6 +133,12 @@ module Gitlab
|
|
|
118
133
|
reviewer = spin_for_person(weighted_reviewers)
|
|
119
134
|
maintainer = spin_for_person(weighted_maintainers)
|
|
120
135
|
|
|
136
|
+
# A trainee maintainer can be in both pools. Keep the maintainer pick and spin the reviewer again.
|
|
137
|
+
if maintainer && reviewer == maintainer
|
|
138
|
+
weighted_reviewers.delete(maintainer)
|
|
139
|
+
reviewer = spin_for_person(weighted_reviewers)
|
|
140
|
+
end
|
|
141
|
+
|
|
121
142
|
# allow projects with small number of reviewers to take from maintainers if possible
|
|
122
143
|
if reviewer.nil? && weighted_maintainers.uniq.size > 1
|
|
123
144
|
weighted_maintainers.delete(maintainer)
|
|
@@ -8,29 +8,39 @@ module Gitlab
|
|
|
8
8
|
# @api private
|
|
9
9
|
class Maintainers
|
|
10
10
|
# @param maintainers [Array<Gitlab::Dangerfiles::Teammate>]
|
|
11
|
+
# @param traintainers [Array<Gitlab::Dangerfiles::Teammate>] trainee maintainers who can fill the maintainer slot
|
|
12
|
+
# @param traintainer_boost [Integer] extra base weight for trainee maintainers at full capacity
|
|
11
13
|
# @param codeowners_usernames [Set<String>] usernames of CODEOWNERS-eligible approvers for the MR
|
|
12
14
|
# @param codeowners_boost [Integer] extra weight entries for CODEOWNERS-eligible maintainers
|
|
13
|
-
def initialize(maintainers, codeowners_usernames: Set.new, codeowners_boost: 0)
|
|
15
|
+
def initialize(maintainers, traintainers: [], traintainer_boost: 0, codeowners_usernames: Set.new, codeowners_boost: 0)
|
|
14
16
|
@maintainers = maintainers
|
|
17
|
+
@traintainers = traintainers
|
|
18
|
+
@traintainer_boost = traintainer_boost
|
|
15
19
|
@codeowners_usernames = codeowners_usernames
|
|
16
20
|
@codeowners_boost = codeowners_boost
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
def execute
|
|
20
|
-
maintainers.each_with_object([]) do |maintainer,
|
|
21
|
-
add_weighted_reviewer(
|
|
24
|
+
weighted_maintainers = maintainers.each_with_object([]) do |maintainer, weighted|
|
|
25
|
+
add_weighted_reviewer(weighted, maintainer, Gitlab::Dangerfiles::Weightage::BASE_REVIEWER_WEIGHT)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# A person listed in both groups keeps the maintainer weight.
|
|
29
|
+
(traintainers - maintainers).each_with_object(weighted_maintainers) do |traintainer, weighted|
|
|
30
|
+
add_weighted_reviewer(weighted, traintainer, Gitlab::Dangerfiles::Weightage::BASE_REVIEWER_WEIGHT, boost: traintainer_boost)
|
|
22
31
|
end
|
|
23
32
|
end
|
|
24
33
|
|
|
25
34
|
private
|
|
26
35
|
|
|
27
|
-
attr_reader :maintainers, :codeowners_usernames, :codeowners_boost
|
|
36
|
+
attr_reader :maintainers, :traintainers, :traintainer_boost, :codeowners_usernames, :codeowners_boost
|
|
28
37
|
|
|
29
|
-
|
|
38
|
+
# Reduced capacity drops the boost, the same rule as Weightage::Reviewers.
|
|
39
|
+
def add_weighted_reviewer(reviewers, reviewer, weight, boost: 0)
|
|
30
40
|
if reviewer.reduced_capacity
|
|
31
41
|
reviewers.fill(reviewer, reviewers.size, weight)
|
|
32
42
|
else
|
|
33
|
-
reviewers.fill(reviewer, reviewers.size, weight * Gitlab::Dangerfiles::Weightage::CAPACITY_MULTIPLIER)
|
|
43
|
+
reviewers.fill(reviewer, reviewers.size, (weight + boost) * Gitlab::Dangerfiles::Weightage::CAPACITY_MULTIPLIER)
|
|
34
44
|
end
|
|
35
45
|
|
|
36
46
|
reviewers.fill(reviewer, reviewers.size, codeowners_boost) if codeowners_boost.positive? && codeowners_usernames.include?(reviewer.username)
|
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.
|
|
4
|
+
version: 4.16.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GitLab
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|