Create composite job entries in new CI config
This commit is contained in:
parent
6ae80732bb
commit
dbab56a951
|
|
@ -11,6 +11,20 @@ module Gitlab
|
|||
validations do
|
||||
validates :config, type: Hash
|
||||
end
|
||||
|
||||
def nodes
|
||||
@config
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_node(key, essence)
|
||||
Node::Job.new(essence).tap do |job|
|
||||
job.key = key
|
||||
job.parent = self
|
||||
job.description = "#{key} job definition."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1043,11 +1043,11 @@ EOT
|
|||
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings")
|
||||
end
|
||||
|
||||
it "returns errors if there are unknown parameters" do
|
||||
it "returns error if job configuration is invalid" do
|
||||
config = YAML.dump({ extra: "bundle update" })
|
||||
expect do
|
||||
GitlabCiYamlProcessor.new(config, path)
|
||||
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Unknown parameter: extra")
|
||||
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:extra config should be a hash")
|
||||
end
|
||||
|
||||
it "returns errors if there are unknown parameters that are hashes, but doesn't have a script" do
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ describe Gitlab::Ci::Config::Node::Jobs do
|
|||
let(:entry) { described_class.new(config) }
|
||||
|
||||
describe 'validations' do
|
||||
before { entry.process! }
|
||||
|
||||
context 'when entry config value is correct' do
|
||||
let(:config) { { rspec: { script: 'rspec' } } }
|
||||
|
||||
|
|
@ -33,4 +35,19 @@ describe Gitlab::Ci::Config::Node::Jobs do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#descendants' do
|
||||
before { entry.process! }
|
||||
|
||||
let(:config) do
|
||||
{ rspec: { script: 'rspec' },
|
||||
spinach: { script: 'spinach' } }
|
||||
end
|
||||
|
||||
it 'creates two descendant nodes' do
|
||||
expect(entry.descendants.count).to eq 2
|
||||
expect(entry.descendants)
|
||||
.to all(be_an_instance_of(Gitlab::Ci::Config::Node::Job))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue