watch

package
v3.37.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxConsecutiveErrors is the number of consecutive polling failures
	// before the watch loop aborts.
	DefaultMaxConsecutiveErrors = 10

	// DefaultRequestTimeout is the per-request timeout for each polling call.
	DefaultRequestTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func WatchBuild

func WatchBuild(
	ctx context.Context,
	client *buildkite.Client,
	org, pipeline string,
	buildNumber int,
	interval time.Duration,
	onStatus StatusFunc,
	opts ...WatchOpt,
) (buildkite.Build, error)

WatchBuild polls a build until it reaches a terminal state (FinishedAt != nil). It calls onStatus after each successful poll so callers can render progress.

Types

type BuildStatus

type BuildStatus struct {
	NewlyFailed      []buildkite.Job
	NewlyRetryPassed []buildkite.Job
	Running          []buildkite.Job
	TotalRunning     int
	Summary          JobSummary
	Build            buildkite.Build
}

BuildStatus is the output of JobTracker.Update().

type FormattedJob

type FormattedJob struct {
	buildkite.Job
}

FormattedJob wraps a Buildkite job with watch-specific formatting and classification helpers.

func NewFormattedJob

func NewFormattedJob(j buildkite.Job) FormattedJob

NewFormattedJob wraps a Buildkite job.

func (FormattedJob) DisplayName

func (j FormattedJob) DisplayName() string

DisplayName returns a human-readable name for a job.

func (FormattedJob) Duration

func (j FormattedJob) Duration() time.Duration

Duration returns the elapsed duration for a job.

func (FormattedJob) IsFailed

func (j FormattedJob) IsFailed() bool

func (FormattedJob) IsSoftFailed

func (j FormattedJob) IsSoftFailed() bool

func (FormattedJob) IsTerminalFailureState

func (j FormattedJob) IsTerminalFailureState() bool

type JobSummary

type JobSummary struct {
	Passed     int `json:"passed"`
	Failed     int `json:"failed"`
	SoftFailed int `json:"soft_failed"`
	Running    int `json:"running"`
	Scheduled  int `json:"scheduled"`
	Blocked    int `json:"blocked"`
	Skipped    int `json:"skipped"`
	Waiting    int `json:"waiting"`
}

JobSummary aggregates job counts by high-level state.

func (JobSummary) String

func (s JobSummary) String() string

String returns a human-readable summary of non-zero job counts.

type JobTracker

type JobTracker struct {
	// contains filtered or unexported fields
}

JobTracker tracks job state changes across polls.

func NewJobTracker

func NewJobTracker() *JobTracker

NewJobTracker creates a new JobTracker.

func (*JobTracker) FailedJobs added in v3.33.1

func (t *JobTracker) FailedJobs() []buildkite.Job

FailedJobs returns all hard-failed, non-superseded jobs (excludes soft failures), sorted by start time.

func (*JobTracker) PassedJobs added in v3.35.0

func (t *JobTracker) PassedJobs() []buildkite.Job

PassedJobs returns all non-superseded jobs that passed, sorted by start time.

func (*JobTracker) Update

func (t *JobTracker) Update(b buildkite.Build) BuildStatus

Update processes a build and returns the current status with any state changes.

type StatusFunc

type StatusFunc func(b buildkite.Build) error

StatusFunc is called on each successful poll with the latest build state. Returning an error aborts the watch loop and propagates that error to the caller.

type TestStatusFunc added in v3.35.0

type TestStatusFunc func(newTestChanges []buildkite.BuildTest) error

TestStatusFunc is called with newly-seen test changes on each poll. Returning an error aborts the watch loop.

type TestTracker added in v3.35.0

type TestTracker struct {
	// contains filtered or unexported fields
}

TestTracker tracks which test executions have already been reported, so that each test change is only surfaced once across polling iterations.

func NewTestTracker added in v3.35.0

func NewTestTracker() *TestTracker

NewTestTracker creates a new TestTracker.

func (*TestTracker) Update added in v3.35.0

func (t *TestTracker) Update(tests []buildkite.BuildTest) []buildkite.BuildTest

Update processes a list of build tests and returns only those with at least one execution that has not been seen before.

type WatchOpt added in v3.35.0

type WatchOpt func(*watchConfig)

WatchOpt configures optional WatchBuild behavior.

func WithRetriedJobs added in v3.37.0

func WithRetriedJobs() WatchOpt

WithRetriedJobs includes retried (superseded) jobs in each poll so the tracker can correlate original failures with their retry outcomes.

func WithTestTracking added in v3.35.0

func WithTestTracking(fn TestStatusFunc) WatchOpt

WithTestTracking enables polling BuildTests.List for failed tests on each iteration, calling onTestStatus with any newly-seen test changes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL