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:
Grzegorz Bizon 2019-01-22 13:54:59 +01:00
parent 9f26729af5
commit 76e7b19c81
4 changed files with 31 additions and 1 deletions

View File

@ -3,6 +3,7 @@
module Ci
class Build < CommitStatus
prepend ArtifactMigratable
include Ci::Processable
include TokenAuthenticatable
include AfterCommitQueue
include ObjectStorage::BackgroundMove

View File

@ -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'

View File

@ -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

View File

@ -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