Make sure all pipelines would go to pending once
Without this fix, pipeline could go from skipped to running directly, bypassing the transition for: [:created, :pending] => :running And this is responsible for setting up started_at. Without this fix, started_at would never be set. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/39884
This commit is contained in:
parent
760b2c75ef
commit
c00fde606e
3 changed files with 32 additions and 2 deletions
|
@ -66,8 +66,8 @@ module Ci
|
||||||
|
|
||||||
state_machine :status, initial: :created do
|
state_machine :status, initial: :created do
|
||||||
event :enqueue do
|
event :enqueue do
|
||||||
transition created: :pending
|
transition [:created, :skipped] => :pending
|
||||||
transition [:success, :failed, :canceled, :skipped] => :running
|
transition [:success, :failed, :canceled] => :running
|
||||||
end
|
end
|
||||||
|
|
||||||
event :run do
|
event :run do
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
title: Fix pipeline status transition for single manual job. This would also fix pipeline
|
||||||
|
duration becuse it is depending on status transition
|
||||||
|
merge_request: 15251
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -292,6 +292,30 @@ describe Ci::ProcessPipelineService, '#execute' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when there is only one manual action' do
|
||||||
|
before do
|
||||||
|
create_build('deploy', stage_idx: 0, when: 'manual', allow_failure: true)
|
||||||
|
|
||||||
|
process_pipeline
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'skips the pipeline' do
|
||||||
|
expect(pipeline.reload).to be_skipped
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the action was played' do
|
||||||
|
before do
|
||||||
|
play_manual_action('deploy')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'queues the action and pipeline' do
|
||||||
|
expect(all_builds_statuses).to eq(%w[pending])
|
||||||
|
|
||||||
|
expect(pipeline.reload).to be_pending
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when blocking manual actions are defined' do
|
context 'when blocking manual actions are defined' do
|
||||||
before do
|
before do
|
||||||
create_build('code:test', stage_idx: 0)
|
create_build('code:test', stage_idx: 0)
|
||||||
|
|
Loading…
Reference in a new issue