2018-10-26 00:12:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-26 05:13:40 -04:00
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Pipeline
|
|
|
|
module Chain
|
|
|
|
class Sequence
|
|
|
|
def initialize(pipeline, command, sequence)
|
|
|
|
@pipeline = pipeline
|
2017-12-04 07:56:32 -05:00
|
|
|
@command = command
|
|
|
|
@sequence = sequence
|
2021-11-19 13:12:50 -05:00
|
|
|
@start = current_monotonic_time
|
2017-09-26 05:13:40 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def build!
|
2020-08-12 11:10:02 -04:00
|
|
|
@sequence.each do |step_class|
|
2021-11-19 13:12:50 -05:00
|
|
|
step_start = current_monotonic_time
|
2020-08-12 11:10:02 -04:00
|
|
|
step = step_class.new(@pipeline, @command)
|
2017-09-26 05:13:40 -04:00
|
|
|
|
2017-12-04 07:56:32 -05:00
|
|
|
step.perform!
|
2021-08-27 11:10:21 -04:00
|
|
|
|
|
|
|
@command.observe_step_duration(
|
|
|
|
step_class,
|
2021-11-19 13:12:50 -05:00
|
|
|
current_monotonic_time - step_start
|
2021-08-27 11:10:21 -04:00
|
|
|
)
|
|
|
|
|
2017-09-26 05:13:40 -04:00
|
|
|
break if step.break?
|
|
|
|
end
|
|
|
|
|
2021-11-19 13:12:50 -05:00
|
|
|
@command.observe_creation_duration(current_monotonic_time - @start)
|
2020-08-12 11:10:02 -04:00
|
|
|
@command.observe_pipeline_size(@pipeline)
|
2021-07-27 02:09:01 -04:00
|
|
|
@command.observe_jobs_count_in_alive_pipelines
|
2017-09-26 05:13:40 -04:00
|
|
|
|
2020-08-12 11:10:02 -04:00
|
|
|
@pipeline
|
2017-09-26 05:13:40 -04:00
|
|
|
end
|
2021-11-19 13:12:50 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def current_monotonic_time
|
|
|
|
::Gitlab::Metrics::System.monotonic_time
|
|
|
|
end
|
2017-09-26 05:13:40 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|