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
11d49cd2
Commit
11d49cd2
authored
Dec 07, 2021
by
Francisco Javier López
Committed by
Dylan Griffith
Dec 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable Runner ancestor scopes
parent
6b591ca2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
49 deletions
+17
-49
app/models/ci/runner.rb
app/models/ci/runner.rb
+2
-14
config/feature_flags/development/linear_runner_ancestor_scopes.yml
...ature_flags/development/linear_runner_ancestor_scopes.yml
+0
-8
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+15
-27
No files found.
app/models/ci/runner.rb
View file @
11d49cd2
...
...
@@ -81,14 +81,7 @@ module Ci
scope
:belonging_to_group
,
->
(
group_id
,
include_ancestors:
false
)
{
groups
=
::
Group
.
where
(
id:
group_id
)
if
include_ancestors
groups
=
if
Feature
.
enabled?
(
:linear_runner_ancestor_scopes
,
default_enabled: :yaml
)
groups
.
self_and_ancestors
else
Gitlab
::
ObjectHierarchy
.
new
(
groups
).
base_and_ancestors
end
end
groups
=
groups
.
self_and_ancestors
if
include_ancestors
joins
(
:runner_namespaces
)
.
where
(
ci_runner_namespaces:
{
namespace_id:
groups
})
...
...
@@ -109,14 +102,9 @@ module Ci
scope
:belonging_to_parent_group_of_project
,
->
(
project_id
)
{
project_groups
=
::
Group
.
joins
(
:projects
).
where
(
projects:
{
id:
project_id
})
hierarchy_groups
=
if
Feature
.
enabled?
(
:linear_runner_ancestor_scopes
,
default_enabled: :yaml
)
project_groups
.
self_and_ancestors
.
as_ids
else
Gitlab
::
ObjectHierarchy
.
new
(
project_groups
).
base_and_ancestors
end
joins
(
:groups
)
.
where
(
namespaces:
{
id:
hierarchy_group
s
})
.
where
(
namespaces:
{
id:
project_groups
.
self_and_ancestors
.
as_id
s
})
.
allow_cross_joins_across_databases
(
url:
'https://gitlab.com/gitlab-org/gitlab/-/issues/336433'
)
}
...
...
config/feature_flags/development/linear_runner_ancestor_scopes.yml
deleted
100644 → 0
View file @
6b591ca2
---
name
:
linear_runner_ancestor_scopes
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70385
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/341114
milestone
:
'
14.6'
type
:
development
group
:
group::access
default_enabled
:
false
spec/models/ci/runner_spec.rb
View file @
11d49cd2
...
...
@@ -204,38 +204,26 @@ RSpec.describe Ci::Runner do
end
describe
'.belonging_to_parent_group_of_project'
do
shared_examples
'returns parent group project runners'
do
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
group
])
}
let!
(
:unrelated_group
)
{
create
(
:group
)
}
let!
(
:unrelated_project
)
{
create
(
:project
,
group:
unrelated_group
)
}
let!
(
:unrelated_runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
unrelated_group
])
}
it
'returns the specific group runner'
do
expect
(
described_class
.
belonging_to_parent_group_of_project
(
project
.
id
)).
to
contain_exactly
(
runner
)
end
context
'with a parent group with a runner'
do
let
(
:runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
parent_group
])
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:group
)
{
create
(
:group
,
parent:
parent_group
)
}
let
(
:parent_group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
group
])
}
let!
(
:unrelated_group
)
{
create
(
:group
)
}
let!
(
:unrelated_project
)
{
create
(
:project
,
group:
unrelated_group
)
}
let!
(
:unrelated_runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
unrelated_group
])
}
it
'returns the group runner from the parent group'
do
expect
(
described_class
.
belonging_to_parent_group_of_project
(
project
.
id
)).
to
contain_exactly
(
runner
)
end
end
it
'returns the specific group runner'
do
expect
(
described_class
.
belonging_to_parent_group_of_project
(
project
.
id
)).
to
contain_exactly
(
runner
)
end
it_behaves_like
'returns parent group project runners'
context
'with a parent group with a runner'
do
let
(
:runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
parent_group
])
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:group
)
{
create
(
:group
,
parent:
parent_group
)
}
let
(
:parent_group
)
{
create
(
:group
)
}
context
'when feature flag :linear_runner_ancestor_scopes is disabled'
do
before
do
stub_feature_flags
(
linear_runner_ancestor_scopes:
false
)
it
'returns the group runner from the parent group'
do
expect
(
described_class
.
belonging_to_parent_group_of_project
(
project
.
id
)).
to
contain_exactly
(
runner
)
end
it_behaves_like
'returns parent group project runners'
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