jobparser

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 NewInterpeter

func NewInterpeter(
	jobID string,
	job *model.Job,
	matrix map[string]interface{},
	gitCtx *model.GithubContext,
	results map[string]*JobResult,
	vars map[string]string,
	inputs map[string]interface{},
) 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 ReadWorkflowRawConcurrency

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

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 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"`
	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]interface{}    `yaml:"with,omitempty"`
	RawSecrets     yaml.Node                 `yaml:"secrets,omitempty"`
	RawConcurrency *model.RawConcurrency     `yaml:"concurrency,omitempty"`
}

func (*Job) Clone

func (j *Job) Clone() *Job

func (*Job) EraseNeeds

func (j *Job) EraseNeeds() *Job

func (*Job) Needs

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

func (*Job) RunsOn

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

type JobResult

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

JobResult is the minimum requirement of job results for Interpeter

type ParseOption

type ParseOption func(c *parseContext)

func WithGitContext

func WithGitContext(context *model.GithubContext) ParseOption

func WithJobResults

func WithJobResults(results map[string]string) 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 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"`
}

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 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