Commit a40e357f authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'gitlab-ci-multi-runner-2284' into 'master'

Return an empty array when dependencies is an empty array

Closes #30316 and gitlab-ci-multi-runner#2284

See merge request !10359
parents 10a77824 31b8287a
...@@ -540,6 +540,8 @@ module Ci ...@@ -540,6 +540,8 @@ module Ci
end end
def dependencies def dependencies
return [] if empty_dependencies?
depended_jobs = depends_on_builds depended_jobs = depends_on_builds
return depended_jobs unless options[:dependencies].present? return depended_jobs unless options[:dependencies].present?
...@@ -549,6 +551,10 @@ module Ci ...@@ -549,6 +551,10 @@ module Ci
end end
end end
def empty_dependencies?
options[:dependencies]&.empty?
end
private private
def update_artifacts_size def update_artifacts_size
......
...@@ -461,6 +461,29 @@ describe API::Runner do ...@@ -461,6 +461,29 @@ describe API::Runner do
end end
end end
context 'when dependencies is an empty array' do
let!(:job) { create(:ci_build_tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
let!(:job2) { create(:ci_build_tag, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 0) }
let!(:empty_dependencies_job) do
create(:ci_build, pipeline: pipeline, token: 'test-job-token', name: 'empty_dependencies_job',
stage: 'deploy', stage_idx: 1,
options: { dependencies: [] })
end
before do
job.success
job2.success
end
it 'returns an empty array' do
request_job
expect(response).to have_http_status(201)
expect(json_response['id']).to eq(empty_dependencies_job.id)
expect(json_response['dependencies'].count).to eq(0)
end
end
context 'when job has no tags' do context 'when job has no tags' do
before { job.update(tags: []) } before { job.update(tags: []) }
......
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