diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-12 06:09:05 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-12 06:09:05 +0000 |
commit | 8c9dc985b90c353b33cb829caf51f8320171bc15 (patch) | |
tree | 9a68886dbea1aefabddb46bbd3faf961eab22ae6 /app/models/ci | |
parent | 500626a5c953ad81cfc3ed74bf0148c075617e58 (diff) | |
download | gitlab-ce-8c9dc985b90c353b33cb829caf51f8320171bc15.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/ci')
-rw-r--r-- | app/models/ci/bridge.rb | 1 | ||||
-rw-r--r-- | app/models/ci/build.rb | 1 | ||||
-rw-r--r-- | app/models/ci/processable.rb | 19 |
3 files changed, 19 insertions, 2 deletions
diff --git a/app/models/ci/bridge.rb b/app/models/ci/bridge.rb index 3726c05acd8..bb22cc3e039 100644 --- a/app/models/ci/bridge.rb +++ b/app/models/ci/bridge.rb @@ -8,7 +8,6 @@ module Ci include Importable include AfterCommitQueue include HasRef - include Gitlab::Utils::StrongMemoize InvalidBridgeTypeError = Class.new(StandardError) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index c23b2d81ce3..b0502f7a26e 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -10,7 +10,6 @@ module Ci include ObjectStorage::BackgroundMove include Presentable include Importable - include Gitlab::Utils::StrongMemoize include HasRef include IgnorableColumns diff --git a/app/models/ci/processable.rb b/app/models/ci/processable.rb index 6c4b271cd2c..95fb75688a9 100644 --- a/app/models/ci/processable.rb +++ b/app/models/ci/processable.rb @@ -2,10 +2,14 @@ module Ci class Processable < ::CommitStatus + include Gitlab::Utils::StrongMemoize + has_many :needs, class_name: 'Ci::BuildNeed', foreign_key: :build_id, inverse_of: :build accepts_nested_attributes_for :needs + enum scheduling_type: { stage: 0, dag: 1 }, _prefix: true + scope :preload_needs, -> { preload(:needs) } def self.select_with_aggregated_needs(project) @@ -23,6 +27,7 @@ module Ci end validates :type, presence: true + validates :scheduling_type, presence: true, on: :create, if: :validate_scheduling_type? def aggregated_needs_names read_attribute(:aggregated_needs_names) @@ -47,5 +52,19 @@ module Ci def scoped_variables_hash raise NotImplementedError end + + # scheduling_type column of previous builds/bridges have not been populated, + # so we calculate this value on runtime when we need it. + def find_legacy_scheduling_type + strong_memoize(:find_legacy_scheduling_type) do + needs.exists? ? :dag : :stage + end + end + + private + + def validate_scheduling_type? + !importing? && Feature.enabled?(:validate_scheduling_type_of_processables, project) + end end end |