diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-10-01 14:17:54 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-10-01 14:17:54 +0800 |
commit | 33bbfd277b94ecdf3cb8ffdfc973bbfb67b54810 (patch) | |
tree | 6f5c5e037a7876193d5dc6240b12786e0f635b6f | |
parent | dd01f3a748ea8be2af75ef03ff203efe1b8f5962 (diff) | |
download | gitlab-ce-33bbfd277b94ecdf3cb8ffdfc973bbfb67b54810.tar.gz |
on_failure should also be ignored, and status_sql should
also respect this ignorance. Address feedback from:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6604#note_16273363
-rw-r--r-- | app/models/concerns/has_status.rb | 12 | ||||
-rw-r--r-- | app/services/ci/process_pipeline_service.rb | 6 |
2 files changed, 10 insertions, 8 deletions
diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 0fa4df0fb56..5a6c2725354 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -8,7 +8,7 @@ module HasStatus class_methods do def status_sql - scope = all + scope = exclude_ignored_jobs builds = scope.select('count(*)').to_sql created = scope.created.select('count(*)').to_sql success = scope.success.select('count(*)').to_sql @@ -21,8 +21,8 @@ module HasStatus deduce_status = "(CASE WHEN (#{builds})=(#{created}) THEN 'created' - WHEN (#{builds})=(#{skipped}) THEN 'skipped' - WHEN (#{builds})=(#{success})+(#{ignored})+(#{skipped}) THEN 'success' + WHEN (#{builds})=(#{success})+(#{ignored}) THEN 'success' + WHEN (#{builds})=(#{success})+(#{ignored})+(#{skipped}) THEN 'skipped' WHEN (#{builds})=(#{created})+(#{pending})+(#{skipped}) THEN 'pending' WHEN (#{builds})=(#{canceled})+(#{success})+(#{ignored})+(#{skipped}) THEN 'canceled' WHEN (#{running})+(#{pending})+(#{created})>0 THEN 'running' @@ -68,6 +68,12 @@ module HasStatus scope :skipped, -> { where(status: 'skipped') } scope :running_or_pending, -> { where(status: [:running, :pending]) } scope :finished, -> { where(status: [:success, :failed, :canceled]) } + scope :exclude_ignored_jobs, -> do + quoted_when = connection.quote_column_name('when') + # We want to ignore skipped manual jobs + where("#{quoted_when} <> ? OR status <> ?", 'manual', 'skipped'). + where("#{quoted_when} <> ? OR status <> ?", 'on_failure', 'skipped') + end end def started? diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb index 7adf093557b..3e76dc32f01 100644 --- a/app/services/ci/process_pipeline_service.rb +++ b/app/services/ci/process_pipeline_service.rb @@ -61,11 +61,7 @@ module Ci end def status_for_prior_stages(index) - quoted_when = pipeline.builds.connection.quote_column_name('when') - pipeline.builds. - where('stage_idx < ?', index). - # We want to ignore skipped manual jobs - where("#{quoted_when} <> ? OR status <> ?", 'manual', 'skipped'). + pipeline.builds.exclude_ignored_jobs.where('stage_idx < ?', index). latest.status || 'success' end |