Skip to content
Snippets Groups Projects
Commit cf53d798 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Extract jobs config to separate key in config hash

parent 06c7d6f3
No related branches found
No related tags found
1 merge request!5087Move CI job config entries from legacy to new config
Pipeline #
Loading
@@ -36,6 +36,22 @@ module Gitlab
Loading
@@ -36,6 +36,22 @@ module Gitlab
helpers :before_script, :image, :services, :after_script, helpers :before_script, :image, :services, :after_script,
:variables, :stages, :types, :cache :variables, :stages, :types, :cache
   
def initialize(config)
return super(config) unless config.is_a?(Hash)
jobs = config.except(*self.class.nodes.keys)
global = config.slice(*self.class.nodes.keys)
super(global.merge(jobs: jobs))
end
##
# Temporary refactoring stub
#
def jobs
@config[:jobs]
end
def stages def stages
stages_defined? ? stages_value : types_value stages_defined? ? stages_value : types_value
end end
Loading
Loading
Loading
@@ -22,7 +22,9 @@ describe Gitlab::Ci::Config::Node::Global do
Loading
@@ -22,7 +22,9 @@ describe Gitlab::Ci::Config::Node::Global do
variables: { VAR: 'value' }, variables: { VAR: 'value' },
after_script: ['make clean'], after_script: ['make clean'],
stages: ['build', 'pages'], stages: ['build', 'pages'],
cache: { key: 'k', untracked: true, paths: ['public/'] } } cache: { key: 'k', untracked: true, paths: ['public/'] },
rspec: { script: 'rspec' },
spinach: { script: 'spinach' } }
end end
   
describe '#process!' do describe '#process!' do
Loading
@@ -120,6 +122,14 @@ describe Gitlab::Ci::Config::Node::Global do
Loading
@@ -120,6 +122,14 @@ describe Gitlab::Ci::Config::Node::Global do
.to eq(key: 'k', untracked: true, paths: ['public/']) .to eq(key: 'k', untracked: true, paths: ['public/'])
end end
end end
describe '#jobs' do
it 'returns jobs configuration' do
expect(global.jobs)
.to eq(rspec: { script: 'rspec' },
spinach: { script: 'spinach' })
end
end
end end
end end
   
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment