Types
type Instance struct {
Matrix map[string]string `json:"matrix,omitempty" yaml:"matrix,omitempty" toml:"matrix,omitempty"`
Task *int `json:"task,omitempty" yaml:"task,omitempty" toml:"task,omitempty"`
Status string `json:"status" yaml:"status" toml:"status"`
AttemptID string `json:"attempt_id,omitempty" yaml:"attempt_id,omitempty" toml:"attempt_id,omitempty"`
}
type Job struct {
Name string `json:"name,omitempty" yaml:"name,omitempty" toml:"name,omitempty"`
Command []string `json:"command" yaml:"command" toml:"command"`
Stage string `json:"stage,omitempty" yaml:"stage,omitempty" toml:"stage,omitempty"`
DependsOn []string `json:"depends_on,omitempty" yaml:"depends_on,omitempty" toml:"depends_on,omitempty"`
// DependsOnFinished names prerequisites that only need to finish.
DependsOnFinished []string `json:"depends_on_finished,omitempty" yaml:"depends_on_finished,omitempty" toml:"depends_on_finished,omitempty"`
// Timeout matches add --timeout, such as "2h".
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty" toml:"timeout,omitempty"`
// Retry matches add --retry.
Retry *int `json:"retry,omitempty" yaml:"retry,omitempty" toml:"retry,omitempty"`
// RetryDelay, RetryBackoff, and RetryMaxDelay match add --retry-delay,
// --retry-backoff, and --retry-max-delay.
RetryDelay string `json:"retry_delay,omitempty" yaml:"retry_delay,omitempty" toml:"retry_delay,omitempty"`
RetryBackoff float64 `json:"retry_backoff,omitempty" yaml:"retry_backoff,omitempty" toml:"retry_backoff,omitempty"`
RetryMaxDelay string `json:"retry_max_delay,omitempty" yaml:"retry_max_delay,omitempty" toml:"retry_max_delay,omitempty"`
Executor string `json:"executor,omitempty" yaml:"executor,omitempty" toml:"executor,omitempty"`
ExecutorOptions []string `json:"executor_options,omitempty" yaml:"executor_options,omitempty" toml:"executor_options,omitempty"`
Output []string `json:"output,omitempty" yaml:"output,omitempty" toml:"output,omitempty"`
Error []string `json:"error,omitempty" yaml:"error,omitempty" toml:"error,omitempty"`
// Artifacts matches add --artifact.
Artifacts []string `json:"artifacts,omitempty" yaml:"artifacts,omitempty" toml:"artifacts,omitempty"`
LogMode string `json:"log_mode,omitempty" yaml:"log_mode,omitempty" toml:"log_mode,omitempty"`
OpenMode string `json:"open_mode,omitempty" yaml:"open_mode,omitempty" toml:"open_mode,omitempty"`
WorkingDirectory string `json:"working_directory,omitempty" yaml:"working_directory,omitempty" toml:"working_directory,omitempty"`
Environment []string `json:"environment,omitempty" yaml:"env,omitempty" toml:"environment,omitempty"`
Array string `json:"array,omitempty" yaml:"array,omitempty" toml:"array,omitempty"`
Matrix []string `json:"matrix,omitempty" yaml:"matrix,omitempty" toml:"matrix,omitempty"`
MatrixExclude []map[string]string `json:"matrix_exclude,omitempty" yaml:"matrix_exclude,omitempty" toml:"matrix_exclude,omitempty"`
Status string `json:"status,omitempty" yaml:"status,omitempty" toml:"status,omitempty"`
AttemptID string `json:"attempt_id,omitempty" yaml:"attempt_id,omitempty" toml:"attempt_id,omitempty"`
Instances []Instance `json:"instances,omitempty" yaml:"instances,omitempty" toml:"instances,omitempty"`
}
type Manifest struct {
Version int `json:"version" yaml:"version" toml:"version"`
Source *Source `json:"source,omitempty" yaml:"source,omitempty" toml:"source,omitempty"`
Jobs []Job `json:"jobs" yaml:"jobs" toml:"jobs"`
}
func Decode(reader io.Reader, format string) (Manifest, error)
func FromQueue(queue model.Queue) (Manifest, error)
func FromRun(queue model.Queue, summary model.RunSummary, source Source) (Manifest, error)
func MergeRuns(project string, runs []SourceRun) (Manifest, error)
MergeRuns exports the listed runs of project as one manifest. Each command
ID is described by its latest snapshot, in first-appearance order.
type RemovedJob struct {
RunID string `json:"run_id"`
JobID string `json:"job_id"`
Name string `json:"name,omitempty"`
Command []string `json:"command"`
}
RemovedJob is a source job that the manifest no longer describes.
func Reconcile(manifest Manifest, queue model.Queue, store SourceStore) (model.Queue, []RemovedJob, error)
Reconcile links the jobs of a queue compiled from a run-exported manifest
to their source attempts, as copy does, and marks each job whose manifest
status differs from its source result with that status. It also lists
exported source jobs that the manifest no longer describes. A manifest
without a source is returned unchanged.
type Source struct {
Project string `json:"project" yaml:"project" toml:"project"`
RunIDs []string `json:"run_ids" yaml:"run_ids" toml:"run_ids"`
}
type SourceRun struct {
ID string
Queue model.Queue
Summary model.RunSummary
CWD string
// JobTimestamps returns a job's submitted and finished times in the run.
JobTimestamps func(jobID string) (submittedAt, finishedAt string)
// Has unexported fields.
}
SourceRun is a finished run that a manifest is exported from or reconciled
against.
func (run SourceRun) CommandTimestamp(command model.QueuedCommand) string
CommandTimestamp is the time that orders snapshots of the same command
across runs: the latest finish (or, for an unfinished job, submission) of
its jobs, falling back to the run's finish.
type SourceStore interface {
// Run loads a source run.
Run(runID string) (SourceRun, error)
// Attempt checks that attemptID of jobID exists in runID and returns the
// result it records, if finished.
Attempt(runID, jobID, attemptID string, command []string) (result model.JobResult, finished bool, err error)
// AttemptTimestamps returns an attempt's own submitted and finished times.
AttemptTimestamps(runID, jobID, attemptID string) (submittedAt, finishedAt string)
}
SourceStore reads the source runs and attempts that a run-exported manifest
names. Implementations own filesystem access and path validation.