workflow

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindWorkflow

func FindWorkflow(dir string) (string, error)

FindWorkflow searches for a workflow file in the given directory. If dir contains .github/workflows/*.yml or *.yaml, the first match is returned.

Types

type Container

type Container struct {
	Image string `yaml:"image"`
}

Container specifies the OCI image to use for the job.

On Linux and Windows hosts, this is the runner container image. On macOS hosts, it is an OCI artifact image whose layers are extracted onto the per-job VM via virtio-fs.

GitHub Actions accepts both a bare string (shorthand for {image: "..."}) and a full object. The custom UnmarshalYAML below handles both forms.

func (*Container) UnmarshalYAML

func (c *Container) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML accepts either a bare string ("image:tag") or a full mapping ({image: "...", ...}) for the container field, matching GitHub Actions.

type Job

type Job struct {
	Name      string            `yaml:"name"`
	RunsOn    interface{}       `yaml:"runs-on"` // string or []string
	Env       map[string]string `yaml:"env"`
	Container Container         `yaml:"container"`
	Steps     []Step            `yaml:"steps"`
}

Job represents a single job within a workflow.

type NetworkOptions added in v0.2.0

type NetworkOptions struct {
	Subnet            string
	MTU               int
	L2BridgeEgress    bool
	HostNIC           string
	IPPool            string
	Gateway           string
	PublicDNS         []string
	ExtraAllowedCIDRs []string
	AllowHostAccess   bool
}

NetworkOptions carries the host's [network] configuration into a local run.

Without it a local run silently built its own default network — on Windows an HNS NAT network plus the NAT-era netsh host-firewall rules — even on a host configured for L2Bridge egress. That was wrong twice over: the container came up unfiltered on NAT rather than on the enforcing L2Bridge path, and the netsh rules block RFC1918 host-wide, which severs the host's own DNS when its resolver is a LAN address. Mirrors the fields serve passes to networking.New.

type Runner

type Runner struct {
	DataDir    string
	SocketPath string // optional: containerd socket override for isolation from the service
	Image      string // container image; empty falls back to defaultImage
	Network    NetworkOptions
	// RegistryMirror routes the image pull through a LAN pull-through cache
	// when the node's config.toml configures one. Nil leaves the pull alone.
	RegistryMirror *registrymirror.Mirror
	Log            *slog.Logger
}

Runner executes workflow jobs locally using embedded containerd.

func (*Runner) RunJob

func (r *Runner) RunJob(ctx context.Context, jobName string, job Job, repoDir string) error

RunJob executes a single workflow job inside a container.

type Step

type Step struct {
	Name string            `yaml:"name"`
	Uses string            `yaml:"uses"`
	Run  string            `yaml:"run"`
	With map[string]string `yaml:"with"`
	Env  map[string]string `yaml:"env"`
}

Step represents a single step within a job.

type TargetPlatform

type TargetPlatform int

TargetPlatform identifies the OS a workflow job targets.

const (
	PlatformLinux TargetPlatform = iota
	PlatformWindows
	PlatformMacOS
)

func DetectPlatform

func DetectPlatform(runsOn interface{}) TargetPlatform

DetectPlatform determines the target OS from a job's runs-on field. The runs-on value can be a string ("ubuntu-latest") or a list (["self-hosted", "linux", "x64"]). If no OS label is found, linux is assumed (matching GitHub Actions default behavior).

func (TargetPlatform) String

func (p TargetPlatform) String() string

type Workflow

type Workflow struct {
	Name string         `yaml:"name"`
	Jobs map[string]Job `yaml:"jobs"`
}

Workflow represents a parsed GitHub Actions workflow file.

func Parse

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

Parse reads and parses a GitHub Actions workflow YAML file.

Jump to

Keyboard shortcuts

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