Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ab784910
Commit
ab784910
authored
Mar 12, 2020
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fallback to backend reviewer/mtainer for test/eng-prod changes
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
51aad1dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
11 deletions
+40
-11
danger/roulette/Dangerfile
danger/roulette/Dangerfile
+37
-8
lib/gitlab/danger/helper.rb
lib/gitlab/danger/helper.rb
+3
-3
No files found.
danger/roulette/Dangerfile
View file @
ab784910
...
...
@@ -38,24 +38,32 @@ MARKDOWN
NO_REVIEWER
=
'No reviewer available'
.
freeze
NO_MAINTAINER
=
'No maintainer available'
.
freeze
def
spin_for_category
(
team
,
project
,
category
,
branch_name
)
random
=
roulette
.
new_random
(
branch_name
)
labels
=
gitlab
.
mr_labels
Spin
=
Struct
.
new
(
:reviewer
,
:maintainer
)
def
spin_role_for_category
(
team
,
role
,
project
,
category
)
team
.
select
do
|
member
|
member
.
public_send
(
"
#{
role
}
?"
,
project
,
category
,
gitlab
.
mr_labels
)
# rubocop:disable GitlabSecurity/PublicSend
end
end
def
spin_for_category
(
team
,
project
,
category
,
branch_name
)
reviewers
,
traintainers
,
maintainers
=
%i[reviewer? traintainer? maintainer?]
.
map
do
|
kind
|
team
.
select
do
|
member
|
member
.
public_send
(
kind
,
project
,
category
,
labels
)
# rubocop:disable GitlabSecurity/PublicSend
end
%i[reviewer traintainer maintainer]
.
map
do
|
role
|
spin_role_for_category
(
team
,
role
,
project
,
category
)
end
# TODO: take CODEOWNERS into account?
# https://gitlab.com/gitlab-org/gitlab/issues/26723
# Make traintainers have triple the chance to be picked as a reviewer
random
=
roulette
.
new_random
(
branch_name
)
reviewer
=
roulette
.
spin_for_person
(
reviewers
+
traintainers
+
traintainers
,
random:
random
)
maintainer
=
roulette
.
spin_for_person
(
maintainers
,
random:
random
)
Spin
.
new
(
reviewer
,
maintainer
)
end
def
markdown_row_for_category
(
category
,
reviewer
,
maintainer
)
"|
#{
helper
.
label_for_category
(
category
)
}
|
#{
reviewer
&
.
markdown_name
||
NO_REVIEWER
}
|
#{
maintainer
&
.
markdown_name
||
NO_MAINTAINER
}
|"
end
...
...
@@ -85,8 +93,29 @@ if changes.any? && !gitlab.mr_labels.include?('CSS cleanup')
project
=
helper
.
project_name
unknown
=
changes
.
fetch
(
:unknown
,
[])
spin_per_category
=
categories
.
each_with_object
({})
do
|
category
,
memo
|
memo
[
category
]
=
spin_for_category
(
team
,
project
,
category
,
canonical_branch_name
)
end
rows
=
spin_per_category
.
map
do
|
category
,
spin
|
reviewer
=
spin
.
reviewer
maintainer
=
spin
.
maintainer
case
category
when
:test
if
reviewer
.
nil?
# Fetch an already picked backend reviewer, or pick one otherwise
reviewer
=
spin_per_category
[
:backend
]
&
.
reviewer
||
spin_for_category
(
team
,
project
,
:backend
,
canonical_branch_name
).
reviewer
end
when
:engineering_productivity
if
maintainer
.
nil?
# Fetch an already picked backend maintainer, or pick one otherwise
maintainer
=
spin_per_category
[
:backend
]
&
.
maintainer
||
spin_for_category
(
team
,
project
,
:backend
,
canonical_branch_name
).
maintainer
end
end
rows
=
categories
.
map
{
|
category
|
spin_for_category
(
team
,
project
,
category
,
canonical_branch_name
)
}
markdown_row_for_category
(
category
,
reviewer
,
maintainer
)
end
markdown
(
MESSAGE
)
markdown
(
CATEGORY_TABLE_HEADER
+
rows
.
join
(
"
\n
"
))
unless
rows
.
empty?
...
...
lib/gitlab/danger/helper.rb
View file @
ab784910
...
...
@@ -100,6 +100,7 @@ module Gitlab
test:
"~test ~Quality for `spec/features/*`"
,
engineering_productivity:
'~"Engineering Productivity" for CI, Danger'
}.
freeze
# First-match win, so be sure to put more specific regex at the top...
CATEGORIES
=
{
%r{
\A
doc/}
=>
:none
,
# To reinstate roulette for documentation, set to `:docs`.
%r{
\A
(CONTRIBUTING|LICENSE|MAINTENANCE|PHILOSOPHY|PROCESS|README)(
\.
md)?
\z
}
=>
:none
,
# To reinstate roulette for documentation, set to `:docs`.
...
...
@@ -145,9 +146,8 @@ module Gitlab
%r{
\A
(ee/)?app/(?!assets|views)[^/]+}
=>
:backend
,
%r{
\A
(ee/)?(bin|config|generator_templates|lib|rubocop)/}
=>
:backend
,
%r{
\A
(ee/)?spec/features/}
=>
:test
,
%r{
\A
(ee/)?spec/(?!javascripts|frontend)[^/]+}
=>
:backend
,
%r{
\A
(ee/)?vendor/(?!assets)[^/]+}
=>
:backend
,
%r{
\A
(ee/)?vendor/(languages
\.
yml|licenses
\.
csv)
\z
}
=>
:backend
,
%r{
\A
(ee/)?spec/}
=>
:backend
,
%r{
\A
(ee/)?vendor/}
=>
:backend
,
%r{
\A
(Gemfile|Gemfile.lock|Rakefile)
\z
}
=>
:backend
,
%r{
\A
[A-Z_]+_VERSION
\z
}
=>
:backend
,
%r{
\A\.
rubocop(_todo)?
\.
yml
\z
}
=>
:backend
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment