Class: FunCi::Pipeline::StageRunner
- Inherits:
-
Object
- Object
- FunCi::Pipeline::StageRunner
- Includes:
- ProcessRunner
- Defined in:
- lib/fun_ci/pipeline/stage_runner.rb
Instance Method Summary collapse
-
#initialize(commit_hash:, stdout:, command_runner: nil, time_budgets: {}, recorder: Persistence::NullRecorder.new) ⇒ StageRunner
constructor
A new instance of StageRunner.
- #run_stage(config, stage) ⇒ Object
Methods included from ProcessRunner
Constructor Details
#initialize(commit_hash:, stdout:, command_runner: nil, time_budgets: {}, recorder: Persistence::NullRecorder.new) ⇒ StageRunner
Returns a new instance of StageRunner.
12 13 14 15 16 17 18 |
# File 'lib/fun_ci/pipeline/stage_runner.rb', line 12 def initialize(commit_hash:, stdout:, command_runner: nil, time_budgets: {}, recorder: Persistence::NullRecorder.new) @commit_hash = commit_hash @stdout = stdout @command_runner = command_runner @time_budgets = time_budgets @recorder = recorder end |
Instance Method Details
#run_stage(config, stage) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fun_ci/pipeline/stage_runner.rb', line 20 def run_stage(config, stage) script = config.script_path(stage) budget = @time_budgets[stage] job_id = @recorder.start_stage(stage) output, status, timed_out = run_with_timeout(script, budget) if timed_out @recorder.end_stage(job_id, "timed_out") @stdout.puts "#{stage_label(stage)} killed -- exceeded #{budget}s time budget." @stdout.puts budget_advice(stage) return false end unless status.success? @recorder.end_stage(job_id, "failed") @stdout.puts output unless output.empty? @stdout.puts "#{stage_label(stage)} failed." return false end @recorder.end_stage(job_id, "completed") true end |