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
9b836b83
Commit
9b836b83
authored
Oct 05, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support group hierarchies for group runners
parent
6bd3cb04
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
app/models/ci/runner.rb
app/models/ci/runner.rb
+4
-7
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+9
-0
No files found.
app/models/ci/runner.rb
View file @
9b836b83
...
...
@@ -31,13 +31,10 @@ module Ci
joins
(
:runner_projects
).
where
(
ci_runner_projects:
{
project_id:
project_id
})
}
scope
:belonging_to_group
,
->
(
project_id
)
{
joins
(
%{
INNER JOIN ci_runner_groups ON ci_runner_groups.runner_id = ci_runners.id
INNER JOIN namespaces ON namespaces.id = ci_runner_groups.group_id
INNER JOIN projects ON projects.namespace_id = namespaces.id
}
).
where
(
'projects.id = :project_id'
,
project_id:
project_id
)
project_groups
=
::
Group
.
joins
(
:projects
).
where
(
projects:
{
id:
project_id
})
hierarchy_groups
=
Gitlab
::
GroupHierarchy
.
new
(
project_groups
).
base_and_ancestors
joins
(
:groups
).
where
(
namespaces:
{
id:
hierarchy_groups
})
}
scope
:owned_or_shared
,
->
(
project_id
)
do
...
...
spec/models/ci/runner_spec.rb
View file @
9b836b83
...
...
@@ -93,6 +93,15 @@ describe Ci::Runner do
expect
(
described_class
.
belonging_to_group
(
specific_project
.
id
)).
to
eq
[
specific_runner
]
end
it
'returns the group runner from a parent group'
do
parent_group
=
create
:group
group
=
create
:group
,
parent:
parent_group
project
=
create
:project
,
group:
group
runner
=
create
:ci_runner
,
:specific
,
groups:
[
parent_group
]
expect
(
described_class
.
belonging_to_group
(
project
.
id
)).
to
eq
[
runner
]
end
end
describe
'.owned_or_shared'
do
...
...
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