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
745ba70d
Commit
745ba70d
authored
Jun 13, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
24c74040
10ea9750
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
100 additions
and
33 deletions
+100
-33
changelogs/unreleased/61157-reviewer-roulette-shouldn-t-include-the-author-as-a-possibility.yml
...oulette-shouldn-t-include-the-author-as-a-possibility.yml
+5
-0
danger/gitlab_ui_wg/Dangerfile
danger/gitlab_ui_wg/Dangerfile
+18
-11
danger/roulette/Dangerfile
danger/roulette/Dangerfile
+4
-4
danger/single_codebase/Dangerfile
danger/single_codebase/Dangerfile
+7
-7
lib/gitlab/danger/helper.rb
lib/gitlab/danger/helper.rb
+4
-0
lib/gitlab/danger/roulette.rb
lib/gitlab/danger/roulette.rb
+9
-11
spec/lib/gitlab/danger/helper_spec.rb
spec/lib/gitlab/danger/helper_spec.rb
+10
-0
spec/lib/gitlab/danger/roulette_spec.rb
spec/lib/gitlab/danger/roulette_spec.rb
+43
-0
No files found.
changelogs/unreleased/61157-reviewer-roulette-shouldn-t-include-the-author-as-a-possibility.yml
0 → 100644
View file @
745ba70d
---
title
:
Excludes MR author from Review roulette
merge_request
:
28886
author
:
Jacopo Beschi @jacopo-beschi
type
:
fixed
danger/gitlab_ui_wg/Dangerfile
View file @
745ba70d
FRONTEND_MAINTAINERS
=
%w[filipa iamphill psimyn sarahghp mishunov]
.
freeze
UX_MAINTAINERS
=
%w[tauriedavis rverissimo]
.
freeze
NO_REVIEWER
=
'No reviewer available'
.
freeze
def
mention_single_codebase_approvers
frontend_maintainers
=
%w(@filipa @iamphill @psimyn @sarahghp @mishunov)
ux_maintainers
=
%w(@tauriedavis @rverissimo)
canonical_branch_name
=
roulette
.
canonical_branch_name
(
gitlab
.
mr_json
[
'source_branch'
])
random
=
roulette
.
new_random
(
canonical_branch_name
)
frontend_maintainers
=
helper
.
new_teammates
(
FRONTEND_MAINTAINERS
)
ux_maintainers
=
helper
.
new_teammates
(
UX_MAINTAINERS
)
rows
=
[]
users
=
[]
if
gitlab
.
mr_labels
.
include?
(
'frontend'
)
frontend_maintainer
=
frontend_maintainers
.
sample
frontend_maintainer
=
roulette
.
spin_for_person
(
frontend_maintainers
,
random:
random
)
rows
<<
"| ~frontend | `
#{
frontend_maintainer
}
`"
users
<<
frontend_maintainer
rows
<<
"| ~frontend |
#{
frontend_maintainer
&
.
markdown_name
||
NO_REVIEWER
}
"
end
if
gitlab
.
mr_labels
.
include?
(
'UX'
)
ux_maintainers
=
ux_maintainers
.
sample
ux_maintainers
=
roulette
.
spin_for_person
(
ux_maintainers
,
random:
random
)
rows
<<
"| ~UX | `
#{
ux_maintainers
}
`"
users
<<
ux_maintainers
rows
<<
"| ~UX |
#{
ux_maintainers
&
.
markdown_name
||
NO_REVIEWER
}
"
end
if
rows
.
empty?
backup_maintainer
=
frontend_maintainers
.
sample
rows
<<
"| ~frontend / ~UX | `
#{
backup_maintainer
}
`"
users
<<
backup_maintainer
rows
<<
"| ~frontend / ~UX |
#{
backup_maintainer
.
markdown_name
}
"
end
markdown
(
<<~
MARKDOWN
.
strip
)
...
...
danger/roulette/Dangerfile
View file @
745ba70d
...
...
@@ -31,6 +31,9 @@ Please consider creating a merge request to
for them.
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
...
...
@@ -49,7 +52,7 @@ def spin_for_category(team, project, category, branch_name)
reviewer
=
roulette
.
spin_for_person
(
reviewers
+
traintainers
+
traintainers
,
random:
random
)
maintainer
=
roulette
.
spin_for_person
(
maintainers
,
random:
random
)
"|
#{
helper
.
label_for_category
(
category
)
}
|
#{
reviewer
&
.
markdown_name
}
|
#{
maintainer
&
.
markdown_name
}
|"
"|
#{
helper
.
label_for_category
(
category
)
}
|
#{
reviewer
&
.
markdown_name
||
NO_REVIEWER
}
|
#{
maintainer
&
.
markdown_name
||
NO_MAINTAINER
}
|"
end
def
build_list
(
items
)
...
...
@@ -85,9 +88,6 @@ if changes.any? && !gitlab.mr_labels.include?('single codebase') && !gitlab.mr_l
[]
end
# Exclude the MR author from the team for selection purposes
team
.
delete_if
{
|
teammate
|
teammate
.
username
==
gitlab
.
mr_author
}
project
=
helper
.
project_name
unknown
=
changes
.
fetch
(
:unknown
,
[])
...
...
danger/single_codebase/Dangerfile
View file @
745ba70d
def
new_teammates
(
usernames
)
usernames
.
map
{
|
u
|
::
Gitlab
::
Danger
::
Teammate
.
new
(
'username'
=>
u
)
}
end
FRONTEND_MAINTAINERS
=
%w[filipa iamphill]
.
freeze
BACKEND_MAINTAINERS
=
%w[rspeicher rymai yorickpeterse godfat]
.
freeze
NO_REVIEWER
=
'No reviewer available'
.
freeze
def
mention_single_codebase_approvers
canonical_branch_name
=
...
...
@@ -8,8 +8,8 @@ def mention_single_codebase_approvers
random
=
roulette
.
new_random
(
canonical_branch_name
)
frontend_maintainers
=
new_teammates
(
%w[filipa iamphill]
)
backend_maintainers
=
new_teammates
(
%w[rspeicher rymai yorickpeterse godfat]
)
frontend_maintainers
=
helper
.
new_teammates
(
FRONTEND_MAINTAINERS
)
backend_maintainers
=
helper
.
new_teammates
(
BACKEND_MAINTAINERS
)
rows
=
[]
...
...
@@ -17,14 +17,14 @@ def mention_single_codebase_approvers
frontend_maintainer
=
roulette
.
spin_for_person
(
frontend_maintainers
,
random:
random
)
rows
<<
"| ~frontend |
#{
frontend_maintainer
.
markdown_name
}
"
rows
<<
"| ~frontend |
#{
frontend_maintainer
&
.
markdown_name
||
NO_REVIEWER
}
"
end
if
gitlab
.
mr_labels
.
include?
(
'backend'
)
backend_maintainer
=
roulette
.
spin_for_person
(
backend_maintainers
,
random:
random
)
rows
<<
"| ~backend |
#{
backend_maintainer
.
markdown_name
}
"
rows
<<
"| ~backend |
#{
backend_maintainer
&
.
markdown_name
||
NO_REVIEWER
}
"
end
if
rows
.
empty?
...
...
lib/gitlab/danger/helper.rb
View file @
745ba70d
...
...
@@ -124,6 +124,10 @@ module Gitlab
%r{
\.
(md|txt)
\z
}
=>
:none
,
# To reinstate roulette for documentation, set to `:docs`.
%r{
\.
js
\z
}
=>
:frontend
}.
freeze
def
new_teammates
(
usernames
)
usernames
.
map
{
|
u
|
Gitlab
::
Danger
::
Teammate
.
new
(
'username'
=>
u
)
}
end
end
end
end
lib/gitlab/danger/roulette.rb
View file @
745ba70d
...
...
@@ -45,22 +45,20 @@ module Gitlab
# Known issue: If someone is rejected due to OOO, and then becomes not OOO, the
# selection will change on next spin
def
spin_for_person
(
people
,
random
:)
person
=
nil
people
=
people
.
dup
people
.
size
.
times
do
person
=
people
.
sample
(
random:
random
)
people
.
shuffle
(
random:
random
)
.
find
(
&
method
(
:valid_person?
))
end
break
person
unless
out_of_office?
(
person
)
private
people
-=
[
person
]
def
valid_person?
(
person
)
!
mr_author?
(
person
)
&&
!
out_of_office?
(
person
)
end
person
def
mr_author?
(
person
)
person
.
username
==
gitlab
.
mr_author
end
private
def
out_of_office?
(
person
)
username
=
CGI
.
escape
(
person
.
username
)
api_endpoint
=
"https://gitlab.com/api/v4/users/
#{
username
}
/status"
...
...
spec/lib/gitlab/danger/helper_spec.rb
View file @
745ba70d
...
...
@@ -202,4 +202,14 @@ describe Gitlab::Danger::Helper do
it
{
is_expected
.
to
eq
(
expected_label
)
}
end
end
describe
'#new_teammates'
do
it
'returns an array of Teammate'
do
usernames
=
%w[filipa iamphil]
teammates
=
helper
.
new_teammates
(
usernames
)
expect
(
teammates
.
map
(
&
:username
)).
to
eq
(
usernames
)
end
end
end
spec/lib/gitlab/danger/roulette_spec.rb
View file @
745ba70d
...
...
@@ -98,4 +98,47 @@ describe Gitlab::Danger::Roulette do
is_expected
.
to
contain_exactly
(
ce_teammate_matcher
)
end
end
describe
'#spin_for_person'
do
let
(
:person1
)
{
Gitlab
::
Danger
::
Teammate
.
new
(
'username'
=>
'rymai'
)
}
let
(
:person2
)
{
Gitlab
::
Danger
::
Teammate
.
new
(
'username'
=>
'godfat'
)
}
let
(
:author
)
{
Gitlab
::
Danger
::
Teammate
.
new
(
'username'
=>
'filipa'
)
}
let
(
:ooo
)
{
Gitlab
::
Danger
::
Teammate
.
new
(
'username'
=>
'jacopo-beschi'
)
}
before
do
stub_person_message
(
person1
,
'making GitLab magic'
)
stub_person_message
(
person2
,
'making GitLab magic'
)
stub_person_message
(
ooo
,
'OOO till 15th'
)
# we don't stub Filipa, as she is the author and
# we should not fire request checking for her
allow
(
subject
).
to
receive_message_chain
(
:gitlab
,
:mr_author
).
and_return
(
author
.
username
)
end
it
'returns a random person'
do
persons
=
[
person1
,
person2
]
selected
=
subject
.
spin_for_person
(
persons
,
random:
Random
.
new
)
expect
(
selected
.
username
).
to
be_in
(
persons
.
map
(
&
:username
))
end
it
'excludes OOO persons'
do
expect
(
subject
.
spin_for_person
([
ooo
],
random:
Random
.
new
)).
to
be_nil
end
it
'excludes mr.author'
do
expect
(
subject
.
spin_for_person
([
author
],
random:
Random
.
new
)).
to
be_nil
end
private
def
stub_person_message
(
person
,
message
)
body
=
{
message:
message
}.
to_json
WebMock
.
stub_request
(
:get
,
"https://gitlab.com/api/v4/users/
#{
person
.
username
}
/status"
)
.
to_return
(
body:
body
)
end
end
end
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