Class: Bard::CI::Runner

Inherits:
Struct
  • Object
show all
Includes:
Retryable
Defined in:
lib/bard/ci/runner.rb

Direct Known Subclasses

GithubActions, Jenkins, Local

Constant Summary

Constants included from Retryable

Bard::CI::Retryable::INITIAL_DELAY, Bard::CI::Retryable::MAX_RETRIES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Retryable

#retry_with_backoff

Instance Attribute Details

#branchObject

Returns the value of attribute branch

Returns:

  • (Object)

    the current value of branch



6
7
8
# File 'lib/bard/ci/runner.rb', line 6

def branch
  @branch
end

#project_nameObject

Returns the value of attribute project_name

Returns:

  • (Object)

    the current value of project_name



6
7
8
# File 'lib/bard/ci/runner.rb', line 6

def project_name
  @project_name
end

#shaObject

Returns the value of attribute sha

Returns:

  • (Object)

    the current value of sha



6
7
8
# File 'lib/bard/ci/runner.rb', line 6

def sha
  @sha
end

Instance Method Details

#resumeObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/bard/ci/runner.rb', line 22

def resume
  saved_state = state.load
  raise "No saved CI state found for #{project_name}. Start a new build with 'bard ci'." if saved_state.nil?

  restore_state(saved_state)
  poll_until_complete { |elapsed, last_time| yield elapsed, last_time }

  state.delete
  success?
end

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bard/ci/runner.rb', line 9

def run
  start
  @start_time = Time.new.to_i
  @last_time_elapsed = get_last_time_elapsed
  save_state
  wait_until_started if respond_to?(:wait_until_started)

  poll_until_complete { |elapsed, last_time| yield elapsed, last_time }

  state.delete
  success?
end