Commit 56a08d23 authored by Matija Čupić's avatar Matija Čupić

Parallelize jobs in Gitlab::Ci::YamlProcessor

parent 3c8dd4cc
......@@ -29,8 +29,6 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def compose!(deps = nil)
super do
@config = Ci::Config::Normalizer.normalize_jobs(@config)
@config.each do |name, config|
node = hidden?(name) ? Entry::Hidden : Entry::Job
......
......@@ -7,11 +7,11 @@ module Gitlab
parallelized_jobs = {}
parallelized_config = jobs_config.map do |name, config|
if config&.[](:parallel)
if config[:parallel]
total = config[:parallel]
names = parallelize_job_names(name, total)
parallelized_jobs[name] = names
Hash[names.collect { |job_name| [job_name.to_sym, config] }]
Hash[names.collect { |job_name| [job_name.to_sym, config.merge(name: job_name)] }]
else
{ name => config }
end
......
......@@ -103,7 +103,7 @@ module Gitlab
##
# Jobs
#
@jobs = @ci_config.jobs
@jobs = Ci::Config::Normalizer.normalize_jobs(@ci_config.jobs)
@jobs.each do |name, job|
# logical validation for job
......
......@@ -136,19 +136,6 @@ module Gitlab
end
end
end
describe 'parallel entry' do
context 'when parallel is defined' do
let(:config) do
YAML.dump(rspec: { script: 'rspec',
parallel: 2 })
end
it 'has the attributes' do
expect(subject[:options][:parallel]).to eq 2
end
end
end
end
describe '#stages_attributes' do
......@@ -667,12 +654,12 @@ module Gitlab
parallel: parallel })
end
it 'returns parallelized job' do
it 'returns parallelized jobs' do
config_processor = Gitlab::Ci::YamlProcessor.new(config)
builds = config_processor.stage_builds_attributes("test")
builds = config_processor.stage_builds_attributes('test')
expect(builds.size).to eq(1)
expect(builds.first[:options][:parallel]).to eq(parallel)
expect(builds.size).to eq(5)
expect(builds.map { |build| build[:options] }).to all(include(parallel: parallel))
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