Commit ca92c9ac authored by Matija Čupić's avatar Matija Čupić

Mirror blocked pipeline status to bridge jobs

Mirrors blocked pipeline statuses (manual and scheduled) to bridge jobs.
parent b1cbad15
......@@ -72,6 +72,10 @@ module HasStatus
def completed_statuses
COMPLETED_STATUSES.map(&:to_sym)
end
def blocked_statuses
BLOCKED_STATUS.map(&:to_sym)
end
end
included do
......
......@@ -97,7 +97,7 @@ module EE
end
end
after_transition any => ::Ci::Pipeline.completed_statuses do |pipeline|
after_transition any => ::Ci::Pipeline.completed_statuses + ::Ci::Pipeline.blocked_statuses do |pipeline|
next unless pipeline.downstream_bridges.any?
pipeline.run_after_commit do
......
......@@ -18,6 +18,10 @@ module Ci
bridge.cancel!
when 'skipped'
bridge.skip!
when 'manual'
bridge.update(status: 'manual')
when 'scheduled'
bridge.schedule!
end
end
end
......
......@@ -21,7 +21,7 @@ module Ci
bridge_updates = { upstream_pipeline: upstream_pipeline }
if completed_status?(upstream_pipeline.status)
if upstream_pipeline.complete? || upstream_pipeline.blocked?
bridge_updates[:status] = upstream_pipeline.status
end
......@@ -41,9 +41,5 @@ module Ci
upstream_project.pipeline_for(upstream_project.default_branch)
end
end
def completed_status?(status)
Ci::Pipeline::COMPLETED_STATUSES.include?(status)
end
end
end
......@@ -433,6 +433,14 @@ describe Ci::Pipeline do
pipeline.succeed!
end
end
context 'when transitioning to blocked' do
it 'schedules the pipeline bridge worker' do
expect(::Ci::PipelineBridgeStatusWorker).to receive(:perform_async).with(pipeline.id)
pipeline.block!
end
end
end
end
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
describe Ci::PipelineBridgeStatusService do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, :success, project: project) }
let(:pipeline) { create(:ci_pipeline, status, project: project) }
describe '#execute' do
subject { described_class.new(project, user).execute(pipeline) }
......@@ -17,8 +17,20 @@ describe Ci::PipelineBridgeStatusService do
pipeline.downstream_bridges << bridge
end
it 'updates the bridge status with the pipeline status' do
expect { subject }.to change { bridge.status }.from('pending').to('success')
context 'when pipeline succeeds' do
let(:status) { :success }
it 'updates the bridge status with the pipeline status' do
expect { subject }.to change { bridge.status }.from('pending').to('success')
end
end
context 'when pipeline gets blocked' do
let(:status) { :blocked }
it 'updates the bridge status with the pipeline status' do
expect { subject }.to change { bridge.status }.from('pending').to('manual')
end
end
end
end
......
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