Commit 820eeaf6 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add scaffold of EE extensions to CI/CD bridge jobs

parent b7c0076e
......@@ -32,3 +32,5 @@ module Ci
end
end
end
::Ci::Bridge.prepend(::EE::Ci::Bridge)
# frozen_string_literal: true
module EE
module Ci
module Bridge
extend ActiveSupport::Concern
prepended do
has_many :sourced_pipelines, class_name: ::Ci::Sources::Pipeline,
foreign_key: :source_job_id
state_machine :status do
after_transition any => [:pending] do |bridge|
bridge.run_after_commit do
bridge.schedule_downstream_pipeline!
# 1. schedule pipeline creation async
# 2. scheduled pipeline calls-back to change state to running
# when it gets created successfully
# 3. if no downstream pipeline can not be created because of
# various reasons like lack of access then we change state to
# failed with a reason
end
end
after_transition pending: :running do |bridge|
bridge.run_after_commit do
end
end
end
end
def schedule_downstream_pipeline!
raise NotImplementedError
end
end
end
end
require 'spec_helper'
describe Ci::Bridge do
set(:project) { create(:project) }
set(:pipeline) { create(:ci_pipeline, project: project) }
let(:bridge) do
create(:ci_bridge, status: :created, pipeline: pipeline)
end
it 'has many sourced pipelines' do
expect(bridge).to have_many(:sourced_pipelines)
end
describe 'state machine transitions' do
context 'when it changes status from created to pending' do
it 'schedules downstream pipeline creation' do
expect(bridge).to receive(:schedule_downstream_pipeline!)
bridge.enqueue!
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