summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2019-04-01 20:44:58 +0200
committerMatija Čupić <matteeyah@gmail.com>2019-04-02 01:07:03 +0200
commit2c8510703cd0e99b4e1adc7740a124e7a2157def (patch)
tree64bb4bf56d5382699b35a72bc97c70f594b29f72
parent57cba4d1e9e9964359a5c55bca6558db0d511d98 (diff)
downloadgitlab-ce-mc/refactor/bridges-ce.tar.gz
Backport changes from EEmc/refactor/bridges-ce
This backports CE changes from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/10521
-rw-r--r--app/models/ci/bridge.rb4
-rw-r--r--app/models/commit_status.rb2
-rw-r--r--lib/gitlab/ci/pipeline/seed/build.rb2
-rw-r--r--spec/factories/ci/bridge.rb10
-rw-r--r--spec/features/projects/pipelines/pipeline_spec.rb3
-rw-r--r--spec/lib/gitlab/ci/pipeline/seed/build_spec.rb16
6 files changed, 16 insertions, 21 deletions
diff --git a/app/models/ci/bridge.rb b/app/models/ci/bridge.rb
index 0d8d7d95791..dac203b6f30 100644
--- a/app/models/ci/bridge.rb
+++ b/app/models/ci/bridge.rb
@@ -15,6 +15,10 @@ module Ci
delegate :merge_request_event?, to: :pipeline
+ def self.fabricate(attributes)
+ ::Ci::Bridge.new(attributes)
+ end
+
def self.retry(bridge, current_user)
raise NotImplementedError
end
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index f97dc38dab7..48214c076d9 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -41,7 +41,7 @@ class CommitStatus < ApplicationRecord
scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) }
scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) }
scope :after_stage, -> (index) { where('stage_idx > ?', index) }
- scope :processables, -> { where(type: %w[Ci::Build Ci::Bridge]) }
+ scope :processables, -> { where(type: %w[Ci::Build Ci::Bridge Ci::Bridges::Downstream]) }
# We use `CommitStatusEnums.failure_reasons` here so that EE can more easily
# extend this `Hash` with new values.
diff --git a/lib/gitlab/ci/pipeline/seed/build.rb b/lib/gitlab/ci/pipeline/seed/build.rb
index d8296940a04..cefb1cc1182 100644
--- a/lib/gitlab/ci/pipeline/seed/build.rb
+++ b/lib/gitlab/ci/pipeline/seed/build.rb
@@ -45,7 +45,7 @@ module Gitlab
def to_resource
strong_memoize(:resource) do
if bridge?
- ::Ci::Bridge.new(attributes)
+ ::Ci::Bridge.fabricate(attributes)
else
::Ci::Build.new(attributes)
end
diff --git a/spec/factories/ci/bridge.rb b/spec/factories/ci/bridge.rb
index b1d82b98411..183f2399ba5 100644
--- a/spec/factories/ci/bridge.rb
+++ b/spec/factories/ci/bridge.rb
@@ -14,16 +14,8 @@ FactoryBot.define do
yaml_variables [{ key: 'BRIDGE', value: 'cross', public: true }]
end
- transient { downstream nil }
-
- after(:build) do |bridge, evaluator|
+ after(:build) do |bridge, _|
bridge.project ||= bridge.pipeline.project
-
- if evaluator.downstream.present?
- bridge.options = bridge.options.to_h.merge(
- trigger: { project: evaluator.downstream.full_path }
- )
- end
end
end
end
diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb
index b197557039d..0de5d50df59 100644
--- a/spec/features/projects/pipelines/pipeline_spec.rb
+++ b/spec/features/projects/pipelines/pipeline_spec.rb
@@ -476,8 +476,7 @@ describe 'Pipeline', :js do
let!(:bridge) do
create(:ci_bridge, pipeline: pipeline,
name: 'cross-build',
- user: user,
- downstream: downstream)
+ user: user)
end
describe 'GET /:project/pipelines/:id' do
diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
index fae8add6453..d2f53780344 100644
--- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
@@ -21,20 +21,20 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end
describe '#bridge?' do
- context 'when job is a bridge' do
+ context 'when job is a downstream bridge' do
let(:attributes) do
{ name: 'rspec', ref: 'master', options: { trigger: 'my/project' } }
end
it { is_expected.to be_bridge }
- end
- context 'when trigger definition is empty' do
- let(:attributes) do
- { name: 'rspec', ref: 'master', options: { trigger: '' } }
- end
+ context 'when trigger definition is empty' do
+ let(:attributes) do
+ { name: 'rspec', ref: 'master', options: { trigger: '' } }
+ end
- it { is_expected.not_to be_bridge }
+ it { is_expected.not_to be_bridge }
+ end
end
context 'when job is not a bridge' do
@@ -50,7 +50,7 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end
end
- context 'when job is a bridge' do
+ context 'when job is a downstream bridge' do
let(:attributes) do
{ name: 'rspec', ref: 'master', options: { trigger: 'my/project' } }
end