Commit 44b740f9 authored by Matija Čupić's avatar Matija Čupić

Implement POC for job parallelization

parent d9b56bc1
......@@ -24,6 +24,24 @@ module Gitlab
end
end
def parallelized?
@attributes[:options].include?(:parallel)
end
def parallelize_build
builds = []
total = @attributes[:options][:parallel]
total.times do |i|
build = ::Ci::Build.new(attributes.merge(options: { variables: { CI_NODE_INDEX: i + 1, CI_NODE_TOTAL: total } }))
build.name = build.name + "_#{i + 1}/#{total}"
builds << build
end
builds
end
def attributes
@attributes.merge(
pipeline: @pipeline,
......@@ -38,7 +56,11 @@ module Gitlab
def to_resource
strong_memoize(:resource) do
::Ci::Build.new(attributes)
if parallelized?
parallelize_build
else
::Ci::Build.new(attributes)
end
end
end
end
......
......@@ -50,6 +50,7 @@ module Gitlab
after_script: job[:after_script],
environment: job[:environment],
retry: job[:retry],
parallel: job[:parallel],
start_in: job[:start_in]
}.compact }
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