Commit e60e591f authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'touchup-ci-normalizer' into 'master'

Touchup Normalizer implementation

See merge request gitlab-org/gitlab-ce!22872
parents 0cd22a38 d5919aeb
...@@ -9,14 +9,16 @@ module Gitlab ...@@ -9,14 +9,16 @@ module Gitlab
end end
def normalize_jobs def normalize_jobs
extract_parallelized_jobs extract_parallelized_jobs!
return @jobs_config if @parallelized_jobs.empty?
parallelized_config = parallelize_jobs parallelized_config = parallelize_jobs
parallelize_dependencies(parallelized_config) parallelize_dependencies(parallelized_config)
end end
private private
def extract_parallelized_jobs def extract_parallelized_jobs!
@parallelized_jobs = {} @parallelized_jobs = {}
@jobs_config.each do |job_name, config| @jobs_config.each do |job_name, config|
...@@ -41,8 +43,8 @@ module Gitlab ...@@ -41,8 +43,8 @@ module Gitlab
end end
def parallelize_dependencies(parallelized_config) def parallelize_dependencies(parallelized_config)
parallelized_config.each_with_object({}) do |(job_name, config), hash|
parallelized_job_names = @parallelized_jobs.keys.map(&:to_s) parallelized_job_names = @parallelized_jobs.keys.map(&:to_s)
parallelized_config.each_with_object({}) do |(job_name, config), hash|
if config[:dependencies] && (intersection = config[:dependencies] & parallelized_job_names).any? if config[:dependencies] && (intersection = config[:dependencies] & parallelized_job_names).any?
deps = intersection.map { |dep| @parallelized_jobs[dep.to_sym].map(&:first) }.flatten deps = intersection.map { |dep| @parallelized_jobs[dep.to_sym].map(&:first) }.flatten
hash[job_name] = config.merge(dependencies: deps) hash[job_name] = config.merge(dependencies: deps)
......
...@@ -31,6 +31,14 @@ describe Gitlab::Ci::Config::Normalizer do ...@@ -31,6 +31,14 @@ describe Gitlab::Ci::Config::Normalizer do
expect(configs).to all(eq(original_config)) expect(configs).to all(eq(original_config))
end end
context 'when the job is not parallelized' do
let(:job_config) { { script: 'rspec', name: 'rspec' } }
it 'returns the same hash' do
is_expected.to eq(config)
end
end
context 'when there is a job with a slash in it' do context 'when there is a job with a slash in it' do
let(:job_name) { :"rspec 35/2" } let(:job_name) { :"rspec 35/2" }
......
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