Commit dbab56a9 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Create composite job entries in new CI config

parent 6ae80732
...@@ -11,6 +11,20 @@ module Gitlab ...@@ -11,6 +11,20 @@ module Gitlab
validations do validations do
validates :config, type: Hash validates :config, type: Hash
end 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 end
end end
......
...@@ -1043,11 +1043,11 @@ EOT ...@@ -1043,11 +1043,11 @@ EOT
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings")
end 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" }) config = YAML.dump({ extra: "bundle update" })
expect do expect do
GitlabCiYamlProcessor.new(config, path) 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 end
it "returns errors if there are unknown parameters that are hashes, but doesn't have a script" do 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 ...@@ -4,6 +4,8 @@ describe Gitlab::Ci::Config::Node::Jobs do
let(:entry) { described_class.new(config) } let(:entry) { described_class.new(config) }
describe 'validations' do describe 'validations' do
before { entry.process! }
context 'when entry config value is correct' do context 'when entry config value is correct' do
let(:config) { { rspec: { script: 'rspec' } } } let(:config) { { rspec: { script: 'rspec' } } }
...@@ -33,4 +35,19 @@ describe Gitlab::Ci::Config::Node::Jobs do ...@@ -33,4 +35,19 @@ describe Gitlab::Ci::Config::Node::Jobs do
end end
end 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 end
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