diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-12-12 17:22:48 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-12-12 17:22:48 +0300 |
commit | 099777a3569208cdadeb88203a19885dbcd5d527 (patch) | |
tree | 69a912e92efce58346064a044592dcc7aaee8aa6 | |
parent | c6db4471aa73e68e558c22b8009be826a267d565 (diff) | |
parent | 4f2685fb7f778f96327e12ee9246090c5edf5eaa (diff) |
Merge branch 'feature/gb/ci-pipeline-bridge' into 'master'
Add basic implementation of CI/CD bridge job
See merge request gitlab-org/gitlab-ce!23730
-rw-r--r-- | app/models/ci/bridge.rb | 34 | ||||
-rw-r--r-- | lib/gitlab/ci/status/bridge/common.rb | 27 | ||||
-rw-r--r-- | lib/gitlab/ci/status/bridge/factory.rb | 15 | ||||
-rw-r--r-- | spec/factories/ci/bridge.rb | 17 | ||||
-rw-r--r-- | spec/models/ci/bridge_spec.rb | 25 |
5 files changed, 118 insertions, 0 deletions
diff --git a/app/models/ci/bridge.rb b/app/models/ci/bridge.rb new file mode 100644 index 00000000000..29aa00a66d9 --- /dev/null +++ b/app/models/ci/bridge.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Ci + class Bridge < CommitStatus + include Importable + include AfterCommitQueue + include Gitlab::Utils::StrongMemoize + + belongs_to :project + validates :ref, presence: 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 diff --git a/lib/gitlab/ci/status/bridge/common.rb b/lib/gitlab/ci/status/bridge/common.rb new file mode 100644 index 00000000000..c6cb620f7a0 --- /dev/null +++ b/lib/gitlab/ci/status/bridge/common.rb @@ -0,0 +1,27 @@ +# 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 diff --git a/lib/gitlab/ci/status/bridge/factory.rb b/lib/gitlab/ci/status/bridge/factory.rb new file mode 100644 index 00000000000..910de865483 --- /dev/null +++ b/lib/gitlab/ci/status/bridge/factory.rb @@ -0,0 +1,15 @@ +# 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 diff --git a/spec/factories/ci/bridge.rb b/spec/factories/ci/bridge.rb new file mode 100644 index 00000000000..5f83b80ad7b --- /dev/null +++ b/spec/factories/ci/bridge.rb @@ -0,0 +1,17 @@ +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 diff --git a/spec/models/ci/bridge_spec.rb b/spec/models/ci/bridge_spec.rb new file mode 100644 index 00000000000..741cdfef1a5 --- /dev/null +++ b/spec/models/ci/bridge_spec.rb @@ -0,0 +1,25 @@ +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 |