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