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:
Diffstat (limited to 'app/models/ci/pipeline.rb')
-rw-r--r--app/models/ci/pipeline.rb36
1 files changed, 30 insertions, 6 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 9a96429d3a9..7fa290610aa 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -386,13 +386,12 @@ module Ci
end
end
- def legacy_stages
+ def legacy_stages_using_sql
# TODO, this needs refactoring, see gitlab-foss#26481.
-
stages_query = statuses
.group('stage').select(:stage).order('max(stage_idx)')
- status_sql = statuses.latest.where('stage=sg.stage').status_sql
+ status_sql = statuses.latest.where('stage=sg.stage').legacy_status_sql
warnings_sql = statuses.latest.select('COUNT(*)')
.where('stage=sg.stage').failed_but_allowed.to_sql
@@ -405,6 +404,30 @@ module Ci
end
end
+ def legacy_stages_using_composite_status
+ stages = statuses.latest
+ .order(:stage_idx, :stage)
+ .group_by(&:stage)
+
+ stages.map do |stage_name, jobs|
+ composite_status = Gitlab::Ci::Status::Composite
+ .new(jobs)
+
+ Ci::LegacyStage.new(self,
+ name: stage_name,
+ status: composite_status.status,
+ warnings: composite_status.warnings?)
+ end
+ end
+
+ def legacy_stages
+ if Feature.enabled?(:ci_composite_status, default_enabled: false)
+ legacy_stages_using_composite_status
+ else
+ legacy_stages_using_sql
+ end
+ end
+
def valid_commit_sha
if self.sha == Gitlab::Git::BLANK_SHA
self.errors.add(:sha, " cant be 00000000 (branch removal)")
@@ -635,7 +658,8 @@ module Ci
def update_status
retry_optimistic_lock(self) do
- case latest_builds_status.to_s
+ new_status = latest_builds_status.to_s
+ case new_status
when 'created' then nil
when 'preparing' then prepare
when 'pending' then enqueue
@@ -648,7 +672,7 @@ module Ci
when 'scheduled' then delay
else
raise HasStatus::UnknownStatusError,
- "Unknown status `#{latest_builds_status}`"
+ "Unknown status `#{new_status}`"
end
end
end
@@ -907,7 +931,7 @@ module Ci
def latest_builds_status
return 'failed' unless yaml_errors.blank?
- statuses.latest.status || 'skipped'
+ statuses.latest.slow_composite_status || 'skipped'
end
def keep_around_commits