Documentation
¶
Overview ¶
Package store is the durable run-history layer: an embedded SQLite database (pure-Go modernc driver) plus a central directory of per-run log files. It is written by the persistence sink during a run and read by the `local-ci runs` / `local-ci log` commands (and later the server/UI).
Index ¶
- Constants
- Variables
- func DefaultDBPath() (string, error)
- type Job
- type JobSample
- type Run
- type Store
- func (s *Store) Close() error
- func (s *Store) CountRuns(projectPath string, all bool) (int, error)
- func (s *Store) CreateRun(r Run) error
- func (s *Store) DBPath() string
- func (s *Store) DeleteRun(id string) error
- func (s *Store) FinishJob(id int64, status string, finishedAt time.Time, dur time.Duration, exitCode int, ...) error
- func (s *Store) FinishRun(id, status string, finishedAt time.Time, dur time.Duration, errMsg string) error
- func (s *Store) GetJobs(runID string) ([]Job, error)
- func (s *Store) GetRun(id string) (Run, error)
- func (s *Store) JobSamples(projectPath string, all bool, window int) ([]JobSample, error)
- func (s *Store) ListRuns(projectPath string, all bool, limit, offset int) ([]Run, error)
- func (s *Store) OldRunIDs(projectPath string, all bool, keep int) ([]string, error)
- func (s *Store) Root() string
- func (s *Store) RunDir(id string) string
- func (s *Store) StartJob(j Job) (int64, error)
Constants ¶
const ( StatusRunning = "running" StatusPassed = "passed" StatusFailed = "failed" )
Run statuses.
Variables ¶
var ErrNotFound = errors.New("run not found")
ErrNotFound is returned by GetRun when no run matches the id.
Functions ¶
func DefaultDBPath ¶
DefaultDBPath returns the standard database path under the XDG data dir.
Types ¶
type Job ¶
type Job struct {
ID int64
RunID string
Name string
Stage string
ExecKind string
GroupLabel string
Status string
StartedAt time.Time
FinishedAt time.Time
Duration time.Duration
ExitCode int
Error string
LogPath string
}
Job is a persisted job within a run.
type JobSample ¶ added in v0.2.3
type JobSample struct {
RunID string
Name string
Status string
StartedAt time.Time
Duration time.Duration
}
JobSample is one job execution inside the recent-runs window, ordered oldest-first — the raw material for duration sparklines and flakiness flags.
type Run ¶
type Run struct {
ID string
ProjectPath string
ConfigPath string
Mode string
Status string
StartedAt time.Time
FinishedAt time.Time
Duration time.Duration
Error string
Commit string // HEAD SHA at run start ("" outside a git repo)
Branch string // branch name at run start
}
Run is a persisted pipeline run. Times are zero and Duration is 0 until the run finishes.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps the SQLite database and the run-log root directory.
func Open ¶
Open opens (creating if needed) the store at dbPath, applying the schema. The parent directory is created quietly; it intentionally does not use fs.MakeDefaultDir, which prints to stdout.
func (*Store) CountRuns ¶ added in v0.2.0
CountRuns returns the total number of runs (for pagination), scoped to projectPath unless all is true.
func (*Store) DeleteRun ¶ added in v0.2.0
DeleteRun removes a run, its job rows, and its on-disk log directory. A missing log directory is not an error.
func (*Store) FinishJob ¶
func (s *Store) FinishJob(id int64, status string, finishedAt time.Time, dur time.Duration, exitCode int, errMsg string) error
FinishJob records a job's terminal status, finish time, duration and exit code.
func (*Store) FinishRun ¶
func (s *Store) FinishRun(id, status string, finishedAt time.Time, dur time.Duration, errMsg string) error
FinishRun records a run's terminal status, finish time and duration.
func (*Store) JobSamples ¶ added in v0.2.3
JobSamples returns every job execution from the `window` most recent runs of projectPath (all projects when all is true), ordered oldest run first.
func (*Store) ListRuns ¶
ListRuns returns runs newest first, skipping offset and capped at limit. When all is false the list is restricted to projectPath. limit <= 0 defaults to 20.
func (*Store) OldRunIDs ¶ added in v0.2.0
OldRunIDs returns the ids of every run beyond the keep most recent (newest first), scoped to projectPath unless all is true — the candidates for cleanup.