class GithubActions::Tasks::Run
run the requested Github Actions job locally
Attributes
name[R]
the requested job name
Public Class Methods
new(name)
click to toggle source
constructor @param name [String] name of the job to run
# File lib/tasks/github_actions/tasks/run.rb, line 34 def initialize(name) @name = name end
Public Instance Methods
run()
click to toggle source
run the GitHub Action locally
# File lib/tasks/github_actions/tasks/run.rb, line 39 def run runner = GithubActions::JobRunner.new(find_job, ENV["DOCKER_IMAGE"]) abort unless runner.run end
Private Instance Methods
check_job(job)
click to toggle source
check if the job is valid and can be run locally, it aborts when the job cannot be used
# File lib/tasks/github_actions/tasks/run.rb, line 63 def check_job(job) if job.nil? error("ERROR: Job \"#{name}\" not found") abort end unsupported = job.unsupported_steps if !unsupported.empty? error("ERROR: These steps are not supported: #{unsupported.inspect}") abort end return if job.container && !job.container.empty? error("ERROR: Docker image name is missing in the job definition") abort end
find_job()
click to toggle source
read the job definition from YAML file
# File lib/tasks/github_actions/tasks/run.rb, line 47 def find_job job = nil Workflow.read.each do |workflow| # NOTE: in theory the same job name might be used in different files, # but in YaST we use single YAML files and we can avoid duplicates, # simply use the first found and avoid unnecessary complexity job = workflow.jobs.find { |j| j.name == name } end check_job(job) job end