Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-01-22 15:54:59 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-01-25 12:36:59 +0300
commit76e7b19c8158bcf000db8575f958161a232d643e (patch)
tree120121eac1724c651760151a4efa21ee7e278821 /app
parent9f26729af5a3403e6b4f040370996e9c2b35d8d4 (diff)
Segregate interface require to make CI/CD entity processable
This commit segregates interface that is require to make CI/CD entity processable, like `Ci::Build`. With this change it is not clear and explicit what methods need to be implement to pass an object to pipeline processing service.
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/build.rb1
-rw-r--r--app/models/ci/pipeline.rb2
-rw-r--r--app/models/concerns/ci/processable.rb27
-rw-r--r--app/services/ci/process_pipeline_service.rb2
4 files changed, 31 insertions, 1 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index cfdb3c0d719..304588a417a 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -3,6 +3,7 @@
module Ci
class Build < CommitStatus
prepend ArtifactMigratable
+ include Ci::Processable
include TokenAuthenticatable
include AfterCommitQueue
include ObjectStorage::BackgroundMove
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 30a957b4117..014872a2e2a 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -25,6 +25,8 @@ module Ci
has_many :stages, -> { order(position: :asc) }, inverse_of: :pipeline
has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline
+ has_many :processables, -> { where(type: %w[Ci::Build Ci::Bridge]) },
+ class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline
has_many :builds, foreign_key: :commit_id, inverse_of: :pipeline
has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id # rubocop:disable Cop/ActiveRecordDependent
has_many :variables, class_name: 'Ci::PipelineVariable'
diff --git a/app/models/concerns/ci/processable.rb b/app/models/concerns/ci/processable.rb
new file mode 100644
index 00000000000..8edffb14a30
--- /dev/null
+++ b/app/models/concerns/ci/processable.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Ci
+ ##
+ # This module implements methods that need to be implemented by CI/CD
+ # entities that are supposed to go through pipeline processing
+ # services.
+ #
+ #
+ module Processable
+ def schedulable?
+ raise NotImplementedError
+ end
+
+ def action?
+ raise NotImplementedError
+ end
+
+ def artifacts?
+ raise NotImplementedError
+ end
+
+ def expanded_environment_name
+ raise NotImplementedError
+ end
+ end
+end
diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb
index 446188347df..7dbb5c16c70 100644
--- a/app/services/ci/process_pipeline_service.rb
+++ b/app/services/ci/process_pipeline_service.rb
@@ -55,7 +55,7 @@ module Ci
# rubocop: enable CodeReuse/ActiveRecord
def created_builds
- pipeline.builds.created
+ pipeline.processables.created
end
# This method is for compatibility and data consistency and should be removed with 9.3 version of GitLab