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

jobparser

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SecretsInherit = "inherit"

SecretsInherit is the literal keyword used in a caller's `secrets: inherit` directive

Variables

This section is empty.

Functions

func EvaluateCallerWith added in v1.3.0

func EvaluateCallerWith(
	jobID string,
	job *Job,
	gitCtx map[string]any,
	results map[string]*JobResult,
	vars map[string]string,
	inputs map[string]any,
) (map[string]any, error)

EvaluateCallerWith evaluates the caller-side expressions in `job.With` against the provided contexts

func EvaluateConcurrency

func EvaluateConcurrency(rc *model.RawConcurrency, jobID string, job *Job, gitCtx map[string]any, results map[string]*JobResult, vars map[string]string, inputs map[string]any) (string, bool, error)

func EvaluateJobIfExpression added in v1.3.0

func EvaluateJobIfExpression(jobID string, job *Job, gitCtx map[string]any, results map[string]*JobResult, vars map[string]string, inputs map[string]any) (bool, error)

func EvaluateWorkflowCallOutputs added in v1.3.0

func EvaluateWorkflowCallOutputs(spec *WorkflowCallSpec, gitCtx *model.GithubContext, vars map[string]string, inputs map[string]any, jobOutputs JobOutputs) (map[string]string, error)

EvaluateWorkflowCallOutputs evaluates a called workflow's "on.workflow_call.outputs.<name>.value" expressions against the provided contexts.

func MatchCallerInputsAgainstSpec added in v1.3.0

func MatchCallerInputsAgainstSpec(spec *WorkflowCallSpec, evaluated map[string]any) (map[string]any, error)

MatchCallerInputsAgainstSpec checks the caller's already-evaluated `with:` values against the callee's declared `on.workflow_call.inputs` schema

func NewInterpeter

func NewInterpeter(
	jobID string,
	job *model.Job,
	matrix map[string]any,
	gitCtx *model.GithubContext,
	results map[string]*JobResult,
	vars map[string]string,
	inputs map[string]any,
) exprparser.Interpreter

NewInterpeter returns an interpeter used in the server, need github, needs, strategy, matrix, inputs context only, see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability

func ParseCallerSecrets added in v1.3.0

func ParseCallerSecrets(node yaml.Node) (inherit bool, mapping map[string]string, err error)

ParseCallerSecrets decodes a caller's "secrets:" YAML node into one of two forms:

  • inherit == true: the caller wrote `secrets: inherit`; mapping is nil
  • inherit == false, mapping == {alias: source_name}: explicit mapping. Each value must be of the form `${{ secrets.NAME }}`.

Both alias and source name are upper-cased: secret names are case-insensitive (matching GitHub), and Gitea stores secrets upper-cased, so this keeps lookups and schema validation consistent.

func ReadWorkflowRawConcurrency

func ReadWorkflowRawConcurrency(content []byte) (*model.RawConcurrency, error)

func ValidateCallerSecrets added in v1.3.0

func ValidateCallerSecrets(spec *WorkflowCallSpec, mapping map[string]string) error

ValidateCallerSecrets checks a caller's parsed explicit-mapping `secrets:` against the called workflow's declared `on.workflow_call.secrets` schema.

Types

type ContainerSpec

type ContainerSpec struct {
	Image       string            `yaml:"image,omitempty"`
	Env         map[string]string `yaml:"env,omitempty"`
	Ports       []string          `yaml:"ports,omitempty"`
	Volumes     []string          `yaml:"volumes,omitempty"`
	Options     string            `yaml:"options,omitempty"`
	Credentials map[string]string `yaml:"credentials,omitempty"`
	Cmd         []string          `yaml:"cmd,omitempty"`
}

type Defaults

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

type Event

type Event struct {
	Name string
	// contains filtered or unexported fields
}

func ParseRawOn

func ParseRawOn(rawOn *yaml.Node) ([]*Event, error)

func (*Event) Acts

func (evt *Event) Acts() map[string][]string

func (*Event) Inputs

func (evt *Event) Inputs() []WorkflowDispatchInput

