summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-08-19 14:20:33 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-08-19 14:20:33 +0200
commit9e548934469a235515aa7d6d07551d711c47876c (patch)
tree06ac8f81b8171c495b4165558aab2e1faf166cf0
parente97c078a2654650a1072c00fd7ef4ea1a01cd403 (diff)
downloadgitlab-ce-fix/pipeline-stage-processing.tar.gz
Extend processable builds to include skipped onesfix/pipeline-stage-processing
-rw-r--r--app/services/ci/process_pipeline_service.rb25
-rw-r--r--spec/services/ci/process_pipeline_service_spec.rb2
2 files changed, 12 insertions, 15 deletions
diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb
index 6f7610d42ba..a8be1e5fd90 100644
--- a/app/services/ci/process_pipeline_service.rb
+++ b/app/services/ci/process_pipeline_service.rb
@@ -6,14 +6,11 @@ module Ci
@pipeline = pipeline
# This method will ensure that our pipeline does have all builds for all stages created
- if created_builds.empty?
- create_builds!
- end
+ create_builds! if pipeline.builds.created.empty?
- new_builds =
- stage_indexes_of_created_builds.map do |index|
- process_stage(index)
- end
+ new_builds = stage_indexes_of_processable_builds.map do |index|
+ process_stage(index)
+ end
# Return a flag if a when builds got enqueued
new_builds.flatten.any?
@@ -28,7 +25,7 @@ module Ci
def process_stage(index)
current_status = status_for_prior_stages(index)
- created_builds_in_stage(index).select do |build|
+ processable_builds_in_stage(index).select do |build|
process_build(build, current_status)
end
end
@@ -62,16 +59,16 @@ module Ci
pipeline.builds.where('stage_idx < ?', index).latest.status || 'success'
end
- def stage_indexes_of_created_builds
- created_builds.order(:stage_idx).pluck('distinct stage_idx')
+ def processable_builds_in_stage(index)
+ processable_builds.where(stage_idx: index)
end
- def created_builds_in_stage(index)
- created_builds.where(stage_idx: index)
+ def stage_indexes_of_processable_builds
+ processable_builds.order(:stage_idx).pluck('distinct stage_idx')
end
- def created_builds
- pipeline.builds.created
+ def processable_builds
+ pipeline.builds.where(status: ['created', 'skipped'])
end
end
end
diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb
index 6529acbac2c..8326e5cd313 100644
--- a/spec/services/ci/process_pipeline_service_spec.rb
+++ b/spec/services/ci/process_pipeline_service_spec.rb
@@ -256,7 +256,7 @@ describe Ci::ProcessPipelineService, services: true do
expect(builds.pluck(:name))
.to contain_exactly('build:1', 'build:2', 'test:1', 'test:2')
- Ci::Build.retry(pipeline.builds.find_by(name: 'test:2'))
+ Ci::Build.retry(pipeline.builds.find_by(name: 'test:2')).success
expect(builds.pluck(:name)).to contain_exactly(
'build:1', 'build:2', 'test:1', 'test:2', 'test:2', 'deploy:1', 'deploy:2')