Help us shape the future of Go! Take the 2026 Go Developer Survey

workflow

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package workflow reads GitHub Actions workflow files: the repo guards, secrets and push triggers the CI audit reports, and the guard rewrite the gate applies to its CI candidate. It knows nothing of git or the forge.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPushSkip

func IsPushSkip(expr, public string) bool

IsPushSkip reports whether expr holds the advised push guard for the public repo, so it skips every push run outside that repo.

func IsWorkflowPath

func IsWorkflowPath(path string) bool

IsWorkflowPath reports whether GitHub Actions reads path as a workflow: a .yml or .yaml file directly under .github/workflows.

Types

type File

type File struct {
	Path         string
	Guards       []Guard
	Secrets      []string
	Inherit      []string
	Environments []string
	// PushGuarded is true when every job has an if: holding the advised
	// push guard (github.event_name != 'push' || github.repository ==
	// '<public>'), so a push outside the public repo runs none of them.
	PushGuarded bool
	// contains filtered or unexported fields
}

File is what the CI audit needs from one workflow file.

func Parse

func Parse(path string, src []byte, n Names) (File, error)

Parse reads one workflow file. A file that is not valid YAML returns the parse error; GitHub reports such files itself.

func (File) PushTriggered

func (f File) PushTriggered(branches []string) bool

PushTriggered reports whether a push to any of branches starts this workflow. A pattern it can't evaluate exactly counts as a match, so the audit errs toward reporting.

func (File) RunsOnPR added in v0.2.0

func (f File) RunsOnPR(branch string) bool

RunsOnPR reports whether this workflow runs for a gate PR whose head is branch: it triggers on pull_request or pull_request_target (whatever their filters), or on a push to branch, since the gate pushes it.

type Guard

type Guard struct {
	Path       string  `json:"path"`
	Job        string  `json:"job"`
	Step       *string `json:"step"`
	Expr       string  `json:"expr"`
	Rewritable bool    `json:"rewritable"`
}

Guard is one if: that compares the running repo with the public repo, so it skips in the shadow repo unless rewritten.

func Rewrite

func Rewrite(path string, src []byte, n Names) ([]byte, []Guard, error)

Rewrite widens every rewritable guard in src so it also matches the shadow repo. Only the bytes of those if: values change. The result is parsed again: unless every other value is unchanged and each if: reads exactly as intended, Rewrite returns src and reports every guard unrewritable. The same src and names always give the same bytes. The error is only ever src's YAML parse error.

type GuardReport

type GuardReport struct {
	Mode         string  `json:"mode"`
	Rewritten    []Guard `json:"rewritten"`
	Unrewritable []Guard `json:"unrewritable"`
	// Skipped are rewritable guards left as they are because
	// ci.rewrite_repo_guards is warn, so their jobs skip in the shadow repo
	// too. Nil in a plan written before 0.9.
	Skipped []Guard `json:"skipped"`
}

GuardReport is what the gate did with a candidate's guards.

type Names

type Names struct{ Public, Shadow string }

Names are the pair's repos, owner/name each.

Jump to

Keyboard shortcuts

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