Commit 8156e77c authored by Sean McGivern's avatar Sean McGivern

Merge branch 'respect-needs-on-artifacts' into 'master'

Respect needs on artifacts

Closes #65466

See merge request gitlab-org/gitlab-ce!31413
parents eb2d4adf 181b9b3e
...@@ -715,18 +715,14 @@ module Ci ...@@ -715,18 +715,14 @@ module Ci
depended_jobs = depends_on_builds depended_jobs = depends_on_builds
# find all jobs that are dependent on # find all jobs that are needed
if options[:dependencies].present? if Feature.enabled?(:ci_dag_support, project) && needs.exists?
depended_jobs = depended_jobs.select do |job| depended_jobs = depended_jobs.where(name: needs.select(:name))
options[:dependencies].include?(job.name)
end
end end
# find all jobs that are needed by this one # find all jobs that are dependent on
if options[:needs].present? if options[:dependencies].present?
depended_jobs = depended_jobs.select do |job| depended_jobs = depended_jobs.where(name: options[:dependencies])
options[:needs].include?(job.name)
end
end end
depended_jobs depended_jobs
......
...@@ -630,12 +630,17 @@ describe Ci::Build do ...@@ -630,12 +630,17 @@ describe Ci::Build do
create(:ci_build, create(:ci_build,
pipeline: pipeline, name: 'final', pipeline: pipeline, name: 'final',
stage_idx: 3, stage: 'deploy', options: { stage_idx: 3, stage: 'deploy', options: {
dependencies: dependencies, dependencies: dependencies
needs: needs
} }
) )
end end
before do
needs.to_a.each do |need|
create(:ci_build_need, build: final, name: need)
end
end
subject { final.dependencies } subject { final.dependencies }
context 'when depedencies are defined' do context 'when depedencies are defined' do
...@@ -648,6 +653,14 @@ describe Ci::Build do ...@@ -648,6 +653,14 @@ describe Ci::Build do
let(:needs) { %w(build rspec staging) } let(:needs) { %w(build rspec staging) }
it { is_expected.to contain_exactly(build, rspec_test, staging) } it { is_expected.to contain_exactly(build, rspec_test, staging) }
context 'when ci_dag_support is disabled' do
before do
stub_feature_flags(ci_dag_support: false)
end
it { is_expected.to contain_exactly(build, rspec_test, rubocop_test, staging) }
end
end end
context 'when needs and dependencies are defined' do context 'when needs and dependencies are defined' do
......
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