Class: GithubActions::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/github_actions/github_actions/job.rb

Overview

Github Actions job

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, data, workflow) ⇒ Job

Returns a new instance of Job.

Parameters:

  • name (String)

    name of the job

  • data (Hash)

    data from the workflow YAML file

  • workflow (GithubActions::Workflow)

    the parent workflow



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tasks/github_actions/github_actions/job.rb', line 30

def initialize(name, data, workflow)
  @name = name
  @runs_on = data["runs-on"]
  @container = data["container"]
  @workflow = workflow
  @matrix = data.fetch("strategy", {})["matrix"]

  @steps = data["steps"].map do |step|
    Step.new(self, step)
  end
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



25
26
27
# File 'lib/tasks/github_actions/github_actions/job.rb', line 25

def container
  @container
end

#matrixObject (readonly)

Returns the value of attribute matrix.



25
26
27
# File 'lib/tasks/github_actions/github_actions/job.rb', line 25

def matrix
  @matrix
end

#nameObject (readonly)

Returns the value of attribute name.



25
26
27
# File 'lib/tasks/github_actions/github_actions/job.rb', line 25

def name
  @name
end

#runs_onObject (readonly)

Returns the value of attribute runs_on.



25
26
27
# File 'lib/tasks/github_actions/github_actions/job.rb', line 25

def runs_on
  @runs_on
end

#stepsObject (readonly)

Returns the value of attribute steps.



25
26
27
# File 'lib/tasks/github_actions/github_actions/job.rb', line 25

def steps
  @steps
end

#workflowObject (readonly)

Returns the value of attribute workflow.



25
26
27
# File 'lib/tasks/github_actions/github_actions/job.rb', line 25

def workflow
  @workflow
end

Instance Method Details

#unsupported_stepsArray<String>

check if the defined steps can be used locally

Returns:

  • (Array<String>)

    the list of unsupported steps, returns empty list if all actions are supported



45
46
47
48
49
# File 'lib/tasks/github_actions/github_actions/job.rb', line 45

def unsupported_steps
  steps.each_with_object([]) do |step, array|
    array << step.name unless step.supported?
  end
end