Commit b14c20b3 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch '339186-fj-use-runner-linear-scopes' into 'master'

Replace Ci::Runner with linear scopes

See merge request gitlab-org/gitlab!70385
parents 4a71cb34 af61def7
......@@ -84,7 +84,11 @@ module Ci
groups = ::Group.where(id: group_id)
if include_ancestors
groups = Gitlab::ObjectHierarchy.new(groups).base_and_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
joins(:runner_namespaces)
......@@ -106,7 +110,11 @@ module Ci
scope :belonging_to_parent_group_of_project, -> (project_id) {
project_groups = ::Group.joins(:projects).where(projects: { id: project_id })
hierarchy_groups = Gitlab::ObjectHierarchy.new(project_groups).base_and_ancestors
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_groups })
......
---
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
......@@ -208,6 +208,7 @@ 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]) }
......@@ -231,6 +232,17 @@ RSpec.describe Ci::Runner do
end
end
it_behaves_like 'returns parent group project runners'
context 'when feature flag :linear_runner_ancestor_scopes is disabled' do
before do
stub_feature_flags(linear_runner_ancestor_scopes: false)
end
it_behaves_like 'returns parent group project runners'
end
end
describe '.owned_or_instance_wide' do
it 'returns a globally shared, a project specific and a group specific runner' do
# group specific
......@@ -1259,6 +1271,7 @@ RSpec.describe Ci::Runner do
end
describe '.belonging_to_group' do
shared_examples 'returns group runners' do
it 'returns the specific group runner' do
group = create(:group)
runner = create(:ci_runner, :group, groups: [group])
......@@ -1286,4 +1299,15 @@ RSpec.describe Ci::Runner do
end
end
end
it_behaves_like 'returns group runners'
context 'when feature flag :linear_runner_ancestor_scopes is disabled' do
before do
stub_feature_flags(linear_runner_ancestor_scopes: false)
end
it_behaves_like 'returns group runners'
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment