Commit f56b96b8 authored by Shinya Maeda's avatar Shinya Maeda

Recreate feature flags for merge trains

This commit recreates a feature flag for merge trains
parent 81cf8a7c
...@@ -8,9 +8,15 @@ module EE ...@@ -8,9 +8,15 @@ module EE
project.feature_available?(:merge_pipelines) && super project.feature_available?(:merge_pipelines) && super
end end
##
# The `disable_merge_trains` feature flag is meant to be used for dogfooding
# pipelines for merged results in gitlab-org/gitlab project.
# This feature flag is never meant to be enabled for the entire instance.
# See more context in https://gitlab.com/gitlab-org/gitlab/issues/200037
def merge_trains_enabled? def merge_trains_enabled?
merge_pipelines_enabled? && project.feature_available?(:merge_trains) && return false if ::Feature.enabled?(:disable_merge_trains, project)
::Feature.enabled?(:merge_trains_enabled, project, default_enabled: true)
merge_pipelines_enabled? && project.feature_available?(:merge_trains)
end end
def merge_pipelines_were_disabled? def merge_pipelines_were_disabled?
......
...@@ -24,6 +24,7 @@ describe 'Merge requests > User merges immediately', :js do ...@@ -24,6 +24,7 @@ describe 'Merge requests > User merges immediately', :js do
end end
before do before do
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_pipelines: true, merge_trains: true) stub_licensed_features(merge_pipelines: true, merge_trains: true)
stub_ci_pipeline_yaml_file(YAML.dump(ci_yaml)) stub_ci_pipeline_yaml_file(YAML.dump(ci_yaml))
......
...@@ -28,6 +28,7 @@ describe 'Two merge requests on a merge train' do ...@@ -28,6 +28,7 @@ describe 'Two merge requests on a merge train' do
end end
before do before do
stub_feature_flags(disable_merge_trains: false)
project.add_maintainer(maintainer_1) project.add_maintainer(maintainer_1)
project.add_maintainer(maintainer_2) project.add_maintainer(maintainer_2)
stub_licensed_features(merge_pipelines: true, merge_trains: true) stub_licensed_features(merge_pipelines: true, merge_trains: true)
......
...@@ -17,6 +17,7 @@ describe 'User adds a merge request to a merge train', :js do ...@@ -17,6 +17,7 @@ describe 'User adds a merge request to a merge train', :js do
end end
before do before do
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_pipelines: true, merge_trains: true) stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.add_maintainer(user) project.add_maintainer(user)
project.update!(merge_pipelines_enabled: true) project.update!(merge_pipelines_enabled: true)
......
...@@ -15,6 +15,7 @@ describe 'User adds to merge train when pipeline succeeds', :js do ...@@ -15,6 +15,7 @@ describe 'User adds to merge train when pipeline succeeds', :js do
let(:pipeline) { merge_request.all_pipelines.first } let(:pipeline) { merge_request.all_pipelines.first }
before do before do
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_pipelines: true, merge_trains: true) stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.add_maintainer(user) project.add_maintainer(user)
project.update!(merge_pipelines_enabled: true) project.update!(merge_pipelines_enabled: true)
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
require 'spec_helper' require 'spec_helper'
describe ProjectCiCdSetting do describe ProjectCiCdSetting do
before do
stub_feature_flags(disable_merge_trains: false)
end
describe '#merge_pipelines_enabled?' do describe '#merge_pipelines_enabled?' do
subject { project.merge_pipelines_enabled? } subject { project.merge_pipelines_enabled? }
......
...@@ -11,6 +11,7 @@ describe MergeRequestPollWidgetEntity do ...@@ -11,6 +11,7 @@ describe MergeRequestPollWidgetEntity do
let(:request) { double('request', current_user: user) } let(:request) { double('request', current_user: user) }
before do before do
stub_feature_flags(disable_merge_trains: false)
project.add_developer(user) project.add_developer(user)
end end
...@@ -33,7 +34,7 @@ describe MergeRequestPollWidgetEntity do ...@@ -33,7 +34,7 @@ describe MergeRequestPollWidgetEntity do
context 'when the merge train feature is disabled' do context 'when the merge train feature is disabled' do
before do before do
stub_feature_flags(merge_trains_enabled: false) stub_feature_flags(disable_merge_trains: true)
end end
it 'does not have merge trains count' do it 'does not have merge trains count' do
......
...@@ -16,6 +16,7 @@ describe AutoMerge::AddToMergeTrainWhenPipelineSucceedsService do ...@@ -16,6 +16,7 @@ describe AutoMerge::AddToMergeTrainWhenPipelineSucceedsService do
let(:pipeline) { merge_request.reload.all_pipelines.first } let(:pipeline) { merge_request.reload.all_pipelines.first }
before do before do
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_trains: true, merge_pipelines: true) stub_licensed_features(merge_trains: true, merge_pipelines: true)
project.add_maintainer(user) project.add_maintainer(user)
project.update!(merge_pipelines_enabled: true) project.update!(merge_pipelines_enabled: true)
......
...@@ -20,6 +20,7 @@ describe AutoMerge::MergeTrainService do ...@@ -20,6 +20,7 @@ describe AutoMerge::MergeTrainService do
allow(AutoMergeProcessWorker).to receive(:perform_async) { } allow(AutoMergeProcessWorker).to receive(:perform_async) { }
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_trains: true, merge_pipelines: true) stub_licensed_features(merge_trains: true, merge_pipelines: true)
project.update!(merge_pipelines_enabled: true) project.update!(merge_pipelines_enabled: true)
end end
...@@ -263,7 +264,7 @@ describe AutoMerge::MergeTrainService do ...@@ -263,7 +264,7 @@ describe AutoMerge::MergeTrainService do
context 'when merge trains project option is disabled' do context 'when merge trains project option is disabled' do
before do before do
stub_feature_flags(merge_trains_enabled: false) stub_feature_flags(disable_merge_trains: true)
end end
it { is_expected.to be_falsy } it { is_expected.to be_falsy }
......
...@@ -9,6 +9,7 @@ describe MergeTrains::CheckStatusService do ...@@ -9,6 +9,7 @@ describe MergeTrains::CheckStatusService do
let(:previous_ref) { 'refs/heads/master' } let(:previous_ref) { 'refs/heads/master' }
before do before do
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_pipelines: true, merge_trains: true) stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.update!(merge_pipelines_enabled: true) project.update!(merge_pipelines_enabled: true)
end end
......
...@@ -9,6 +9,7 @@ describe MergeTrains::CreatePipelineService do ...@@ -9,6 +9,7 @@ describe MergeTrains::CreatePipelineService do
let(:previous_ref) { 'refs/heads/master' } let(:previous_ref) { 'refs/heads/master' }
before do before do
stub_feature_flags(disable_merge_trains: false)
project.add_maintainer(maintainer) project.add_maintainer(maintainer)
stub_licensed_features(merge_pipelines: true, merge_trains: true) stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.update!(merge_pipelines_enabled: true) project.update!(merge_pipelines_enabled: true)
...@@ -35,7 +36,7 @@ describe MergeTrains::CreatePipelineService do ...@@ -35,7 +36,7 @@ describe MergeTrains::CreatePipelineService do
context 'when merge trains option is disabled' do context 'when merge trains option is disabled' do
before do before do
stub_feature_flags(merge_trains_enabled: false) stub_feature_flags(disable_merge_trains: true)
end end
it_behaves_like 'returns an error' do it_behaves_like 'returns an error' do
......
...@@ -9,6 +9,7 @@ describe MergeTrains::RefreshMergeRequestService do ...@@ -9,6 +9,7 @@ describe MergeTrains::RefreshMergeRequestService do
let(:require_recreate) { false } let(:require_recreate) { false }
before do before do
stub_feature_flags(disable_merge_trains: false)
project.add_maintainer(maintainer) project.add_maintainer(maintainer)
stub_licensed_features(merge_pipelines: true, merge_trains: true) stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.update!(merge_pipelines_enabled: true) project.update!(merge_pipelines_enabled: true)
......
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