func (*Event) IsSchedule

func (evt *Event) IsSchedule() bool

func (*Event) Schedules

func (evt *Event) Schedules() []map[string]string

type ExpressionEvaluator

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

ExpressionEvaluator is copied from runner.expressionEvaluator, to avoid unnecessary dependencies

func NewExpressionEvaluator

func NewExpressionEvaluator(interpreter exprparser.Interpreter) *ExpressionEvaluator

func (ExpressionEvaluator) EvaluateYamlNode

func (ee ExpressionEvaluator) EvaluateYamlNode(node *yaml.Node) error

func (ExpressionEvaluator) Interpolate

func (ee ExpressionEvaluator) Interpolate(in string) string

type InputSpec added in v1.3.0

type InputSpec struct {
	Description string    `yaml:"description"`
	Required    bool      `yaml:"required"`
	Default     yaml.Node `yaml:"default"`
	Type        InputType `yaml:"type"`
}

InputSpec describes a single workflow_call input declaration.

type InputType added in v1.3.0

type InputType string

InputType enumerates the allowed types for a workflow_call input.

const (
	InputTypeString  InputType = "string"
	InputTypeBoolean InputType = "boolean"
	InputTypeNumber  InputType = "number"
)

type Job

type Job struct {
	Name               string                    `yaml:"name,omitempty"`
	RawNeeds           yaml.Node                 `yaml:"needs,omitempty"`
	RawRunsOn          yaml.Node                 `yaml:"runs-on,omitempty"`
	Env                yaml.Node                 `yaml:"env,omitempty"`
	If                 yaml.Node                 `yaml:"if,omitempty"`
	Steps              []*Step                   `yaml:"steps,omitempty"`
	TimeoutMinutes     string                    `yaml:"timeout-minutes,omitempty"`
	RawContinueOnError yaml.Node                 `yaml:"continue-on-error,omitempty"`
	Services           map[string]*ContainerSpec `yaml:"services,omitempty"`
	Strategy           Strategy                  `yaml:"strategy,omitempty"`
	RawContainer       yaml.Node                 `yaml:"container,omitempty"`
	Defaults           Defaults                  `yaml:"defaults,omitempty"`
	Outputs            map[string]string         `yaml:"outputs,omitempty"`
	Uses               string                    `yaml:"uses,omitempty"`
	With               map[string]any            `yaml:"with,omitempty"`
	RawSecrets         yaml.Node                 `yaml:"secrets,omitempty"`
	RawConcurrency     *model.RawConcurrency     `yaml:"concurrency,omitempty"`
	RawPermissions     yaml.Node                 `yaml:"permissions,omitempty"`
}

func (*Job) Clone

func (j *Job) Clone() *Job

func (*Job) EraseNeeds

func (j *Job) EraseNeeds() *Job

func (*Job) GetContinueOnError added in v1.3.0

func (j *Job) GetContinueOnError() bool

GetContinueOnError decodes the continue-on-error field to a bool. The field may be a literal bool or an already-evaluated expression node.

func (*Job) Needs

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

func (*Job) RunsOn

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

type JobOutputs added in v1.3.0

type JobOutputs map[string]map[string]string

JobOutputs is the per-job-id outputs map used for evaluating workflow_call outputs.

type JobResult

type JobResult struct {
	Needs   []string
	Result  string
	Outputs map[string]string
}

JobResult is the minimum requirement of job results for Interpeter

type OutputSpec added in v1.3.0

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

OutputSpec describes a single workflow_call output declaration.

type ParseOption

type ParseOption func(c *parseContext)

func WithGitContext

func WithGitContext(context *model.GithubContext) ParseOption

func WithInputs

func WithInputs(inputs map[string]any) ParseOption

func WithVars

func WithVars(vars map[string]string) ParseOption

type RunDefaults

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

type SecretSpec added in v1.3.0

type SecretSpec struct {
	Description string `yaml:"description"`
	Required    bool   `yaml:"required"`
}

SecretSpec describes a single workflow_call secret declaration.

