summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-07-20 15:33:45 +0000
committerRémy Coutable <remy@rymai.me>2016-07-21 11:16:04 +0200
commitb76d37c2261d4a61ad199ea4f32659f1e15d797a (patch)
tree9b8ccae307214e99801ed84dc493bb11f87ba744
parented3cda00edf7d45edfbde5a8567b88ecfd8d1d3d (diff)
downloadgitlab-ce-b76d37c2261d4a61ad199ea4f32659f1e15d797a.tar.gz
Merge branch 'fix-retries-on-manual-actions' into 'master'
Fix two small problems on how we handle manual actions ## What does this MR do? Fixes two small problems in how we handle manual actions: - On environments page we show a `Play` for the same action that is lately deployed, we should show other actions only - When we process a pipeline that have only a manual action in a stage, the pipeline will stop being processed. - Tests - [ ] Added for this feature/bug - [ ] All builds are passing - [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ ] Branch has no merge conflicts with `master` (if you do - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5366
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--app/models/ci/pipeline.rb5
-rw-r--r--spec/models/build_spec.rb16
-rw-r--r--spec/models/ci/pipeline_spec.rb24
4 files changed, 33 insertions, 14 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index fcb7c98df0f..cbfa14e81f1 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -97,7 +97,7 @@ module Ci
end
def other_actions
- pipeline.manual_actions.where.not(id: self)
+ pipeline.manual_actions.where.not(name: name)
end
def playable?
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index ad5437cea14..f0edf3e2731 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -217,8 +217,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/build_spec.rb b/spec/models/build_spec.rb
index 7363ffcebeb..978ad9c52d5 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -811,6 +811,22 @@ describe Ci::Build, models: true do
it 'returns other actions' do
is_expected.to contain_exactly(other_build)
end
+
+ context 'when build is retried' do
+ let!(:new_build) { Ci::Build.retry(build) }
+
+ it 'does not return any of them' do
+ is_expected.not_to include(build, new_build)
+ end
+ end
+
+ context 'when other build is retried' do
+ let!(:retried_build) { Ci::Build.retry(other_build) }
+
+ it 'returns a retried build' do
+ is_expected.to contain_exactly(retried_build)
+ end
+ end
end
describe '#play' do
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