Documentation
¶
Index ¶
- func BuildCommand(runCommand, shell string) []string
- func BuildNeedsContext(job workflow.Job, jobResults map[string]Status, ...) map[string]JobNeedsData
- func CollectSecrets(secretsMap map[string]any, envMaps ...map[string]string) []string
- func DeduplicateAndSortSecrets(secrets []string) []string
- func FindRepoRoot(startPath string) (string, error)
- func IsSecretKey(key string) bool
- func MaskSecrets(output string, secrets []string) string
- func NormalizeLineEndings(content string, mode string) (string, error)
- func ParseTimeoutMinutes(value any) (time.Duration, error)
- func TopologicalSort(wf *workflow.Workflow) ([]string, error)
- func ValidateNeeds(wf *workflow.Workflow) error
- func WithTimeout(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
- type ExpressionContext
- func (ec *ExpressionContext) Interpolate(input string) (string, error)
- func (ec *ExpressionContext) InterpolateMap(input map[string]string) (map[string]string, error)
- func (ec *ExpressionContext) InterpolateWith(input map[string]any) (map[string]any, error)
- func (ec *ExpressionContext) SetCancelled(cancelled bool)
- func (ec *ExpressionContext) SetCurrentStepID(stepID string)
- func (ec *ExpressionContext) SetMatrix(matrix map[string]any)
- func (ec *ExpressionContext) SetNeedsContext(needs map[string]JobNeedsData)
- func (ec *ExpressionContext) SetStepResults(results []*StepResult)
- type GitHubEnvFile
- type GitHubOutputFile
- type GitHubPathFile
- type JobNeedsData
- type JobResult
- type JobRunner
- type JobStatus
- type RunConfig
- type Runner
- type ShellResolver
- type Status
- type StepOutputs
- type StepResult
- type StepRunner
- type TimeoutConfig
- type UnsupportedError
- type WorkflowResult
- type WorkflowRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCommand ¶
BuildCommand builds the command slice for a given shell and run command.
func BuildNeedsContext ¶
func BuildNeedsContext( job workflow.Job, jobResults map[string]Status, jobOutputs map[string]map[string]string, matrixJobs map[string]bool, ) map[string]JobNeedsData
BuildNeedsContext builds the needs context map for expression evaluation.
func CollectSecrets ¶
CollectSecrets collects secret strings from a secrets map and environment variable maps.
func DeduplicateAndSortSecrets ¶
DeduplicateAndSortSecrets deduplicates and sorts secret strings by length descending.
func FindRepoRoot ¶ added in v1.0.3
FindRepoRoot finds the git repository root by walking up from startPath. Returns the directory containing .git/ or .github/. Falls back to the workflow file's directory if neither is found.
func IsSecretKey ¶
IsSecretKey returns true if key contains common secret keywords (case-insensitive).
func MaskSecrets ¶
MaskSecrets replaces all occurrences of secret values in output with "***".
func NormalizeLineEndings ¶ added in v1.4.0
NormalizeLineEndings handles line ending conversion based on mode. Modes: "convert" (CRLF→LF), "preserve" (keep as-is), "error" (reject CRLF)
func ParseTimeoutMinutes ¶
ParseTimeoutMinutes parses timeout-minutes value which can be integer or float.
func TopologicalSort ¶
TopologicalSort returns job IDs of the workflow sorted in topological execution order.
func ValidateNeeds ¶
ValidateNeeds validates the job needs graph in a workflow.
func WithTimeout ¶
WithTimeout returns a context with a timeout and its cancel function.
Types ¶
type ExpressionContext ¶
type ExpressionContext struct {
// contains filtered or unexported fields
}
ExpressionContext holds the context for expression interpolation.
func NewExpressionContext ¶
func NewExpressionContext( env map[string]string, github map[string]string, runner map[string]string, stepOutputs *StepOutputs, ) *ExpressionContext
NewExpressionContext creates a new ExpressionContext.
func (*ExpressionContext) Interpolate ¶
func (ec *ExpressionContext) Interpolate(input string) (string, error)
Interpolate interpolates expressions in a string. Supports: ${{ env.KEY }}, ${{ github.KEY }}, ${{ runner.KEY }}, ${{ steps.STEP_ID.outputs.KEY }}, ${{ matrix.KEY }}, ${{ needs.JOB_ID.result }}, ${{ needs.JOB_ID.outputs.KEY }}
func (*ExpressionContext) InterpolateMap ¶
InterpolateMap interpolates expressions in all values of a map.
func (*ExpressionContext) InterpolateWith ¶
InterpolateWith interpolates expressions in all values of a map[string]any (e.g. step.With).
func (*ExpressionContext) SetCancelled ¶
func (ec *ExpressionContext) SetCancelled(cancelled bool)
SetCancelled sets the cancelled state.
func (*ExpressionContext) SetCurrentStepID ¶
func (ec *ExpressionContext) SetCurrentStepID(stepID string)
SetCurrentStepID sets the current step ID for steps context.
func (*ExpressionContext) SetMatrix ¶
func (ec *ExpressionContext) SetMatrix(matrix map[string]any)
SetMatrix sets the matrix context for expression evaluation.
func (*ExpressionContext) SetNeedsContext ¶
func (ec *ExpressionContext) SetNeedsContext(needs map[string]JobNeedsData)
SetNeedsContext sets the needs context for expression evaluation.
func (*ExpressionContext) SetStepResults ¶
func (ec *ExpressionContext) SetStepResults(results []*StepResult)
SetStepResults sets the step results for status function evaluation.
type GitHubEnvFile ¶
type GitHubEnvFile struct {
// contains filtered or unexported fields
}
GitHubEnvFile handles the GITHUB_ENV file for a job.
func NewGitHubEnvFile ¶
func NewGitHubEnvFile(jobInstanceID string) *GitHubEnvFile
NewGitHubEnvFile creates a new GitHubEnvFile for a job.
func (*GitHubEnvFile) EnsureDir ¶
func (f *GitHubEnvFile) EnsureDir() error
EnsureDir creates the directory for the file.
func (*GitHubEnvFile) Path ¶
func (f *GitHubEnvFile) Path() string
Path returns the path to the GITHUB_ENV file.
func (*GitHubEnvFile) ReadAndParse ¶
func (f *GitHubEnvFile) ReadAndParse() (map[string]string, error)
ReadAndParse reads the GITHUB_ENV file, parses it, and returns the parsed variables. It also truncates the file to avoid reapplying values. Supports both single-line (KEY=value) and multiline (KEY<<DELIMITER ... DELIMITER) formats.
func (*GitHubEnvFile) Write ¶
func (f *GitHubEnvFile) Write(key, value string) error
Write writes a key-value pair to the GITHUB_ENV file. Supports both single-line and multiline formats.
type GitHubOutputFile ¶
type GitHubOutputFile struct {
// contains filtered or unexported fields
}
GitHubOutputFile handles the GITHUB_OUTPUT file for a step.
func NewGitHubOutputFile ¶
func NewGitHubOutputFile(jobInstanceID, stepID string) *GitHubOutputFile
NewGitHubOutputFile creates a new GitHubOutputFile for a step.
func (*GitHubOutputFile) EnsureDir ¶
func (f *GitHubOutputFile) EnsureDir() error
EnsureDir creates the directory for the file.
func (*GitHubOutputFile) Path ¶
func (f *GitHubOutputFile) Path() string
Path returns the path to the GITHUB_OUTPUT file.
func (*GitHubOutputFile) ReadAndParse ¶
func (f *GitHubOutputFile) ReadAndParse() (map[string]string, error)
ReadAndParse reads the GITHUB_OUTPUT file, parses it, and returns the outputs.
func (*GitHubOutputFile) Write ¶
func (f *GitHubOutputFile) Write(key, value string) error
Write writes a key-value pair to the GITHUB_OUTPUT file. Supports both single-line and multiline formats.
type GitHubPathFile ¶
type GitHubPathFile struct {
// contains filtered or unexported fields
}
GitHubPathFile handles the GITHUB_PATH file for a job.
func NewGitHubPathFile ¶
func NewGitHubPathFile(jobInstanceID string) *GitHubPathFile
NewGitHubPathFile creates a new GitHubPathFile for a job.
func (*GitHubPathFile) EnsureDir ¶
func (f *GitHubPathFile) EnsureDir() error
EnsureDir creates the directory for the file.
func (*GitHubPathFile) Path ¶
func (f *GitHubPathFile) Path() string
Path returns the path to the GITHUB_PATH file.
func (*GitHubPathFile) ReadAndParse ¶
func (f *GitHubPathFile) ReadAndParse() ([]string, error)
ReadAndParse reads the GITHUB_PATH file, parses it, and returns the paths. It also truncates the file to avoid reapplying values.
func (*GitHubPathFile) Write ¶
func (f *GitHubPathFile) Write(path string) error
Write writes a path to the GITHUB_PATH file.
type JobNeedsData ¶
JobNeedsData contains the aggregated result and resolved outputs of a needed job.
type JobResult ¶
type JobResult struct {
JobID string
Steps []*StepResult
ExitCode int
Error error
Status Status
Outputs map[string]string
}
JobResult represents the result of executing a job.
type JobRunner ¶
type JobRunner struct {
// contains filtered or unexported fields
}
JobRunner handles execution of jobs within Docker containers.
func NewJobRunner ¶
NewJobRunner creates a new job runner.
func (*JobRunner) RunJob ¶
func (jr *JobRunner) RunJob(ctx context.Context, job workflow.Job, jobID string, workflowEnv map[string]string, workflowDefaults *workflow.Defaults, wf *workflow.Workflow, workspacePath string, needsCtx map[string]JobNeedsData) (*JobResult, error)
RunJob executes a job in a Docker container.
type JobStatus ¶
type JobStatus struct {
// contains filtered or unexported fields
}
JobStatus represents the current job execution status.
type RunConfig ¶
type RunConfig struct {
WorkflowPath string
Job string
DryRun bool
Parallel int
CRLF string
Platform string
Offline bool
TimeoutConfig TimeoutConfig
}
RunConfig holds configuration for a workflow run.
type Runner ¶
type Runner interface {
// RunWorkflow executes a workflow and returns the result.
RunWorkflow(ctx context.Context, wf *workflow.Workflow) (*WorkflowResult, error)
// RunJob executes a single job and returns the result.
RunJob(ctx context.Context, job workflow.Job, jobID string, workflowEnv map[string]string, workflowDefaults *workflow.Defaults, wf *workflow.Workflow) (*JobResult, error)
}
Runner defines the interface for running workflows.
type ShellResolver ¶
ShellResolver provides shell resolution with precedence logic.
func NewShellResolver ¶
func NewShellResolver(workflowDefaults, jobDefaults *workflow.Defaults) *ShellResolver
NewShellResolver creates a new shell resolver.
type Status ¶
type Status string
Status represents the execution status of a step, job, or workflow.
const ( // StatusPending indicates the item has not started yet. StatusPending Status = "pending" // StatusRunning indicates the item is currently executing. StatusRunning Status = "running" // StatusSuccess indicates the item completed successfully. StatusSuccess Status = "success" // StatusFailure indicates the item failed. StatusFailure Status = "failure" // StatusCancelled indicates the item was cancelled. StatusCancelled Status = "cancelled" // StatusSkipped indicates the item was skipped. StatusSkipped Status = "skipped" )
func AggregateJobResults ¶
AggregateJobResults aggregates job instance results per original job ID.
type StepOutputs ¶
type StepOutputs struct {
// contains filtered or unexported fields
}
StepOutputs stores outputs from steps for expression interpolation.
func NewStepOutputs ¶
func NewStepOutputs() *StepOutputs
NewStepOutputs creates a new StepOutputs store.
func (*StepOutputs) GetOutput ¶
func (so *StepOutputs) GetOutput(stepID, key string) (string, bool)
GetOutput returns a specific output value for a step.
func (*StepOutputs) GetOutputs ¶
func (so *StepOutputs) GetOutputs(stepID string) map[string]string
GetOutputs returns the outputs for a step.
func (*StepOutputs) SetOutputs ¶
func (so *StepOutputs) SetOutputs(stepID string, outputs map[string]string)
SetOutputs sets the outputs for a step.
type StepResult ¶
type StepResult struct {
ExitCode int
Stdout string
Stderr string
Status Status
Outcome Status // Raw outcome before continue-on-error
Conclusion Status // Final conclusion after continue-on-error
ContinueOnError bool
}
StepResult represents the result of executing a step.
type StepRunner ¶
type StepRunner struct {
// contains filtered or unexported fields
}
StepRunner handles execution of individual steps within a job container.
func NewStepRunner ¶
func NewStepRunner(cli *client.Client, containerID, workingDir string, crlf string) *StepRunner
NewStepRunner creates a new step runner for a job container.
func (*StepRunner) RunStep ¶
func (sr *StepRunner) RunStep(ctx context.Context, step workflow.Step, jobEnv map[string]string, shell, workingDir string, githubOutputFile *GitHubOutputFile, exprContext *ExpressionContext, jobTimeout, stepTimeout time.Duration) (*StepResult, error)
RunStep executes a single step and returns the result.
func (*StepRunner) SetSecrets ¶
func (sr *StepRunner) SetSecrets(secrets []string)
SetSecrets sets the secret values to mask in step output.
type TimeoutConfig ¶
type TimeoutConfig struct {
JobTimeout time.Duration
StepTimeout time.Duration
DefaultJob time.Duration
DefaultStep time.Duration
}
TimeoutConfig holds timeout configuration for job/step execution.
func DefaultTimeoutConfig ¶
func DefaultTimeoutConfig() TimeoutConfig
DefaultTimeoutConfig returns sensible defaults for timeouts.
func (*TimeoutConfig) GetEffectiveJobTimeout ¶
func (tc *TimeoutConfig) GetEffectiveJobTimeout(jobTimeout time.Duration) time.Duration
GetEffectiveJobTimeout returns the effective timeout for a job. Uses default if not set.
func (*TimeoutConfig) GetEffectiveStepTimeout ¶
func (tc *TimeoutConfig) GetEffectiveStepTimeout(jobTimeout, stepTimeout time.Duration) time.Duration
GetEffectiveStepTimeout returns the effective timeout for a step. Step timeout overrides job timeout. If neither is set, uses default.
type UnsupportedError ¶
UnsupportedError represents an error for unsupported features with exit code 3.
func NewUnsupportedError ¶
func NewUnsupportedError(msg string) *UnsupportedError
NewUnsupportedError creates a new UnsupportedError with exit code 3.
func (*UnsupportedError) Code ¶
func (e *UnsupportedError) Code() int
func (*UnsupportedError) Error ¶
func (e *UnsupportedError) Error() string
type WorkflowResult ¶
type WorkflowResult struct {
Jobs map[string]*JobResult
JobOrder []string
ExitCode int
Error error
Status Status
}
WorkflowResult represents the result of executing a workflow.
type WorkflowRunner ¶
type WorkflowRunner struct {
// contains filtered or unexported fields
}
WorkflowRunner handles execution of workflows including job dependency ordering.
func NewWorkflowRunner ¶
func NewWorkflowRunner(jobRunner *JobRunner, offline bool) *WorkflowRunner
NewWorkflowRunner creates a new WorkflowRunner.
func (*WorkflowRunner) RunWorkflow ¶
func (wr *WorkflowRunner) RunWorkflow( ctx context.Context, wf *workflow.Workflow, expandedWf *workflow.Workflow, workspacePath string, workflowEnv map[string]string, jobFilter string, parallel int, ) (*WorkflowResult, error)
RunWorkflow runs a workflow with parallel job execution for unblocked jobs.