type SingleWorkflow

type SingleWorkflow struct {
	Name           string            `yaml:"name,omitempty"`
	RawOn          yaml.Node         `yaml:"on,omitempty"`
	Env            map[string]string `yaml:"env,omitempty"`
	RawJobs        yaml.Node         `yaml:"jobs,omitempty"`
	Defaults       Defaults          `yaml:"defaults,omitempty"`
	RawPermissions yaml.Node         `yaml:"permissions,omitempty"`
	RunName        string            `yaml:"run-name,omitempty"`
}

SingleWorkflow is a workflow with single job and single matrix

func Parse

func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error)

func (*SingleWorkflow) Job

func (w *SingleWorkflow) Job() (string, *Job)

func (*SingleWorkflow) Marshal

func (w *SingleWorkflow) Marshal() ([]byte, error)

func (*SingleWorkflow) SetJob

func (w *SingleWorkflow) SetJob(id string, job *Job) error

type Step

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

func (*Step) String

func (s *Step) String() string

String gets the name of step

type Strategy

type Strategy struct {
	FailFastString    string    `yaml:"fail-fast,omitempty"`
	MaxParallelString string    `yaml:"max-parallel,omitempty"`
	RawMatrix         yaml.Node `yaml:"matrix,omitempty"`
}

type UsesKind added in v1.3.0

type UsesKind int

UsesKind enumerates the supported forms of a reusable workflow "uses:" value.

const (
	// UsesKindLocalSameRepo is "./<dir>/foo.yml" - a path inside the calling repository.
	// For example: "./.gitea/workflows/foo.yml"
	UsesKindLocalSameRepo UsesKind = iota + 1
	// UsesKindLocalCrossRepo is "owner/repo/<dir>/foo.yml@ref" - a workflow in another repo on the same instance.
	// For example: "owner/repo/.gitea/workflows/foo.yml@ref"
	UsesKindLocalCrossRepo
)

type UsesRef added in v1.3.0

type UsesRef struct {
	Kind  UsesKind
	Owner string // empty for UsesKindLocalSameRepo
	Repo  string // empty for UsesKindLocalSameRepo
	Path  string // workflow file path inside the source repo
	Ref   string // git ref; empty for UsesKindLocalSameRepo
}

UsesRef is the parsed form of a reusable workflow "uses:" value.

func ParseUses added in v1.3.0

func ParseUses(s string) (*UsesRef, error)

ParseUses parses the SYNTAX of a reusable workflow "uses:" value into a UsesRef. Two forms are supported:

  • "./<dir>/foo.yml" (UsesKindLocalSameRepo, no @ref)
  • "OWNER/REPO/<dir>/foo.yml@REF" (UsesKindLocalCrossRepo)

It deliberately does NOT validate that <dir> is an allowed workflow directory: the allowed directories are instance-configurable (WORKFLOW_DIRS / SCOPED_WORKFLOW_DIRS). The caller (services/actions.ResolveUses) enforces the directory allowlist. The returned Path is the cleaned, repo-relative file path.

type WorkflowCallSpec added in v1.3.0

type WorkflowCallSpec struct {
	Inputs  map[string]InputSpec
	Secrets map[string]SecretSpec
	Outputs map[string]OutputSpec
}

WorkflowCallSpec is the parsed "on.workflow_call" schema of a called workflow.

func ParseWorkflowCallSpec added in v1.3.0

func ParseWorkflowCallSpec(content []byte) (*WorkflowCallSpec, error)

ParseWorkflowCallSpec extracts on.workflow_call.{inputs,secrets,outputs} from a workflow YAML. Returns an error if the workflow does not declare on.workflow_call at all.

type WorkflowDispatchInput

type WorkflowDispatchInput struct {
	Name        string   `yaml:"name"`
	Description string   `yaml:"description"`
	Required    bool     `yaml:"required"`
	Default     string   `yaml:"default"`
	Type        string   `yaml:"type"`
	Options     []string `yaml:"options"`
}

Jump to

Keyboard shortcuts

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