Add after_stage scope to commit status class
This commit is contained in:
parent
3063ab45dd
commit
346a7c696a
3 changed files with 10 additions and 12 deletions
|
@ -234,9 +234,7 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_as_processable_after_stage(stage_idx)
|
def mark_as_processable_after_stage(stage_idx)
|
||||||
builds.skipped
|
builds.skipped.after_stage(stage_idx).find_each(&:process)
|
||||||
.where('stage_idx > ?', stage_idx)
|
|
||||||
.find_each(&:process)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def latest?
|
def latest?
|
||||||
|
|
|
@ -23,9 +23,6 @@ class CommitStatus < ActiveRecord::Base
|
||||||
where(id: max_id.group(:name, :commit_id))
|
where(id: max_id.group(:name, :commit_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :retried, -> { where.not(id: latest) }
|
|
||||||
scope :ordered, -> { order(:name) }
|
|
||||||
|
|
||||||
scope :failed_but_allowed, -> do
|
scope :failed_but_allowed, -> do
|
||||||
where(allow_failure: true, status: [:failed, :canceled])
|
where(allow_failure: true, status: [:failed, :canceled])
|
||||||
end
|
end
|
||||||
|
@ -36,8 +33,11 @@ class CommitStatus < ActiveRecord::Base
|
||||||
false, all_state_names - [:failed, :canceled])
|
false, all_state_names - [:failed, :canceled])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scope :retried, -> { where.not(id: latest) }
|
||||||
|
scope :ordered, -> { order(:name) }
|
||||||
scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) }
|
scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) }
|
||||||
scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) }
|
scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) }
|
||||||
|
scope :after_stage, -> (index) { where('stage_idx > ?', index) }
|
||||||
|
|
||||||
state_machine :status do
|
state_machine :status do
|
||||||
event :enqueue do
|
event :enqueue do
|
||||||
|
|
|
@ -11,13 +11,18 @@ module Ci
|
||||||
# Reprocess builds in subsequent stages
|
# Reprocess builds in subsequent stages
|
||||||
#
|
#
|
||||||
pipeline.builds
|
pipeline.builds
|
||||||
.where('stage_idx > ?', resume_stage.index)
|
.after_stage(resume_stage.index)
|
||||||
.failed_or_canceled.find_each do |build|
|
.failed_or_canceled.find_each do |build|
|
||||||
Ci::RetryBuildService
|
Ci::RetryBuildService
|
||||||
.new(project, current_user)
|
.new(project, current_user)
|
||||||
.reprocess(build)
|
.reprocess(build)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Mark skipped builds as processable again
|
||||||
|
#
|
||||||
|
pipeline.mark_as_processable_after_stage(resume_stage.index)
|
||||||
|
|
||||||
##
|
##
|
||||||
# Retry builds in the first unsuccessful stage
|
# Retry builds in the first unsuccessful stage
|
||||||
#
|
#
|
||||||
|
@ -26,11 +31,6 @@ module Ci
|
||||||
.new(project, current_user)
|
.new(project, current_user)
|
||||||
.retry(build)
|
.retry(build)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
|
||||||
# Mark skipped builds as processable again
|
|
||||||
#
|
|
||||||
pipeline.mark_as_processable_after_stage(resume_stage.index)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in a new issue