Class: Ocak::PipelineRunner

Inherits:
Object
  • Object
show all
Includes:
FailureReporting, MergeOrchestration
Defined in:
lib/ocak/pipeline_runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FailureReporting

#report_pipeline_failure

Constructor Details

#initialize(config:, options: {}) ⇒ PipelineRunner

Returns a new instance of PipelineRunner.



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

def initialize(config:, options: {})
  @config = config
  @options = options
  @watch_formatter = options[:watch] ? WatchFormatter.new : nil
  @shutting_down = false
  @shutdown_count = 0
  @active_issues = []
  @interrupted_issues = []
  @active_mutex = Mutex.new
  @registry = ProcessRegistry.new
  @executor = PipelineExecutor.new(config: config, shutdown_check: -> { @shutting_down })
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



15
16
17
# File 'lib/ocak/pipeline_runner.rb', line 15

def registry
  @registry
end

Instance Method Details



53
54
55
56
57
58
59
60
61
# File 'lib/ocak/pipeline_runner.rb', line 53

def print_shutdown_summary
  issues = @active_mutex.synchronize { @interrupted_issues.dup }
  return if issues.empty?

  warn "\nInterrupted issues:"
  issues.each do |issue_number|
    warn "  - Issue ##{issue_number}: ocak resume --issue #{issue_number}"
  end
end

#runObject



30
31
32
# File 'lib/ocak/pipeline_runner.rb', line 30

def run
  @options[:single] ? run_single(@options[:single]) : run_loop
end

#run_pipeline(issue_number, logger:, claude:, chdir: nil, skip_steps: [], complexity: 'full') ⇒ Object



34
35
36
37
# File 'lib/ocak/pipeline_runner.rb', line 34

def run_pipeline(issue_number, logger:, claude:, chdir: nil, skip_steps: [], complexity: 'full')
  @executor.run_pipeline(issue_number, logger: logger, claude: claude, chdir: chdir,
                                       skip_steps: skip_steps, complexity: complexity)
end

#shutdown!Object



39
40
41
42
43
44
45
46
47
# File 'lib/ocak/pipeline_runner.rb', line 39

def shutdown!
  count = @active_mutex.synchronize { @shutdown_count += 1 }

  if count >= 2
    force_shutdown!
  else
    graceful_shutdown!
  end
end

#shutting_down?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/ocak/pipeline_runner.rb', line 49

def shutting_down?
  @shutting_down
end