workflow

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultWorkflowDir

func DefaultWorkflowDir() string

DefaultWorkflowDir returns the default workflow directory.

func Normalize

func Normalize(wf *Workflow) error

Normalize normalizes the workflow after loading to handle YAML quirks.

func Validate

func Validate(wf *Workflow) error

Validate validates the workflow structure.

Types

type Defaults

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

Defaults represents default settings for a job.

type DryRunJob

type DryRunJob struct {
	ID     string
	Name   string
	RunsOn string
	Needs  string
	If     string
	Matrix map[string]any
	Steps  []DryRunStep
}

DryRunJob represents a job in the dry-run plan.

type DryRunPlan

type DryRunPlan struct {
	WorkflowName string
	WorkflowPath string
	Jobs         []DryRunJob
}

DryRunPlan represents a dry-run execution plan for a single workflow.

func GenerateDryRunPlan

func GenerateDryRunPlan(wf *Workflow, path string) *DryRunPlan

GenerateDryRunPlan generates a dry-run plan from the workflow.

type DryRunPlanSet

type DryRunPlanSet struct {
	Plans []*DryRunPlan
}

DryRunPlanSet represents a dry-run execution plan for multiple workflows.

func GenerateDryRunPlanSet

func GenerateDryRunPlanSet(workflows []*Workflow, paths []string) *DryRunPlanSet

GenerateDryRunPlanSet generates a dry-run plan set from multiple workflows.

type DryRunStep

type DryRunStep struct {
	Index           int
	ID              string
	Name            string
	Run             string
	Uses            string
	If              string
	ContinueOnError bool
	TimeoutMinutes  float64
}

DryRunStep represents a step in the dry-run plan.

type Job

type Job struct {
	Name           string             `yaml:"name"`
	RunsOn         interface{}        `yaml:"runs-on"`
	Needs          interface{}        `yaml:"needs"`
	If             string             `yaml:"if"`
	Env            map[string]any     `yaml:"env"`
	Services       map[string]Service `yaml:"services"`
	Steps          []Step             `yaml:"steps"`
	Strategy       *Strategy          `yaml:"strategy"`
	Outputs        map[string]string  `yaml:"outputs"`
	TimeoutMinutes float64            `yaml:"timeout-minutes"`
	Defaults       *Defaults          `yaml:"defaults"`
	// contains filtered or unexported fields
}

Job represents a job in a workflow.

func ExpandMatrix

func ExpandMatrix(jobID string, job Job) ([]Job, error)

ExpandMatrix expands a matrix configuration into a list of job instances. Each job instance has its own matrix context.

func (*Job) GetMatrixContext

func (j *Job) GetMatrixContext() map[string]any

GetMatrixContext returns the matrix context for a job.

func (Job) GetNeedsAsString

func (j Job) GetNeedsAsString() string

GetNeedsAsString returns the needs as a comma-separated string for display.

func (Job) GetNeedsList

func (j Job) GetNeedsList() []string

GetNeedsList returns the needs as a slice of strings.

func (*Job) GetRunsOnAsString

func (j *Job) GetRunsOnAsString() string

GetRunsOnAsString returns the runs-on as a comma-separated string for display.

func (*Job) GitHubEnvPath

func (j *Job) GitHubEnvPath() string

GitHubEnvPath returns the GITHUB_ENV file path.

func (*Job) GitHubPathPath

func (j *Job) GitHubPathPath() string

GitHubPathPath returns the GITHUB_PATH file path.

func (*Job) HasMatrix

func (j *Job) HasMatrix() bool

HasMatrix returns true if the job has a matrix strategy.

func (*Job) InstanceID

func (j *Job) InstanceID() string

InstanceID returns the job instance ID.

func (*Job) SetGitHubEnvPath

func (j *Job) SetGitHubEnvPath(path string)

SetGitHubEnvPath sets the GITHUB_ENV file path.

func (*Job) SetGitHubPathPath

func (j *Job) SetGitHubPathPath(path string)

SetGitHubPathPath sets the GITHUB_PATH file path.

func (*Job) SetInstanceID

func (j *Job) SetInstanceID(id string)

SetInstanceID sets the job instance ID.

type MatrixExpansion

type MatrixExpansion map[string]any

MatrixExpansion represents a single expanded matrix combination

type RunDefaults

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

RunDefaults represents default run settings.

type Service

type Service struct {
	Image   string         `yaml:"image"`
	Env     map[string]any `yaml:"env"`
	Ports   []any          `yaml:"ports"`
	Options string         `yaml:"options"`
}

Service represents a service container in a job.

type Step

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

Step represents a step in a job.

type Strategy

type Strategy struct {
	Matrix      map[string]any `yaml:"matrix"`
	FailFast    bool           `yaml:"fail-fast"`
	MaxParallel int            `yaml:"max-parallel"`
}

Strategy represents the strategy configuration for a job.

type ValidationError

type ValidationError struct {
	JobID   string
	Step    int
	Field   string
	Message string
}

ValidationError represents a validation error with location info.

func (*ValidationError) Error

func (e *ValidationError) Error() string

type ValidationErrorWithCode

type ValidationErrorWithCode struct {
	ValidationError
	ExitCode int
}

ValidationErrorWithCode extends ValidationError with an exit code.

func NewValidationErrorWithCode

func NewValidationErrorWithCode(jobID, message string, exitCode int) *ValidationErrorWithCode

NewValidationErrorWithCode creates a validation error with a specific exit code.

func (*ValidationErrorWithCode) Error

func (e *ValidationErrorWithCode) Error() string

type Workflow

type Workflow struct {
	Name     string         `yaml:"name"`
	On       interface{}    `yaml:"on"`
	Env      map[string]any `yaml:"env"`
	Secrets  map[string]any `yaml:"secrets"`
	Jobs     map[string]Job `yaml:"jobs"`
	Defaults *Defaults      `yaml:"defaults"`
}

Workflow represents a GitHub Actions workflow file.

func ExpandWorkflowJobs

func ExpandWorkflowJobs(wf *Workflow) (*Workflow, error)

ExpandWorkflowJobs expands matrix jobs in a workflow. Returns a new workflow with expanded jobs.

func LoadWorkflow

func LoadWorkflow(path string) (*Workflow, error)

LoadWorkflow loads a workflow from a YAML file.

func LoadWorkflows

func LoadWorkflows(path string) ([]*Workflow, error)

LoadWorkflows loads all workflow files from a path (file or directory). If path is a file, loads that single file. If path is a directory, loads all .yml and .yaml files in it.

Jump to

Keyboard shortcuts

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