Commit 320b6d96 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add basic implementation of CI/CD bridge job

parent f6d8fb6e
# frozen_string_literal: true
module Ci
class Bridge < CommitStatus
include Importable
include AfterCommitQueue
include TokenAuthenticatable
include Gitlab::Utils::StrongMemoize
belongs_to :project, inverse_of: :builds
serialize :options # rubocop:disable Cop/ActiveRecordSerialize
validates :ref, presence: true
before_save :ensure_token
add_authentication_token_field :token, encrypted: true
def self.retry(bridge, current_user)
raise NotImplementedError
end
def tags
[:bridge]
end
def detailed_status(current_user)
Gitlab::Ci::Status::Bridge::Factory
.new(self, current_user)
.fabricate!
end
def predefined_variables
raise NotImplementedError
end
def execute_hooks
raise NotImplementedError
end
end
end
# frozen_string_literal: true
module Gitlab
module Ci
module Status
module Bridge
module Common
def label
subject.description
end
def has_details?
false
end
def has_action?
false
end
def details_path
raise NotImplementedError
end
end
end
end
end
end
# frozen_string_literal: true
module Gitlab
module Ci
module Status
module Bridge
class Factory < Status::Factory
def self.common_helpers
Status::Bridge::Common
end
end
end
end
end
end
FactoryBot.define do
factory :ci_bridge, class: Ci::Bridge do
name ' bridge'
stage 'test'
stage_idx 0
ref 'master'
tag false
created_at 'Di 29. Okt 09:50:00 CET 2013'
status :success
pipeline factory: :ci_pipeline
after(:build) do |bridge, evaluator|
bridge.project ||= bridge.pipeline.project
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, pipeline: pipeline)
end
describe '#tags' do
it 'only has a bridge tag' do
expect(bridge.tags).to eq [:bridge]
end
end
describe '#detailed_status' do
let(:user) { create(:user) }
let(:status) { bridge.detailed_status(user) }
it 'returns detailed status object' do
expect(status).to be_a Gitlab::Ci::Status::Success
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