Commit ff34fb10 by Grzegorz Bizon

Execute pipeline hooks asynchronously

parent 7c07c07d
Pipeline #4577271 failed with stages
in 32 minutes 40 seconds
......@@ -71,7 +71,11 @@ module Ci
end
after_transition do |pipeline, transition|
pipeline.execute_hooks unless transition.loopback?
return if transition.loopback?
pipeline.run_after_commit do
PipelineHooksWorker.perform_async(id)
end
end
end
......
class PipelineHooksWorker
include Sidekiq::Worker
sidekiq_options queue: :default
def perform(pipeline_id)
Ci::Pipeline.find_by(id: pipeline_id)
.try(:execute_hooks)
end
end
require 'spec_helper'
describe PipelineHooksWorker do
describe '#perform' do
context 'when pipeline exists' do
let(:pipeline) { create(:ci_pipeline) }
it 'executes hooks for the pipeline' do
expect_any_instance_of(Ci::Pipeline)
.to receive(:execute_hooks)
described_class.new.perform(pipeline.id)
end
end
context 'when pipeline does not exist' do
it 'does not raise exception' do
expect { described_class.new.perform(123) }
.not_to raise_error
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