summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-07-20 16:39:15 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-07-20 16:42:28 +0200
commit6c339026a39eabb8593d2851d21f8eef7b595378 (patch)
tree0f9a20f2b5bba88367433cb7ecca1c470f6d24a1
parent30f375cf5f5b5ca1d708c6f9558308a1d57cbd71 (diff)
downloadgitlab-ce-fix-retries-on-manual-actions.tar.gz
Fix a problem with processing a pipeline where stage only has manual actionsfix-retries-on-manual-actions
-rw-r--r--app/models/ci/pipeline.rb5
-rw-r--r--spec/models/ci/pipeline_spec.rb24
2 files changed, 16 insertions, 13 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index ad117e3950d..88fa01c896d 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -212,8 +212,9 @@ module Ci
# build builds only for the first stage that has builds available.
#
stages.any? do |stage|
- CreateBuildsService.new(self)
- .execute(stage, user, status, trigger_request).present?
+ CreateBuildsService.new(self).
+ execute(stage, user, status, trigger_request).
+ any?(&:active?)
end
end
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index c29e4811385..a3bd8fdf30b 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -264,7 +264,7 @@ describe Ci::Pipeline, models: true do
context 'when listing manual actions' do
let(:yaml) do
{
- stages: ["build", "test", "test_failure", "deploy", "cleanup"],
+ stages: ["build", "test", "staging", "production", "cleanup"],
build: {
stage: "build",
script: "BUILD",
@@ -273,17 +273,12 @@ describe Ci::Pipeline, models: true do
stage: "test",
script: "TEST",
},
- test_failure: {
- stage: "test_failure",
- script: "ON test failure",
- when: "on_failure",
- },
- deploy: {
- stage: "deploy",
+ staging: {
+ stage: "staging",
script: "PUBLISH",
},
production: {
- stage: "deploy",
+ stage: "production",
script: "PUBLISH",
when: "manual",
},
@@ -311,11 +306,18 @@ describe Ci::Pipeline, models: true do
# succeed stage test
pipeline.builds.running_or_pending.each(&:success)
- expect(manual_actions).to be_one # production
+ expect(manual_actions).to be_empty
- # succeed stage deploy
+ # succeed stage staging and skip stage production
pipeline.builds.running_or_pending.each(&:success)
expect(manual_actions).to be_many # production and clear cache
+
+ # succeed stage cleanup
+ pipeline.builds.running_or_pending.each(&:success)
+
+ # after processing a pipeline we should have 6 builds, 5 succeeded
+ expect(pipeline.builds.count).to eq(6)
+ expect(pipeline.builds.success.count).to eq(4)
end
def manual_actions