debian-mirror-gitlab/lib/gitlab/ci/pipeline/chain/sequence.rb

47 lines
1.1 KiB
Ruby
Raw Normal View History

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
2022-01-26 12:08:38 +05:30
@start = current_monotonic_time
2018-03-17 18:26:18 +05:30
end
def build!
2020-10-24 23:57:45 +05:30
@sequence.each do |step_class|
2022-01-26 12:08:38 +05:30
step_start = current_monotonic_time
2020-10-24 23:57:45 +05:30
step = step_class.new(@pipeline, @command)
2018-03-17 18:26:18 +05:30
step.perform!
2021-11-11 11:23:49 +05:30
@command.observe_step_duration(
step_class,
2022-01-26 12:08:38 +05:30
current_monotonic_time - step_start
2021-11-11 11:23:49 +05:30
)
2018-03-17 18:26:18 +05:30
break if step.break?
end
2022-01-26 12:08:38 +05:30
@command.observe_creation_duration(current_monotonic_time - @start)
2020-10-24 23:57:45 +05:30
@command.observe_pipeline_size(@pipeline)
2021-10-27 15:23:28 +05:30
@command.observe_jobs_count_in_alive_pipelines
2018-03-17 18:26:18 +05:30
2020-10-24 23:57:45 +05:30
@pipeline
2018-03-17 18:26:18 +05:30
end
2022-01-26 12:08:38 +05:30
private
def current_monotonic_time
::Gitlab::Metrics::System.monotonic_time
end
2018-03-17 18:26:18 +05:30
end
end
end
end
end