2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Pipeline
|
|
|
|
module Chain
|
|
|
|
class Sequence
|
|
|
|
def initialize(pipeline, command, sequence)
|
|
|
|
@pipeline = pipeline
|
|
|
|
@command = command
|
|
|
|
@sequence = sequence
|
|
|
|
@completed = []
|
2020-05-24 23:13:21 +05:30
|
|
|
@start = Time.now
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def build!
|
|
|
|
@sequence.each do |chain|
|
|
|
|
step = chain.new(@pipeline, @command)
|
|
|
|
|
|
|
|
step.perform!
|
|
|
|
break if step.break?
|
|
|
|
|
|
|
|
@completed.push(step)
|
|
|
|
end
|
|
|
|
|
|
|
|
@pipeline.tap do
|
|
|
|
yield @pipeline, self if block_given?
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
@command.observe_creation_duration(Time.now - @start)
|
2020-06-23 00:09:42 +05:30
|
|
|
@command.observe_pipeline_size(@pipeline)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def complete?
|
|
|
|
@completed.size == @sequence.size
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|