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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
74399a90
Commit
74399a90
authored
May 24, 2019
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show Test Automation Engineer for spec/feature as
reviewers.
parent
deb0c1db
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
89 additions
and
21 deletions
+89
-21
danger/roulette/Dangerfile
danger/roulette/Dangerfile
+7
-3
lib/gitlab/danger/helper.rb
lib/gitlab/danger/helper.rb
+3
-1
lib/gitlab/danger/teammate.rb
lib/gitlab/danger/teammate.rb
+20
-7
spec/features/admin/admin_appearance_spec.rb
spec/features/admin/admin_appearance_spec.rb
+2
-0
spec/features/atom/dashboard_issues_spec.rb
spec/features/atom/dashboard_issues_spec.rb
+2
-0
spec/features/groups/merge_requests_spec.rb
spec/features/groups/merge_requests_spec.rb
+2
-0
spec/features/instance_statistics/conversational_development_index_spec.rb
...tance_statistics/conversational_development_index_spec.rb
+2
-0
spec/features/issues_spec.rb
spec/features/issues_spec.rb
+2
-0
spec/features/merge_request/user_merges_merge_request_spec.rb
.../features/merge_request/user_merges_merge_request_spec.rb
+2
-0
spec/features/project_variables_spec.rb
spec/features/project_variables_spec.rb
+2
-0
spec/features/projects/clusters_spec.rb
spec/features/projects/clusters_spec.rb
+2
-0
spec/features/projects/pipelines/pipeline_spec.rb
spec/features/projects/pipelines/pipeline_spec.rb
+2
-0
spec/features/projects_spec.rb
spec/features/projects_spec.rb
+2
-0
spec/features/security/profile_access_spec.rb
spec/features/security/profile_access_spec.rb
+2
-0
spec/lib/gitlab/danger/teammate_spec.rb
spec/lib/gitlab/danger/teammate_spec.rb
+37
-10
No files found.
danger/roulette/Dangerfile
View file @
74399a90
...
...
@@ -33,10 +33,14 @@ MARKDOWN
def
spin_for_category
(
team
,
project
,
category
,
branch_name
)
random
=
roulette
.
new_random
(
branch_name
)
labels
=
gitlab
.
mr_labels
reviewers
=
team
.
select
{
|
member
|
member
.
reviewer?
(
project
,
category
)
}
traintainers
=
team
.
select
{
|
member
|
member
.
traintainer?
(
project
,
category
)
}
maintainers
=
team
.
select
{
|
member
|
member
.
maintainer?
(
project
,
category
)
}
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
end
# TODO: take CODEOWNERS into account?
# https://gitlab.com/gitlab-org/gitlab-ce/issues/57653
...
...
lib/gitlab/danger/helper.rb
View file @
74399a90
...
...
@@ -72,7 +72,8 @@ module Gitlab
CATEGORY_LABELS
=
{
docs:
"~Documentation"
,
# Docs are reviewed along DevOps stages, so don't need roulette for now.
none:
""
,
qa:
"~QA"
qa:
"~QA"
,
test:
"~test for `spec/features/*`"
}.
freeze
CATEGORIES
=
{
%r{
\A
doc/}
=>
:none
,
# To reinstate roulette for documentation, set to `:docs`.
...
...
@@ -104,6 +105,7 @@ module Gitlab
%r{
\A
(ee/)?app/(?!assets|views)[^/]+}
=>
:backend
,
%r{
\A
(ee/)?(bin|config|danger|generator_templates|lib|rubocop|scripts)/}
=>
: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
,
...
...
lib/gitlab/danger/teammate.rb
View file @
74399a90
...
...
@@ -3,11 +3,12 @@
module
Gitlab
module
Danger
class
Teammate
attr_reader
:name
,
:username
,
:projects
attr_reader
:name
,
:username
,
:
role
,
:
projects
def
initialize
(
options
=
{})
@username
=
options
[
'username'
]
@name
=
options
[
'name'
]
||
@username
@role
=
options
[
'role'
]
@projects
=
options
[
'projects'
]
end
...
...
@@ -20,20 +21,32 @@ module Gitlab
end
# Traintainers also count as reviewers
def
reviewer?
(
project
,
category
)
capabilities
(
project
).
include?
(
"reviewer
#{
category
}
"
)
||
traintainer?
(
project
,
category
)
def
reviewer?
(
project
,
category
,
labels
)
has_capability?
(
project
,
category
,
:reviewer
,
labels
)
||
traintainer?
(
project
,
category
,
labels
)
end
def
traintainer?
(
project
,
category
)
capabilities
(
project
).
include?
(
"trainee_maintainer
#{
category
}
"
)
def
traintainer?
(
project
,
category
,
labels
)
has_capability?
(
project
,
category
,
:trainee_maintainer
,
labels
)
end
def
maintainer?
(
project
,
category
)
capabilities
(
project
).
include?
(
"maintainer
#{
category
}
"
)
def
maintainer?
(
project
,
category
,
labels
)
has_capability?
(
project
,
category
,
:maintainer
,
labels
)
end
private
def
has_capability?
(
project
,
category
,
kind
,
labels
)
case
category
when
:test
area
=
role
[
/Test Automation Engineer, (\w+)/
,
1
]
area
&&
labels
.
any?
(
area
)
if
kind
==
:reviewer
else
capabilities
(
project
).
include?
(
"
#{
kind
}
#{
category
}
"
)
end
end
def
capabilities
(
project
)
Array
(
projects
.
fetch
(
project
,
[]))
end
...
...
spec/features/admin/admin_appearance_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
'spec_helper'
describe
'Admin Appearance'
do
...
...
spec/features/atom/dashboard_issues_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
'spec_helper'
describe
"Dashboard Issues Feed"
do
...
...
spec/features/groups/merge_requests_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
'spec_helper'
describe
'Group merge requests page'
do
...
...
spec/features/instance_statistics/conversational_development_index_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
'spec_helper'
describe
'Conversational Development Index'
do
...
...
spec/features/issues_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
'spec_helper'
describe
'Issues'
do
...
...
spec/features/merge_request/user_merges_merge_request_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
"spec_helper"
describe
"User merges a merge request"
,
:js
do
...
...
spec/features/project_variables_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
'spec_helper'
describe
'Project variables'
,
:js
do
...
...
spec/features/projects/clusters_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
'spec_helper'
describe
'Clusters'
,
:js
do
...
...
spec/features/projects/pipelines/pipeline_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
'spec_helper'
describe
'Pipeline'
,
:js
do
...
...
spec/features/projects_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
'spec_helper'
describe
'Project'
do
...
...
spec/features/security/profile_access_spec.rb
View file @
74399a90
# frozen_string_literal: true
require
'spec_helper'
describe
"Profile access"
do
...
...
spec/lib/gitlab/danger/teammate_spec.rb
View file @
74399a90
...
...
@@ -5,39 +5,66 @@ require 'fast_spec_helper'
require
'gitlab/danger/teammate'
describe
Gitlab
::
Danger
::
Teammate
do
subject
{
described_class
.
new
({
'projects'
=>
projects
})
}
subject
{
described_class
.
new
(
options
)
}
let
(
:options
)
{
{
'projects'
=>
projects
,
'role'
=>
role
}
}
let
(
:projects
)
{
{
project
=>
capabilities
}
}
let
(
:role
)
{
'Engineer, Manage'
}
let
(
:labels
)
{
[]
}
let
(
:project
)
{
double
}
describe
'multiple roles project project
'
do
let
(
:capabilities
)
{
[
'reviewer backend'
,
'maintainer frontend'
,
'trainee_maintainer
database
'
]
}
context
'when having multiple capabilities
'
do
let
(
:capabilities
)
{
[
'reviewer backend'
,
'maintainer frontend'
,
'trainee_maintainer
qa
'
]
}
it
'#reviewer? supports multiple roles per project'
do
expect
(
subject
.
reviewer?
(
project
,
:backend
)).
to
be_truthy
expect
(
subject
.
reviewer?
(
project
,
:backend
,
labels
)).
to
be_truthy
end
it
'#traintainer? supports multiple roles per project'
do
expect
(
subject
.
traintainer?
(
project
,
:
database
)).
to
be_truthy
expect
(
subject
.
traintainer?
(
project
,
:
qa
,
labels
)).
to
be_truthy
end
it
'#maintainer? supports multiple roles per project'
do
expect
(
subject
.
maintainer?
(
project
,
:frontend
)).
to
be_truthy
expect
(
subject
.
maintainer?
(
project
,
:frontend
,
labels
)).
to
be_truthy
end
context
'when labels contain Create and the category is test'
do
let
(
:labels
)
{
[
'Create'
]
}
context
'when role is Test Automation Engineer, Create'
do
let
(
:role
)
{
'Test Automation Engineer, Create'
}
it
'#reviewer? returns true'
do
expect
(
subject
.
reviewer?
(
project
,
:test
,
labels
)).
to
be_truthy
end
it
'#maintainer? returns false'
do
expect
(
subject
.
maintainer?
(
project
,
:test
,
labels
)).
to
be_falsey
end
end
context
'when role is Test Automation Engineer, Manage'
do
let
(
:role
)
{
'Test Automation Engineer, Manage'
}
it
'#reviewer? returns false'
do
expect
(
subject
.
reviewer?
(
project
,
:test
,
labels
)).
to
be_falsey
end
end
end
end
describe
'one role project project
'
do
context
'when having single capability
'
do
let
(
:capabilities
)
{
'reviewer backend'
}
it
'#reviewer? supports one role per project'
do
expect
(
subject
.
reviewer?
(
project
,
:backend
)).
to
be_truthy
expect
(
subject
.
reviewer?
(
project
,
:backend
,
labels
)).
to
be_truthy
end
it
'#traintainer? supports one role per project'
do
expect
(
subject
.
traintainer?
(
project
,
:database
)).
to
be_falsey
expect
(
subject
.
traintainer?
(
project
,
:database
,
labels
)).
to
be_falsey
end
it
'#maintainer? supports one role per project'
do
expect
(
subject
.
maintainer?
(
project
,
:frontend
)).
to
be_falsey
expect
(
subject
.
maintainer?
(
project
,
:frontend
,
labels
)).
to
be_falsey
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