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

Implement POC for job parallelization

parent d9b56bc1
...@@ -24,6 +24,24 @@ module Gitlab ...@@ -24,6 +24,24 @@ module Gitlab
end end
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 def attributes
@attributes.merge( @attributes.merge(
pipeline: @pipeline, pipeline: @pipeline,
...@@ -38,7 +56,11 @@ module Gitlab ...@@ -38,7 +56,11 @@ module Gitlab
def to_resource def to_resource
strong_memoize(:resource) do strong_memoize(:resource) do
::Ci::Build.new(attributes) if parallelized?
parallelize_build
else
::Ci::Build.new(attributes)
end
end end
end end
end end
......
...@@ -50,6 +50,7 @@ module Gitlab ...@@ -50,6 +50,7 @@ module Gitlab
after_script: job[:after_script], after_script: job[:after_script],
environment: job[:environment], environment: job[:environment],
retry: job[:retry], retry: job[:retry],
parallel: job[:parallel],
start_in: job[:start_in] start_in: job[:start_in]
}.compact } }.compact }
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