Commit dbd1b0b1 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'report-missing-job-dependency' into 'master'

Check for dependency job stage index before comparison

Closes #59366

See merge request gitlab-org/gitlab-ce!31116
parents 252a0b0f 5eb3c4af
---
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
job[:dependencies].each do |dependency|
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"
end
end
......
......@@ -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') }
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
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