Module: Ocak::StepComments

Included in:
Commands::Hiz, PipelineExecutor
Defined in:
lib/ocak/step_comments.rb

Overview

Shared comment-posting helpers for pipeline steps. Includers typically provide an @issues instance variable (IssueFetcher or nil). All methods accept an optional ‘issues:` keyword to override @issues, allowing callers like Hiz to pass issues from a different source (e.g., state.issues).

Instance Method Summary collapse

Instance Method Details

#post_step_comment(issue_number, body, issues: @issues) ⇒ Object



9
10
11
12
13
14
# File 'lib/ocak/step_comments.rb', line 9

def post_step_comment(issue_number, body, issues: @issues)
  issues&.comment(issue_number, body)
rescue StandardError => e
  @logger&.debug("Step comment failed: #{e.message}")
  nil
end

#post_step_completion_comment(issue_number, role, result, issues: @issues) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ocak/step_comments.rb', line 16

def post_step_completion_comment(issue_number, role, result, issues: @issues)
  duration = (result.duration_ms.to_f / 1000).round
  cost = format('%.3f', result.cost_usd.to_f)
  if result.success?
    post_step_comment(issue_number, "\u{2705} **Phase: #{role}** completed \u2014 #{duration}s | $#{cost}",
                      issues: issues)
  else
    post_step_comment(issue_number, "\u{274C} **Phase: #{role}** failed \u2014 #{duration}s | $#{cost}",
                      issues: issues)
  end
end