diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-11-07 23:47:50 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-11-09 16:59:52 +0800 |
commit | c00fde606ee2d8f87a13c801efc3278396f6bb7f (patch) | |
tree | 9fe7e23b1e9c1c17c4988c0c775c9663a9530c19 | |
parent | 760b2c75ef9d2c6acb655860dceae4c04cd8e5a7 (diff) | |
download | gitlab-ce-c00fde606ee2d8f87a13c801efc3278396f6bb7f.tar.gz |
Make sure all pipelines would go to pending once39884-fix-pipeline-transition-with-single-manual-action
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
-rw-r--r-- | app/models/ci/pipeline.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/39884-fix-pipeline-transition-with-single-manual-action.yml | 6 | ||||
-rw-r--r-- | spec/services/ci/process_pipeline_service_spec.rb | 24 |
3 files changed, 32 insertions, 2 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index fcbe3d2b67b..19814864e50 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -66,8 +66,8 @@ module Ci state_machine :status, initial: :created do event :enqueue do - transition created: :pending - transition [:success, :failed, :canceled, :skipped] => :running + transition [:created, :skipped] => :pending + transition [:success, :failed, :canceled] => :running end event :run do diff --git a/changelogs/unreleased/39884-fix-pipeline-transition-with-single-manual-action.yml b/changelogs/unreleased/39884-fix-pipeline-transition-with-single-manual-action.yml new file mode 100644 index 00000000000..580b97241e7 --- /dev/null +++ b/changelogs/unreleased/39884-fix-pipeline-transition-with-single-manual-action.yml @@ -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 diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index 214adc9960f..0ce41e7c7ee 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -292,6 +292,30 @@ describe Ci::ProcessPipelineService, '#execute' do 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 before do create_build('code:test', stage_idx: 0) |