Documentation
¶
Overview ¶
Package serve keeps running and runs workflows: on a schedule, or again and again, each run a process of probe of its own. It knows nothing of what a run does; it reads what the run reports.
Index ¶
Constants ¶
const ( StatusPassed = "passed" // StatusFailed is a run whose test or action failed. StatusFailed = "failed" // StatusError is a run that could not run its workflow, such as one // whose workflow cannot run as it is written. StatusError = "error" StatusTimeout = "timeout" // StatusStopped is a run that serve stopped as it was stopped itself. StatusStopped = "stopped" )
Run statuses, as the serve log tells how a run ended.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Name tells this serve from another in the log.
Name string `yaml:"name"`
Description string `yaml:"description"`
// Workers is how many runs go at once, across every workflow.
Workers int `yaml:"workers"`
Results Results `yaml:"results"`
// Grace is how long the runs going when serve is stopped are waited
// for before they are stopped too.
Grace Duration `yaml:"grace"`
Workflows map[string]*Workflow `yaml:"workflows"`
// contains filtered or unexported fields
}
Config is what a serve file says.
type ForEach ¶
type ForEach struct {
// Items is the output of the run that holds the items, a list of
// objects, whose keys are the vars of the runs for each.
Items string `yaml:"items"`
// Workflow is run for each item.
Workflow string `yaml:"workflow"`
// Concurrency is how many items are handled at once.
Concurrency int `yaml:"concurrency"`
// OnSuccess is run for an item whose Workflow passed, and OnFailure for
// one whose Workflow did not; none or empty for nothing.
OnSuccess string `yaml:"on_success"`
OnFailure string `yaml:"on_failure"`
}
ForEach is how the items a run gives are handled: each by a run of a workflow, and then by one of another as that run passed or not.
type Results ¶
type Results struct {
Dir string `yaml:"dir"`
// Keep is how long a run is kept after it ends; zero keeps every run.
Keep Duration `yaml:"keep"`
}
Results is where what the runs leave is kept.
type Run ¶
type Run struct {
Workflow string
ID string
StartedAt time.Time
FinishedAt time.Time
// ExitStatus is that of the process of the run; -1 when a signal ended
// it, or it could not be started.
ExitStatus int
Status string
// Dir is where the run left its report, report.json, and what it
// wrote, output.log.
Dir string
// Err is why the run could not be started, or nil.
Err error
}
Run is a run of a workflow, as serve tells it once it is over.
func (Run) OutputPath ¶
OutputPath returns the path of what the run wrote, its standard output and its standard error.
func (Run) ReportPath ¶
ReportPath returns the path of the json report of the run.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server runs the workflows of a Config.
func New ¶
New returns a Server of c, whose runs are processes of exe, the probe command, and which logs each run to log, each line with the name of c as serve.
func (*Server) Abort ¶
func (s *Server) Abort()
Abort kills the runs going at once, and any that would start, as a second signal to serve does.
type Workflow ¶
type Workflow struct {
Files []string `yaml:"files"`
Vars map[string]any `yaml:"vars"`
EnvFiles []string `yaml:"env_files"`
Jobs []string `yaml:"jobs"`
ReadOnly bool `yaml:"read_only"`
AllowHosts []string `yaml:"allow_hosts"`
AllowActions []string `yaml:"allow_actions"`
// Schedule is a cron expression of the times the workflow is run at.
Schedule string `yaml:"schedule"`
// Loop runs the workflow again once the run before it is over, after
// Interval.
Loop bool `yaml:"loop"`
Interval Duration `yaml:"interval"`
// Timeout ends a run that goes on longer; zero for none.
Timeout Duration `yaml:"timeout"`
// ForEach runs another workflow for each item a run of this one gives.
ForEach *ForEach `yaml:"for_each"`
// State names outputs of the workflow kept between its runs: saved once
// a run is over, and given to the next run as vars of the same names.
State []string `yaml:"state"`
// contains filtered or unexported fields
}
Workflow is a workflow serve runs, and how a run of it is started.