model

package
v0.2.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2021 License: MIT Imports: 14 Imported by: 16

Documentation

Index

Constants

View Source
const (
	// ActionRunsUsingNode12 for running with node12
	ActionRunsUsingNode12 = "node12"
	// ActionRunsUsingDocker for running with docker
	ActionRunsUsingDocker = "docker"
	// ActionRunsUsingComposite for running composite
	ActionRunsUsingComposite = "composite"
)

Variables

This section is empty.

Functions

func FixIfStatement added in v0.2.22

func FixIfStatement(content []byte, wr *Workflow) error

Fixes faulty if statements from decoder

func FixIfStatement1 added in v0.2.22

func FixIfStatement1(val string, lines [][][]byte, l int) (string, error)

Helper function for FixIfstatement

Types

type Action

type Action struct {
	Name        string            `yaml:"name"`
	Author      string            `yaml:"author"`
	Description string            `yaml:"description"`
	Inputs      map[string]Input  `yaml:"inputs"`
	Outputs     map[string]Output `yaml:"outputs"`
	Runs        ActionRuns        `yaml:"runs"`
	Branding    struct {
		Color string `yaml:"color"`
		Icon  string `yaml:"icon"`
	} `yaml:"branding"`
}

Action describes a metadata file for GitHub actions. The metadata filename must be either action.yml or action.yaml. The data in the metadata file defines the inputs, outputs and main entrypoint for your action.

func ReadAction

func ReadAction(in io.Reader) (*Action, error)

ReadAction reads an action from a reader

type ActionRuns added in v0.2.21

type ActionRuns struct {
	Using      ActionRunsUsing   `yaml:"using"`
	Env        map[string]string `yaml:"env"`
	Main       string            `yaml:"main"`
	Image      string            `yaml:"image"`
	Entrypoint []string          `yaml:"entrypoint"`
	Args       []string          `yaml:"args"`
	Steps      []Step            `yaml:"steps"`
}

ActionRuns are a field in Action

type ActionRunsUsing

type ActionRunsUsing string

ActionRunsUsing is the type of runner for the action

func (*ActionRunsUsing) UnmarshalYAML added in v0.2.9

func (a *ActionRunsUsing) UnmarshalYAML(unmarshal func(interface{}) error) error

type ContainerSpec

type ContainerSpec struct {
	Image      string            `yaml:"image"`
	Env        map[string]string `yaml:"env"`
	Ports      []string          `yaml:"ports"`
	Volumes    []string          `yaml:"volumes"`
	Options    string            `yaml:"options"`
	Entrypoint string
	Args       string
	Name       string
	Reuse      bool
}

ContainerSpec is the specification of the container to use for the job

type Defaults added in v0.2.11

type Defaults struct {
	Run RunDefaults `yaml:"run"`
}

Default settings that will apply to all steps in the job or workflow

type Input

type Input struct {
	Description string `yaml:"description"`
	Required    bool   `yaml:"required"`
	Default     string `yaml:"default"`
}

Input parameters allow you to specify data that the action expects to use during runtime. GitHub stores input parameters as environment variables. Input ids with uppercase letters are converted to lowercase during runtime. We recommended using lowercase input ids.

type Job

type Job struct {
	Name           string                    `yaml:"name"`
	RawNeeds       yaml.Node                 `yaml:"needs"`
	RawRunsOn      yaml.Node                 `yaml:"runs-on"`
	Env            interface{}               `yaml:"env"`
	If             yaml.Node                 `yaml:"if"`
	Steps          []*Step                   `yaml:"steps"`
	TimeoutMinutes int64                     `yaml:"timeout-minutes"`
	Services       map[string]*ContainerSpec `yaml:"services"`
	Strategy       *Strategy                 `yaml:"strategy"`
	RawContainer   yaml.Node                 `yaml:"container"`
	Defaults       Defaults                  `yaml:"defaults"`
}

Job is the structure of one job in a workflow

func (*Job) Container

func (j *Job) Container() *ContainerSpec

Container details for the job

func (*Job) Environment added in v0.2.23

func (j *Job) Environment() map[string]string

func (*Job) GetMatrixes added in v0.2.2

func (j *Job) GetMatrixes() []map[string]interface{}

GetMatrixes returns the matrix cross product

func (*Job) Matrix added in v0.2.23

func (j *Job) Matrix() map[string][]interface{}

func (*Job) Needs

func (j *Job) Needs() []string

Needs list for Job

func (*Job) RunsOn

func (j *Job) RunsOn() []string

RunsOn list for Job

type Output

type Output struct {
	Description string `yaml:"description"`
	Value       string `yaml:"value"`
}

