workflow

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultImageMap = map[string]string{
	"ubuntu-latest": "ghcr.io/catthehacker/ubuntu:act-latest",
	"ubuntu-24.04":  "ghcr.io/catthehacker/ubuntu:act-24.04",
	"ubuntu-22.04":  "ghcr.io/catthehacker/ubuntu:act-22.04",
	"ubuntu-20.04":  "ghcr.io/catthehacker/ubuntu:act-20.04",
	"ubuntu-18.04":  "ghcr.io/catthehacker/ubuntu:act-18.04",
}

DefaultImageMap maps common GitHub Actions runner labels to Docker images.

Functions

func ExpandMatrix

func ExpandMatrix(job *Job) []map[string]string

ExpandMatrix returns all matrix combinations for a job as a slice of variable maps (name → string value). Returns nil if the job has no matrix.

func MatrixSuffix

func MatrixSuffix(combo map[string]string) string

MatrixSuffix returns a short suffix like "(node-version=18, os=ubuntu)" used for display and job ID disambiguation.

func ResolveImage

func ResolveImage(runsOn []string, overrides map[string]string) (string, error)

ResolveImage resolves a runs-on label to a Docker image. Platform overrides take priority over defaults.

func ResolveJobOrder

func ResolveJobOrder(jobs map[string]*Job) ([][]string, error)

ResolveJobOrder performs a topological sort on job dependencies. Returns layers of job IDs that can be run in parallel within each layer.

Types

type ContainerConfig

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

ContainerConfig represents a service container configuration.

type Job

type Job struct {
	Name           string              `yaml:"name"`
	RunsOn         StringOrSlice       `yaml:"runs-on"`
	Needs          StringOrSlice       `yaml:"needs"`
	If             string              `yaml:"if"`
	Env            map[string]string   `yaml:"env"`
	Steps          []*Step             `yaml:"steps"`
	TimeoutMinutes int                 `yaml:"timeout-minutes"`
	Outputs        map[string]string   `yaml:"outputs"`
	Container      *ContainerConfig    `yaml:"container"`
	Services       map[string]*Service `yaml:"services"`
	Strategy       *Strategy           `yaml:"strategy"`
}

Job represents a single job in the workflow.

func (*Job) DisplayName

func (j *Job) DisplayName(id string) string

DisplayName returns a human-friendly name for the job.

type Service

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

Service represents a service defined in a job.

type Step

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

Step represents a single step within a job.

func (*Step) DisplayName

func (s *Step) DisplayName(index int) string

DisplayName returns a human-friendly name for the step.

type Strategy

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

Strategy holds the job matrix strategy.

type StringOrSlice

type StringOrSlice []string

StringOrSlice handles YAML fields that can be either a string or []string.

func (*StringOrSlice) UnmarshalYAML

func (s *StringOrSlice) UnmarshalYAML(node *yaml.Node) error

type TriggerConfig

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

TriggerConfig handles the flexible "on:" field in GitHub Actions.

func (TriggerConfig) String

func (t TriggerConfig) String() string

String returns a string representation of the trigger.

func (*TriggerConfig) UnmarshalYAML

func (t *TriggerConfig) UnmarshalYAML(node *yaml.Node) error

type Workflow

type Workflow struct {
	Name     string            `yaml:"name"`
	FileName string            `yaml:"-"`
	On       TriggerConfig     `yaml:"on"`
	Env      map[string]string `yaml:"env"`
	Jobs     map[string]*Job   `yaml:"jobs"`
}

Workflow represents a parsed .github/workflows/*.yml file.

func DiscoverWorkflows

func DiscoverWorkflows(dir string) ([]*Workflow, error)

DiscoverWorkflows finds all workflow YAML files in dir/.github/workflows/.

func ParseFile

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

ParseFile parses a single GitHub Actions workflow YAML file.

Jump to

Keyboard shortcuts

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