Skip to content
代码片段 群组 项目
提交 ace509af 编辑于 作者: Marius Bobin's avatar Marius Bobin
浏览文件

Merge branch...

Merge branch '352830-backend-use-a-reduced-cost-factor-for-contributions-to-oss-plan-projects' into 'master'

Use a reduced cost factor for contributions to OSS plan projects

See merge request gitlab-org/gitlab!96273
No related branches found
No related tags found
无相关合并请求
---
name: ci_cost_factors_narrow_os_contribution_by_plan
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/96273
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/372263
milestone: '15.4'
type: development
group: group::pipeline execution
default_enabled: false
...@@ -50,14 +50,21 @@ def apply_discount(project, runner_cost_factor) ...@@ -50,14 +50,21 @@ def apply_discount(project, runner_cost_factor)
if project.public? if project.public?
cost_factors << PUBLIC_OPEN_SOURCE_PLAN if open_source_plan?(project) cost_factors << PUBLIC_OPEN_SOURCE_PLAN if open_source_plan?(project)
cost_factors << OPEN_SOURCE_CONTRIBUTION if public_fork_source?(project) cost_factors << OPEN_SOURCE_CONTRIBUTION if open_source_project?(project)
end end
cost_factors.min cost_factors.min
end end
def public_fork_source?(project) def open_source_project?(project)
project&.fork_source&.public? fork_source = project&.fork_source
public_fork = fork_source&.public?
if Feature.enabled?(:ci_cost_factors_narrow_os_contribution_by_plan, project)
return public_fork && open_source_plan?(fork_source)
end
public_fork
end end
def open_source_plan?(project) def open_source_plan?(project)
......
...@@ -211,7 +211,25 @@ ...@@ -211,7 +211,25 @@
let(:source_visibility_level) { Gitlab::VisibilityLevel::PUBLIC } let(:source_visibility_level) { Gitlab::VisibilityLevel::PUBLIC }
context 'when the forked source cost factor is lower' do context 'when the forked source cost factor is lower' do
specify { expect(subject).to eq(described_class::OPEN_SOURCE_CONTRIBUTION) } context 'when the forked source plan is open source' do
before do
create(:gitlab_subscription, namespace: project.fork_source.namespace, hosted_plan: create(:opensource_plan))
end
specify { expect(subject).to eq(described_class::OPEN_SOURCE_CONTRIBUTION) }
end
context 'when the plan is not open source' do
specify { expect(subject).to eq(public_cost_factor) }
context 'when the ci_cost_factors_narrow_os_contribution_by_plan flag is disabled' do
before do
stub_feature_flags(ci_cost_factors_narrow_os_contribution_by_plan: false)
end
specify { expect(subject).to eq(described_class::OPEN_SOURCE_CONTRIBUTION) }
end
end
end end
context 'when the runner cost factor is lower' do context 'when the runner cost factor is lower' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册