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
a5f5a27d
Commit
a5f5a27d
authored
Oct 05, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include group runners in Project#any_runners?
parent
743c3227
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
32 deletions
+73
-32
app/models/project.rb
app/models/project.rb
+12
-6
spec/models/project_spec.rb
spec/models/project_spec.rb
+61
-26
No files found.
app/models/project.rb
View file @
a5f5a27d
...
...
@@ -1298,20 +1298,26 @@ class Project < ActiveRecord::Base
project_feature
.
update_attribute
(
:builds_access_level
,
ProjectFeature
::
ENABLED
)
end
def
shared_runners_available?
shared_runners_enabled?
end
def
shared_runners
@shared_runners
||=
shared_runners_
available
?
?
Ci
::
Runner
.
shared
:
Ci
::
Runner
.
none
@shared_runners
||=
shared_runners_
enabled
?
?
Ci
::
Runner
.
shared
:
Ci
::
Runner
.
none
end
def
active_shared_runners
@active_shared_runners
||=
shared_runners
.
active
end
def
group_runners
@group_runners
||=
group_runners_enabled?
?
Ci
::
Runner
.
belonging_to_group
(
self
.
id
)
:
Ci
::
Runner
.
none
end
def
active_group_runners
@active_group_runners
||=
group_runners
.
active
end
def
any_runners?
(
&
block
)
active_runners
.
any?
(
&
block
)
||
active_shared_runners
.
any?
(
&
block
)
active_runners
.
any?
(
&
block
)
||
active_shared_runners
.
any?
(
&
block
)
||
active_group_runners
.
any?
(
&
block
)
end
def
valid_runners_token?
(
token
)
...
...
spec/models/project_spec.rb
View file @
a5f5a27d
...
...
@@ -1139,44 +1139,79 @@ describe Project do
end
describe
'#any_runners'
do
let
(
:project
)
{
create
(
:project
,
shared_runners_enabled:
shared_runners_enabled
)
}
let
(
:specific_runner
)
{
create
(
:ci_runner
)
}
let
(
:shared_runner
)
{
create
(
:ci_runner
,
:shared
)
}
context
'shared runners'
do
let
(
:project
)
{
create
:project
,
shared_runners_enabled:
shared_runners_enabled
}
let
(
:specific_runner
)
{
create
:ci_runner
}
let
(
:shared_runner
)
{
create
:ci_runner
,
:shared
}
context
'for shared runners disabled'
do
let
(
:shared_runners_enabled
)
{
false
}
context
'for shared runners disabled'
do
let
(
:shared_runners_enabled
)
{
false
}
it
'has no runners available'
do
expect
(
project
.
any_runners?
).
to
be_falsey
end
it
'has no runners available'
do
expect
(
project
.
any_runners?
).
to
be_falsey
end
it
'has a specific runner'
do
project
.
runners
<<
specific_runner
expect
(
project
.
any_runners?
).
to
be_truthy
end
it
'has a specific runner'
do
project
.
runners
<<
specific_runner
expect
(
project
.
any_runners?
).
to
be_truthy
end
it
'has a shared runner, but they are prohibited to use'
do
shared_runner
expect
(
project
.
any_runners?
).
to
be_falsey
end
it
'has a shared runner, but they are prohibited to use'
do
shared_runner
expect
(
project
.
any_runners?
).
to
be_falsey
it
'checks the presence of specific runner'
do
project
.
runners
<<
specific_runner
expect
(
project
.
any_runners?
{
|
runner
|
runner
==
specific_runner
}).
to
be_truthy
end
end
it
'checks the presence of specific runner'
do
project
.
runners
<<
specific_runner
expect
(
project
.
any_runners?
{
|
runner
|
runner
==
specific_runner
}).
to
be_truthy
context
'for shared runners enabled'
do
let
(
:shared_runners_enabled
)
{
true
}
it
'has a shared runner'
do
shared_runner
expect
(
project
.
any_runners?
).
to
be_truthy
end
it
'checks the presence of shared runner'
do
shared_runner
expect
(
project
.
any_runners?
{
|
runner
|
runner
==
shared_runner
}).
to
be_truthy
end
end
end
context
'for shared runners enabled'
do
let
(
:shared_runners_enabled
)
{
true
}
context
'group runners'
do
let
(
:project
)
{
create
:project
,
group_runners_enabled:
group_runners_enabled
}
let
(
:group
)
{
create
:group
,
projects:
[
project
]
}
let
(
:group_runner
)
{
create
:ci_runner
,
groups:
[
group
]
}
context
'for group runners disabled'
do
let
(
:group_runners_enabled
)
{
false
}
it
'has a shared runner'
do
shared_runner
expect
(
project
.
any_runners?
).
to
be_truthy
it
'has no runners available'
do
expect
(
project
.
any_runners?
).
to
be_falsey
end
it
'has a group runner, but they are prohibited to use'
do
group_runner
expect
(
project
.
any_runners?
).
to
be_falsey
end
end
it
'checks the presence of shared runner'
do
shared_runner
expect
(
project
.
any_runners?
{
|
runner
|
runner
==
shared_runner
}).
to
be_truthy
context
'for group runners enabled'
do
let
(
:group_runners_enabled
)
{
true
}
it
'has a group runner'
do
group_runner
expect
(
project
.
any_runners?
).
to
be_truthy
end
it
'checks the presence of group runner'
do
group_runner
expect
(
project
.
any_runners?
{
|
runner
|
runner
==
group_runner
}).
to
be_truthy
end
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