Commit 5eb3c4af authored by drew's avatar drew Committed by Kamil Trzciński

Default dependency job stage index to Infinity, and correctly report it as...

Default dependency job stage index to Infinity, and correctly report it as undefined in prior stages
parent 252a0b0f
---
title: Default dependency job stage index to Infinity, and correctly report it as
undefined in prior stages
merge_request: 31116
author:
type: fixed
...@@ -144,7 +144,9 @@ module Gitlab ...@@ -144,7 +144,9 @@ module Gitlab
job[:dependencies].each do |dependency| job[:dependencies].each do |dependency|
raise ValidationError, "#{name} job: undefined dependency: #{dependency}" unless @jobs[dependency.to_sym] raise ValidationError, "#{name} job: undefined dependency: #{dependency}" unless @jobs[dependency.to_sym]
unless @stages.index(@jobs[dependency.to_sym][:stage]) < stage_index dependency_stage_index = @stages.index(@jobs[dependency.to_sym][:stage])
unless dependency_stage_index.present? && dependency_stage_index < stage_index
raise ValidationError, "#{name} job: dependency #{dependency} is not defined in prior stages" raise ValidationError, "#{name} job: dependency #{dependency} is not defined in prior stages"
end end
end end
......
...@@ -1085,6 +1085,31 @@ module Gitlab ...@@ -1085,6 +1085,31 @@ module Gitlab
it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, 'test1 job: dependency deploy is not defined in prior stages') } it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, 'test1 job: dependency deploy is not defined in prior stages') }
end end
context 'when a job depends on another job that references a not-yet defined stage' do
let(:config) do
{
"stages" => [
"version"
],
"version" => {
"stage" => "version",
"dependencies" => ["release:components:versioning"],
"script" => ["./versioning/versioning"]
},
".release_go" => {
"stage" => "build",
"script" => ["cd versioning"]
},
"release:components:versioning" => {
"stage" => "build",
"script" => ["cd versioning"]
}
}
end
it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, /is not defined in prior stages/) }
end
end end
describe "Hidden jobs" do describe "Hidden jobs" 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