Commit 6177bc1d authored by Douwe Maan's avatar Douwe Maan

Merge branch 'remove_create_deployment_from_build_success_worker' into 'master'

Remove deprecated call in BuildSuccessWorker

Closes #63622

See merge request gitlab-org/gitlab-ce!29958
parents 74c8f784 26b05729
...@@ -9,7 +9,6 @@ class BuildSuccessWorker ...@@ -9,7 +9,6 @@ class BuildSuccessWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id) def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build| Ci::Build.find_by(id: build_id).try do |build|
create_deployment(build) if build.has_environment?
stop_environment(build) if build.stops_environment? stop_environment(build) if build.stops_environment?
end end
end end
...@@ -17,17 +16,6 @@ class BuildSuccessWorker ...@@ -17,17 +16,6 @@ class BuildSuccessWorker
private private
##
# Deprecated:
# As of 11.5, we started creating a deployment record when ci_builds record is created.
# Therefore we no longer need to create a deployment, after a build succeeded.
# We're leaving this code for the transition period, but we can remove this code in 11.6.
def create_deployment(build)
build.create_deployment.try do |deployment|
deployment.succeed
end
end
## ##
# TODO: This should be processed in DeploymentSuccessWorker once we started storing `action` value in `deployments` records # TODO: This should be processed in DeploymentSuccessWorker once we started storing `action` value in `deployments` records
def stop_environment(build) def stop_environment(build)
......
...@@ -6,51 +6,7 @@ describe BuildSuccessWorker do ...@@ -6,51 +6,7 @@ describe BuildSuccessWorker do
describe '#perform' do describe '#perform' do
subject { described_class.new.perform(build.id) } subject { described_class.new.perform(build.id) }
before do
allow_any_instance_of(Deployment).to receive(:create_ref)
end
context 'when build exists' do context 'when build exists' do
context 'when deployment was not created with the build creation' do # An edge case during the transition period
let!(:build) { create(:ci_build, :deploy_to_production) }
before do
allow(Deployments::FinishedWorker).to receive(:perform_async)
Deployment.delete_all
build.reload
end
it 'creates a successful deployment' do
expect(build).not_to be_has_deployment
subject
build.reload
expect(build).to be_has_deployment
expect(build.deployment).to be_success
end
end
context 'when deployment was created with the build creation' do # Counter part of the above edge case
let!(:build) { create(:ci_build, :deploy_to_production) }
it 'does not create a new deployment' do
expect(build).to be_has_deployment
expect { subject }.not_to change { Deployment.count }
end
end
context 'when build is not associated with project' do
let!(:build) { create(:ci_build, project: nil) }
it 'does not create deployment' do
subject
expect(build.reload).not_to be_has_deployment
end
end
context 'when the build will stop an environment' do context 'when the build will stop an environment' do
let!(:build) { create(:ci_build, :stop_review_app, environment: environment.name, project: environment.project) } let!(:build) { create(:ci_build, :stop_review_app, environment: environment.name, project: environment.project) }
let(:environment) { create(:environment, state: :available) } let(:environment) { create(:environment, state: :available) }
......
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