Documentation
¶
Overview ¶
Package executor provides recipe execution for Buildfiles. It handles shell invocation, command interpolation, and execution orchestration.
Index ¶
- func ResolveWorkerCount(cliJobs, parallelDirective int) int
- type CommandError
- type ContextFactory
- type ExecResult
- type Executor
- func (e *Executor) ExecuteBlock(script string) (*ExecResult, error)
- func (e *Executor) ExecuteLine(cmdLine string) (*ExecResult, error)
- func (e *Executor) ExecuteRecipe(recipe *ast.Recipe, cmdCtx *eval.CommandContext) ([]*ExecResult, error)
- func (e *Executor) SetEmitter(emitter *output.Emitter)
- func (e *Executor) SetOutput(w io.Writer)
- func (e *Executor) SetTarget(target string)
- type Scheduler
- func (s *Scheduler) Execute(tasks []planner.BuildTask, ctxFactory ContextFactory) []TaskResult
- func (s *Scheduler) ExecuteWithCallback(tasks []planner.BuildTask, ctxFactory ContextFactory, callback TaskCallback) []TaskResult
- func (s *Scheduler) SetKeepGoing(keepGoing bool)
- func (s *Scheduler) Workers() int
- type ShellConfig
- type ShellNotFoundError
- type TaskCallback
- type TaskResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveWorkerCount ¶
ResolveWorkerCount determines the number of workers to use based on CLI -j flag and .parallel: directive value. The -j flag takes precedence when explicitly set (greater than 1), otherwise the .parallel: directive value is used.
Parameters:
- cliJobs: value from -j flag (default is 1)
- parallelDirective: value from .parallel: directive in Buildfile (0 if not set)
Returns the number of workers to use, minimum 1.
Types ¶
type CommandError ¶
CommandError represents a command execution failure.
func (*CommandError) Error ¶
func (e *CommandError) Error() string
type ContextFactory ¶
type ContextFactory func(target string) *eval.CommandContext
ContextFactory creates a CommandContext for a target.
type ExecResult ¶
type ExecResult struct {
Command string // The command that was executed
Stdout string // Standard output
Stderr string // Standard error
ExitCode int // Exit code (0 = success)
}
ExecResult holds the result of a shell command execution.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor handles shell command execution.
func NewExecutor ¶
func NewExecutor(config *ShellConfig) *Executor
NewExecutor creates a new Executor with the given configuration.
func NewExecutorWithValidation ¶
func NewExecutorWithValidation(config *ShellConfig) (*Executor, error)
NewExecutorWithValidation creates a new Executor and validates the shell. Returns an error if the shell is not found.
func (*Executor) ExecuteBlock ¶
func (e *Executor) ExecuteBlock(script string) (*ExecResult, error)
ExecuteBlock executes a shell script block.
func (*Executor) ExecuteLine ¶
func (e *Executor) ExecuteLine(cmdLine string) (*ExecResult, error)
ExecuteLine executes a single shell command line.
func (*Executor) ExecuteRecipe ¶
func (e *Executor) ExecuteRecipe(recipe *ast.Recipe, cmdCtx *eval.CommandContext) ([]*ExecResult, error)
ExecuteRecipe executes all commands in a recipe. Returns results for each command executed and stops on first error.
func (*Executor) SetEmitter ¶
SetEmitter sets the event emitter for the output system.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler handles parallel execution of build tasks.
func NewScheduler ¶
NewScheduler creates a scheduler with the given number of workers.
func (*Scheduler) Execute ¶
func (s *Scheduler) Execute(tasks []planner.BuildTask, ctxFactory ContextFactory) []TaskResult
Execute executes all tasks respecting dependencies.
func (*Scheduler) ExecuteWithCallback ¶
func (s *Scheduler) ExecuteWithCallback(tasks []planner.BuildTask, ctxFactory ContextFactory, callback TaskCallback) []TaskResult
ExecuteWithCallback executes tasks with a callback called at task start.
func (*Scheduler) SetKeepGoing ¶
SetKeepGoing enables or disables keep-going mode. When enabled, the scheduler continues building independent targets after a failure. Dependent targets are still skipped.
type ShellConfig ¶
type ShellConfig struct {
Shell string // Path to shell (default: platform-specific)
DryRun bool // If true, print commands without executing
Verbose bool // If true, print commands before executing
Quiet bool // If true, suppress command output (only show errors)
}
ShellConfig holds shell configuration for command execution.
func NewShellConfig ¶
func NewShellConfig() *ShellConfig
NewShellConfig creates a new ShellConfig with default values.
func (*ShellConfig) SetShell ¶
func (c *ShellConfig) SetShell(shell string)
SetShell sets the shell path.
func (*ShellConfig) Validate ¶
func (c *ShellConfig) Validate() error
Validate checks that the shell exists and is executable. It handles both absolute paths and shells found via PATH lookup.
func (*ShellConfig) WithOverride ¶
func (c *ShellConfig) WithOverride(shell string) *ShellConfig
WithOverride returns a new config with the shell overridden. The original config is not modified.
type ShellNotFoundError ¶
type ShellNotFoundError struct {
Shell string
}
ShellNotFoundError represents a missing shell error.
func (*ShellNotFoundError) Error ¶
func (e *ShellNotFoundError) Error() string
type TaskCallback ¶
type TaskCallback func(target string)
TaskCallback is called when a task starts execution.
type TaskResult ¶
type TaskResult struct {
Target string // The target that was built
Results []*ExecResult // Results from recipe execution
Error error // Error if execution failed
Skipped bool // True if task was skipped due to dependency failure
}
TaskResult represents the result of executing a single build task.