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
diff options
context:
space:
mode:
authorJames Fargher <proglottis@gmail.com>2019-07-18 06:45:12 +0300
committerJames Fargher <proglottis@gmail.com>2019-08-20 05:12:44 +0300
commit30004bc9b77ec02cfbf30e951c8adc7978081762 (patch)
treed5059bf603340b2cb47af257ba966c7fc32a5314 /app/models
parent1068483f7260e5866c7d54f1f09b716dbf463c80 (diff)
Initial detection of Auto-DevOps buildable projects
Contains a large list of files we expect to find for an Auto-DevOps project.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/pipeline.rb7
-rw-r--r--app/models/concerns/has_status.rb1
-rw-r--r--app/models/project.rb6
3 files changed, 13 insertions, 1 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 0a943a33bbb..255ae64a3fd 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -45,6 +45,7 @@ module Ci
has_many :pending_builds, -> { pending }, foreign_key: :commit_id, class_name: 'Ci::Build'
has_many :retryable_builds, -> { latest.failed_or_canceled.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build'
has_many :cancelable_statuses, -> { cancelable }, foreign_key: :commit_id, class_name: 'CommitStatus'
+ has_many :skippable_statuses, -> { skippable }, foreign_key: :commit_id, class_name: 'CommitStatus'
has_many :manual_actions, -> { latest.manual_actions.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build'
has_many :scheduled_actions, -> { latest.scheduled_actions.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build'
has_many :artifacts, -> { latest.with_artifacts_not_expired.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build'
@@ -468,6 +469,12 @@ module Ci
end
end
+ def skip_all
+ retry_optimistic_lock(skippable_statuses) do |skippable|
+ skippable.find_each(&:skip)
+ end
+ end
+
def auto_cancel_running(pipeline)
update(auto_canceled_by: pipeline)
diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb
index 71ebb586c13..ba945b1e006 100644
--- a/app/models/concerns/has_status.rb
+++ b/app/models/concerns/has_status.rb
@@ -107,6 +107,7 @@ module HasStatus
scope :finished, -> { with_status(:success, :failed, :canceled) }
scope :failed_or_canceled, -> { with_status(:failed, :canceled) }
scope :incomplete, -> { without_statuses(completed_statuses) }
+ scope :skippable, -> { with_status(:created, :preparing, :pending) }
scope :cancelable, -> do
where(status: [:running, :preparing, :pending, :created, :scheduled])
diff --git a/app/models/project.rb b/app/models/project.rb
index 8efe4b06f87..e82776df419 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -651,10 +651,14 @@ class Project < ApplicationRecord
if auto_devops&.enabled.nil?
has_auto_devops_implicitly_enabled?
else
- auto_devops.enabled?
+ has_auto_devops_explicitly_enabled?
end
end
+ def has_auto_devops_explicitly_enabled?
+ auto_devops&.enabled?
+ end
+
def has_auto_devops_implicitly_enabled?
auto_devops_config = first_auto_devops_config