Class: GithubActions::JobRunner

Inherits:
Object
  • Object
show all
Includes:
Colorizer
Defined in:
lib/tasks/github_actions/github_actions/job_runner.rb

Overview

Runs GitHub Actions job in a container locally

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Colorizer

#error, #info, #stage, #success, #warning

Constructor Details

#initialize(job, image = nil) ⇒ JobRunner

constructor

Parameters:

  • job (GithubActions::Job)

    the job to run

  • image (String, nil) (defaults to: nil)

    override the Docker image to use, if ‘nil` it by default uses the image specified in the job



32
33
34
35
# File 'lib/tasks/github_actions/github_actions/job_runner.rb', line 32

def initialize(job, image = nil)
  @job = job
  @image = image
end

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image.



26
27
28
# File 'lib/tasks/github_actions/github_actions/job_runner.rb', line 26

def image
  @image
end

#jobObject (readonly)

Returns the value of attribute job.



26
27
28
# File 'lib/tasks/github_actions/github_actions/job_runner.rb', line 26

def job
  @job
end

Instance Method Details

#runBoolean

run the job in a container

Returns:

  • (Boolean)

    ‘true` if all steps were successfully executed, `false` otherwise



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/tasks/github_actions/github_actions/job_runner.rb', line 40

def run
  stage("Running \"#{job.name}\" job from file #{job.workflow.file}")
  start_container

  result = true
  job.steps.each do |step|
    result &= run_step(step)
  end

  print_result(result)
  container.stop
  result
end