Output parameters allow you to declare data that an action sets. Actions that run later in a workflow can use the output data set in previously run actions. For example, if you had an action that performed the addition of two inputs (x + y = z), the action could output the sum (z) for other actions to use as an input.

type Plan

type Plan struct {
	Stages []*Stage
}

Plan contains a list of stages to run in series

func (*Plan) MaxRunNameLen

func (p *Plan) MaxRunNameLen() int

MaxRunNameLen determines the max name length of all jobs

type Run

type Run struct {
	Workflow *Workflow
	JobID    string
}

Run represents a job from a workflow that needs to be run

func (*Run) Job

func (r *Run) Job() *Job

Job returns the job for this Run

func (*Run) String

func (r *Run) String() string

type RunDefaults added in v0.2.11

type RunDefaults struct {
	Shell            string `yaml:"shell"`
	WorkingDirectory string `yaml:"working-directory"`
}

Defaults for all run steps in the job or workflow

type Stage

type Stage struct {
	Runs []*Run
}

Stage contains a list of runs to execute in parallel

func (*Stage) GetJobIDs

func (s *Stage) GetJobIDs() []string

GetJobIDs will get all the job names in the stage

type Step

type Step struct {
	ID               string            `yaml:"id"`
	If               yaml.Node         `yaml:"if"`
	Name             string            `yaml:"name"`
	Uses             string            `yaml:"uses"`
	Run              string            `yaml:"run"`
	WorkingDirectory string            `yaml:"working-directory"`
	Shell            string            `yaml:"shell"`
	Env              interface{}       `yaml:"env"`
	With             map[string]string `yaml:"with"`
	ContinueOnError  bool              `yaml:"continue-on-error"`
	TimeoutMinutes   int64             `yaml:"timeout-minutes"`
}

Step is the structure of one step in a job

func (*Step) Environment added in v0.2.23

func (s *Step) Environment() map[string]string

func (*Step) GetEnv

func (s *Step) GetEnv() map[string]string

GetEnv gets the env for a step

func (*Step) ShellCommand added in v0.2.2

func (s *Step) ShellCommand() string

ShellCommand returns the command for the shell

func (*Step) String

func (s *Step) String() string

String gets the name of step

func (*Step) Type

func (s *Step) Type() StepType

Type returns the type of the step

func (*Step) Validate added in v0.2.22

func (s *Step) Validate() error

type StepType

type StepType int

StepType describes what type of step we are about to run

const (
	// StepTypeRun is all steps that have a `run` attribute
	StepTypeRun StepType = iota

	// StepTypeUsesDockerURL is all steps that have a `uses` that is of the form `docker://...`
	StepTypeUsesDockerURL

	// StepTypeUsesActionLocal is all steps that have a `uses` that is a local action in a subdirectory
	StepTypeUsesActionLocal

	// StepTypeUsesActionRemote is all steps that have a `uses` that is a reference to a github repo
	StepTypeUsesActionRemote

	// StepTypeInvalid is for steps that have invalid step action
	StepTypeInvalid
)

type Strategy

type Strategy struct {
	FailFast    bool        `yaml:"fail-fast"`
	MaxParallel int         `yaml:"max-parallel"`
	Matrix      interface{} `yaml:"matrix"`
}

Strategy for the job

type Workflow

type Workflow struct {
	Name     string            `yaml:"name"`
	RawOn    yaml.Node         `yaml:"on"`
	Env      map[string]string `yaml:"env"`
	Jobs     map[string]*Job   `yaml:"jobs"`
	Defaults Defaults          `yaml:"defaults"`
}

Workflow is the structure of the files in .github/workflows

func ReadWorkflow

func ReadWorkflow(in io.Reader) (*Workflow, error)

ReadWorkflow returns a list of jobs for a given workflow file reader

func (*Workflow) GetJob

func (w *Workflow) GetJob(jobID string) *Job

GetJob will get a job by name in the workflow

func (*Workflow) GetJobIDs

func (w *Workflow) GetJobIDs() []string

GetJobIDs will get all the job names in the workflow

func (*Workflow) On

func (w *Workflow) On() []string

On events for the workflow

type WorkflowFiles added in v0.2.22

type WorkflowFiles struct {
	// contains filtered or unexported fields
}

type WorkflowPlanner

type WorkflowPlanner interface {
	PlanEvent(eventName string) *Plan
	PlanJob(jobName string) *Plan
	GetEvents() []string
}

WorkflowPlanner contains methods for creating plans

func NewWorkflowPlanner

func NewWorkflowPlanner(path string, noWorkflowRecurse bool) (WorkflowPlanner, error)

NewWorkflowPlanner will load a specific workflow, all workflows from a directory or all workflows from a directory and its subdirectories nolint: gocyclo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL