Commit 6ebe8eaa authored by Sean McGivern's avatar Sean McGivern

Merge branch 'remove-process-method' into 'master'

Remove `Pipeline#process!` method

See merge request gitlab-org/gitlab!20223
parents 6e67f9e8 c95ccfa5
...@@ -599,12 +599,6 @@ module Ci ...@@ -599,12 +599,6 @@ module Ci
project.notes.for_commit_id(sha) project.notes.for_commit_id(sha)
end end
# rubocop: disable CodeReuse/ServiceClass
def process!(trigger_build_ids = nil)
Ci::ProcessPipelineService.new(project, user).execute(self, trigger_build_ids)
end
# rubocop: enable CodeReuse/ServiceClass
def update_status def update_status
retry_optimistic_lock(self) do retry_optimistic_lock(self) do
new_status = latest_builds_status.to_s new_status = latest_builds_status.to_s
......
...@@ -57,7 +57,9 @@ module Ci ...@@ -57,7 +57,9 @@ module Ci
cancel_pending_pipelines if project.auto_cancel_pending_pipelines? cancel_pending_pipelines if project.auto_cancel_pending_pipelines?
pipeline_created_counter.increment(source: source) pipeline_created_counter.increment(source: source)
pipeline.process! Ci::ProcessPipelineService
.new(pipeline)
.execute
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module Ci module Ci
class ProcessPipelineService < BaseService class ProcessPipelineService
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
attr_reader :pipeline attr_reader :pipeline
def execute(pipeline, trigger_build_ids = nil) def initialize(pipeline)
@pipeline = pipeline @pipeline = pipeline
end
def execute(trigger_build_ids = nil)
update_retried update_retried
success = process_stages_without_needs success = process_stages_without_needs
...@@ -72,7 +74,7 @@ module Ci ...@@ -72,7 +74,7 @@ module Ci
def process_build(build, current_status) def process_build(build, current_status)
Gitlab::OptimisticLocking.retry_lock(build) do |subject| Gitlab::OptimisticLocking.retry_lock(build) do |subject|
Ci::ProcessBuildService.new(project, @user) Ci::ProcessBuildService.new(project, build.user)
.execute(subject, current_status) .execute(subject, current_status)
end end
end end
...@@ -129,5 +131,9 @@ module Ci ...@@ -129,5 +131,9 @@ module Ci
.update_all(retried: true) if latest_statuses.any? .update_all(retried: true) if latest_statuses.any?
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def project
pipeline.project
end
end end
end end
...@@ -24,7 +24,9 @@ module Ci ...@@ -24,7 +24,9 @@ module Ci
.new(project, current_user) .new(project, current_user)
.close_all(pipeline) .close_all(pipeline)
pipeline.process! Ci::ProcessPipelineService
.new(pipeline)
.execute
end end
end end
end end
...@@ -11,7 +11,9 @@ class PipelineProcessWorker ...@@ -11,7 +11,9 @@ class PipelineProcessWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id, build_ids = nil) def perform(pipeline_id, build_ids = nil)
Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline| Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline|
pipeline.process!(build_ids) Ci::ProcessPipelineService
.new(pipeline)
.execute(build_ids)
end end
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -29,7 +29,11 @@ module Ci ...@@ -29,7 +29,11 @@ module Ci
build_pipeline.tap do |pipeline| build_pipeline.tap do |pipeline|
pipeline.stages << terminal_stage_seed(pipeline).to_resource pipeline.stages << terminal_stage_seed(pipeline).to_resource
pipeline.save! pipeline.save!
pipeline.process!
Ci::ProcessPipelineService
.new(pipeline)
.execute
pipeline_created_counter.increment(source: :webide) pipeline_created_counter.increment(source: :webide)
end end
end end
......
...@@ -11,7 +11,7 @@ describe Ci::ProcessPipelineService, '#execute' do ...@@ -11,7 +11,7 @@ describe Ci::ProcessPipelineService, '#execute' do
create(:ci_empty_pipeline, ref: 'master', project: project, user: user) create(:ci_empty_pipeline, ref: 'master', project: project, user: user)
end end
let(:service) { described_class.new(pipeline.project, user) } let(:service) { described_class.new(pipeline) }
before do before do
project.add_maintainer(user) project.add_maintainer(user)
...@@ -30,7 +30,7 @@ describe Ci::ProcessPipelineService, '#execute' do ...@@ -30,7 +30,7 @@ describe Ci::ProcessPipelineService, '#execute' do
end end
it 'creates a downstream cross-project pipeline', :sidekiq_might_not_need_inline do it 'creates a downstream cross-project pipeline', :sidekiq_might_not_need_inline do
pipeline.process! service.execute
expect_statuses(%w[test pending], %w[cross created], %w[deploy created]) expect_statuses(%w[test pending], %w[cross created], %w[deploy created])
......
...@@ -1045,7 +1045,9 @@ describe Ci::Pipeline, :mailer do ...@@ -1045,7 +1045,9 @@ describe Ci::Pipeline, :mailer do
stage_idx: 0, stage_idx: 0,
status: 'success') status: 'success')
pipeline.process! Ci::ProcessPipelineService
.new(pipeline)
.execute
end end
it 'ignores the previous state' do it 'ignores the previous state' do
......
...@@ -845,7 +845,7 @@ describe Ci::ProcessPipelineService, '#execute' do ...@@ -845,7 +845,7 @@ describe Ci::ProcessPipelineService, '#execute' do
end end
def process_pipeline def process_pipeline
described_class.new(pipeline.project, user).execute(pipeline) described_class.new(pipeline).execute
end end
def all_builds def all_builds
......
...@@ -223,7 +223,7 @@ describe Ci::RetryPipelineService, '#execute' do ...@@ -223,7 +223,7 @@ describe Ci::RetryPipelineService, '#execute' do
end end
it 'reprocesses the pipeline' do it 'reprocesses the pipeline' do
expect(pipeline).to receive(:process!) expect_any_instance_of(Ci::ProcessPipelineService).to receive(:execute)
service.execute(pipeline) service.execute(pipeline)
end end
......
...@@ -8,7 +8,7 @@ describe PipelineProcessWorker do ...@@ -8,7 +8,7 @@ describe PipelineProcessWorker do
let(:pipeline) { create(:ci_pipeline) } let(:pipeline) { create(:ci_pipeline) }
it 'processes pipeline' do it 'processes pipeline' do
expect_any_instance_of(Ci::Pipeline).to receive(:process!) expect_any_instance_of(Ci::ProcessPipelineService).to receive(:execute)
described_class.new.perform(pipeline.id) described_class.new.perform(pipeline.id)
end end
...@@ -17,7 +17,7 @@ describe PipelineProcessWorker do ...@@ -17,7 +17,7 @@ describe PipelineProcessWorker do
let(:build) { create(:ci_build, pipeline: pipeline, name: 'my-build') } let(:build) { create(:ci_build, pipeline: pipeline, name: 'my-build') }
it 'processes pipeline with a list of builds' do it 'processes pipeline with a list of builds' do
expect_any_instance_of(Ci::Pipeline).to receive(:process!) expect_any_instance_of(Ci::ProcessPipelineService).to receive(:execute)
.with([build.id]) .with([build.id])
described_class.new.perform(pipeline.id, [build.id]) described_class.new.perform(pipeline.id, [build.id])
......
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