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
Léo-Paul Géneau
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
Show 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
...
@@ -1298,20 +1298,26 @@ class Project < ActiveRecord::Base
project_feature
.
update_attribute
(
:builds_access_level
,
ProjectFeature
::
ENABLED
)
project_feature
.
update_attribute
(
:builds_access_level
,
ProjectFeature
::
ENABLED
)
end
end
def
shared_runners_available?
shared_runners_enabled?
end
def
shared_runners
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
end
def
active_shared_runners
def
active_shared_runners
@active_shared_runners
||=
shared_runners
.
active
@active_shared_runners
||=
shared_runners
.
active
end
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
)
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
end
def
valid_runners_token?
(
token
)
def
valid_runners_token?
(
token
)
...
...
spec/models/project_spec.rb
View file @
a5f5a27d
...
@@ -1139,9 +1139,10 @@ describe Project do
...
@@ -1139,9 +1139,10 @@ describe Project do
end
end
describe
'#any_runners'
do
describe
'#any_runners'
do
let
(
:project
)
{
create
(
:project
,
shared_runners_enabled:
shared_runners_enabled
)
}
context
'shared runners'
do
let
(
:specific_runner
)
{
create
(
:ci_runner
)
}
let
(
:project
)
{
create
:project
,
shared_runners_enabled:
shared_runners_enabled
}
let
(
:shared_runner
)
{
create
(
:ci_runner
,
:shared
)
}
let
(
:specific_runner
)
{
create
:ci_runner
}
let
(
:shared_runner
)
{
create
:ci_runner
,
:shared
}
context
'for shared runners disabled'
do
context
'for shared runners disabled'
do
let
(
:shared_runners_enabled
)
{
false
}
let
(
:shared_runners_enabled
)
{
false
}
...
@@ -1181,6 +1182,40 @@ describe Project do
...
@@ -1181,6 +1182,40 @@ describe Project do
end
end
end
end
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 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
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
describe
'#shared_runners'
do
describe
'#shared_runners'
do
let!
(
:runner
)
{
create
(
:ci_runner
,
:shared
)
}
let!
(
:runner
)
{
create
(
:ci_runner
,
:shared
)
}
...
...
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