Commit d87132b4 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Always actionize build when it is a manual action

Do not skip manual actions even if actions are optional.
parent 53fcede5
...@@ -35,11 +35,8 @@ module Ci ...@@ -35,11 +35,8 @@ module Ci
def process_build(build, current_status) def process_build(build, current_status)
if valid_statuses_for_when(build.when).include?(current_status) if valid_statuses_for_when(build.when).include?(current_status)
build.enqueue build.action? ? build.actionize : build.enqueue
true true
elsif build.action? && build.barrier?
build.actionize
false
else else
build.skip build.skip
false false
...@@ -54,6 +51,8 @@ module Ci ...@@ -54,6 +51,8 @@ module Ci
%w[failed] %w[failed]
when 'always' when 'always'
%w[success failed skipped] %w[success failed skipped]
when 'manual'
%w[success]
else else
[] []
end end
......
...@@ -73,7 +73,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do ...@@ -73,7 +73,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do
create_build('deploy', stage_idx: 3) create_build('deploy', stage_idx: 3)
create_build('production', stage_idx: 3, when: 'manual', allow_failure: true) create_build('production', stage_idx: 3, when: 'manual', allow_failure: true)
create_build('cleanup', stage_idx: 4, when: 'always') create_build('cleanup', stage_idx: 4, when: 'always')
create_build('clear cache', stage_idx: 4, when: 'manual', allow_failure: true) create_build('clear:cache', stage_idx: 4, when: 'manual', allow_failure: true)
end end
context 'when builds are successful' do context 'when builds are successful' do
...@@ -89,17 +89,17 @@ describe Ci::ProcessPipelineService, '#execute', :services do ...@@ -89,17 +89,17 @@ describe Ci::ProcessPipelineService, '#execute', :services do
succeed_running_or_pending succeed_running_or_pending
expect(builds_names).to eq %w(build test deploy) expect(builds_names).to eq %w(build test deploy production)
expect(builds_statuses).to eq %w(success success pending) expect(builds_statuses).to eq %w(success success pending manual)
succeed_running_or_pending succeed_running_or_pending
expect(builds_names).to eq %w(build test deploy cleanup) expect(builds_names).to eq %w(build test deploy production cleanup clear:cache)
expect(builds_statuses).to eq %w(success success success pending) expect(builds_statuses).to eq %w(success success success manual pending manual)
succeed_running_or_pending succeed_running_or_pending
expect(builds_statuses).to eq %w(success success success success) expect(builds_statuses).to eq %w(success success success manual success manual)
expect(pipeline.reload.status).to eq 'success' expect(pipeline.reload.status).to eq 'success'
end end
end end
...@@ -174,18 +174,18 @@ describe Ci::ProcessPipelineService, '#execute', :services do ...@@ -174,18 +174,18 @@ describe Ci::ProcessPipelineService, '#execute', :services do
succeed_running_or_pending succeed_running_or_pending
expect(builds_names).to eq %w(build test deploy) expect(builds_names).to eq %w(build test deploy production)
expect(builds_statuses).to eq %w(success success pending) expect(builds_statuses).to eq %w(success success pending manual)
fail_running_or_pending fail_running_or_pending
expect(builds_names).to eq %w(build test deploy cleanup) expect(builds_names).to eq %w(build test deploy production cleanup)
expect(builds_statuses).to eq %w(success success failed pending) expect(builds_statuses).to eq %w(success success failed manual pending)
succeed_running_or_pending succeed_running_or_pending
expect(builds_statuses).to eq %w(success success failed success) expect(builds_statuses).to eq %w(success success failed manual success)
expect(pipeline.reload.status).to eq('failed') expect(pipeline.reload).to be_failed
end end
end end
...@@ -204,7 +204,9 @@ describe Ci::ProcessPipelineService, '#execute', :services do ...@@ -204,7 +204,9 @@ describe Ci::ProcessPipelineService, '#execute', :services do
cancel_running_or_pending cancel_running_or_pending
expect(builds.running_or_pending).to be_empty expect(builds.running_or_pending).to be_empty
expect(pipeline.reload.status).to eq 'canceled' expect(builds_names).to eq %w[build test]
expect(builds_statuses).to eq %w[success canceled]
expect(pipeline.reload).to be_canceled
end end
end end
...@@ -243,7 +245,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do ...@@ -243,7 +245,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do
end end
it 'starts from the second stage' do it 'starts from the second stage' do
expect(all_builds_statuses).to eq %w[skipped pending created] expect(all_builds_statuses).to eq %w[manual pending created]
end end
end end
...@@ -261,7 +263,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do ...@@ -261,7 +263,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do
builds.first.success builds.first.success
expect(all_builds_statuses).to eq(%w[success skipped pending]) expect(all_builds_statuses).to eq(%w[success manual pending])
end end
end end
end end
...@@ -275,6 +277,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do ...@@ -275,6 +277,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do
create_build('production:test', stage_idx: 4, when: 'always') create_build('production:test', stage_idx: 4, when: 'always')
end end
context 'when first stage succeeds' do
it 'blocks pipeline on stage with first manual action' do it 'blocks pipeline on stage with first manual action' do
process_pipeline process_pipeline
...@@ -290,6 +293,27 @@ describe Ci::ProcessPipelineService, '#execute', :services do ...@@ -290,6 +293,27 @@ describe Ci::ProcessPipelineService, '#execute', :services do
end end
end end
context 'when first stage fails' do
it 'does not take blocking action into account' do
process_pipeline
expect(builds_names).to eq %w[code:test]
expect(builds_statuses).to eq %w[pending]
expect(pipeline.reload.status).to eq 'pending'
fail_running_or_pending
expect(builds_names).to eq %w[code:test production:test]
expect(builds_statuses).to eq %w[failed pending]
succeed_running_or_pending
expect(builds_statuses).to eq %w[failed success]
expect(pipeline.reload).to be_failed
end
end
end
context 'when second stage has only on_failure jobs' do context 'when second stage has only on_failure jobs' do
before do before do
create_build('check', stage_idx: 0) create_build('check', stage_idx: 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment