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.
This commit is contained in:
parent
9f26729af5
commit
76e7b19c81
|
@ -3,6 +3,7 @@
|
||||||
module Ci
|
module Ci
|
||||||
class Build < CommitStatus
|
class Build < CommitStatus
|
||||||
prepend ArtifactMigratable
|
prepend ArtifactMigratable
|
||||||
|
include Ci::Processable
|
||||||
include TokenAuthenticatable
|
include TokenAuthenticatable
|
||||||
include AfterCommitQueue
|
include AfterCommitQueue
|
||||||
include ObjectStorage::BackgroundMove
|
include ObjectStorage::BackgroundMove
|
||||||
|
|
|
@ -25,6 +25,8 @@ module Ci
|
||||||
|
|
||||||
has_many :stages, -> { order(position: :asc) }, inverse_of: :pipeline
|
has_many :stages, -> { order(position: :asc) }, inverse_of: :pipeline
|
||||||
has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id, 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 :builds, foreign_key: :commit_id, inverse_of: :pipeline
|
||||||
has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id # rubocop:disable Cop/ActiveRecordDependent
|
has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id # rubocop:disable Cop/ActiveRecordDependent
|
||||||
has_many :variables, class_name: 'Ci::PipelineVariable'
|
has_many :variables, class_name: 'Ci::PipelineVariable'
|
||||||
|
|
|
@ -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
|
|
@ -55,7 +55,7 @@ module Ci
|
||||||
# rubocop: enable CodeReuse/ActiveRecord
|
# rubocop: enable CodeReuse/ActiveRecord
|
||||||
|
|
||||||
def created_builds
|
def created_builds
|
||||||
pipeline.builds.created
|
pipeline.processables.created
|
||||||
end
|
end
|
||||||
|
|
||||||
# This method is for compatibility and data consistency and should be removed with 9.3 version of GitLab
|
# This method is for compatibility and data consistency and should be removed with 9.3 version of GitLab
|
||||||
|
|
Loading…
Reference in New Issue