preflight

package
v3.38.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cleanup

func Cleanup(dir string, ref string, debug bool) error

Cleanup deletes the preflight branch from the remote. If the branch no longer exists on the remote, it is treated as success.

func CleanupRefs added in v3.35.2

func CleanupRefs(dir string, refs []string, debug bool) error

CleanupRefs deletes multiple refs from the remote in a single git push. Refs that no longer exist on the remote are silently ignored.

func RepositoryRoot added in v3.35.0

func RepositoryRoot(dir string, debug bool) (string, error)

RepositoryRoot returns the top-level path for the git repository containing dir.

func ResolveBuilds added in v3.35.2

func ResolveBuilds(ctx context.Context, client *buildkite.Client, org, pipeline string, branches []BranchBuild) error

ResolveBuilds looks up the most recent build for each preflight branch and populates the Build field. Branches with no matching build retain a nil Build.

func ValidateExitPolicies added in v3.38.0

func ValidateExitPolicies(policies []ExitPolicy, watch bool) error

Types

type BranchBuild added in v3.35.2

type BranchBuild struct {
	Branch string
	Ref    string
	Build  *buildkite.Build
}

BranchBuild represents a preflight branch and its associated build status.

func ListRemotePreflightBranches added in v3.35.2

func ListRemotePreflightBranches(dir string, debug bool) ([]BranchBuild, error)

ListRemotePreflightBranches returns all remote branches matching bk/preflight/*.

func LookupRemotePreflightBranch added in v3.35.2

func LookupRemotePreflightBranch(dir, uuid string, debug bool) (*BranchBuild, error)

LookupRemotePreflightBranch returns the remote bk/preflight/<uuid> branch if it exists, or nil if no such branch is present on the remote.

func (BranchBuild) IsCompleted added in v3.35.2

func (bb BranchBuild) IsCompleted() bool

IsCompleted returns true if the associated build has reached a terminal state (passed, failed, canceled, etc.), or if no build was found for the branch.

type ExitPolicy added in v3.38.0

type ExitPolicy int
const (
	ExitOnBuildFailing ExitPolicy = iota
	ExitOnBuildTerminal
)

func EffectiveExitPolicy added in v3.38.0

func EffectiveExitPolicy(policies []ExitPolicy) ExitPolicy

func (*ExitPolicy) UnmarshalText added in v3.38.0

func (p *ExitPolicy) UnmarshalText(text []byte) error

type FileChange

type FileChange struct {
	Status string // e.g. "M", "A", "D", "R"
	Path   string
}

FileChange represents a single file changed in the snapshot.

func (FileChange) StatusSymbol

func (f FileChange) StatusSymbol() string

StatusSymbol returns a human-readable symbol for the file change status.

type RunSummaryFailure added in v3.37.0

type RunSummaryFailure struct {
	RunID         string                `json:"run_id"`
	SuiteName     string                `json:"suite_name"`
	SuiteSlug     string                `json:"suite_slug"`
	Name          string                `json:"name"`
	Location      string                `json:"location"`
	FailureReason string                `json:"failure_reason"`
	LatestFail    *RunSummaryLatestFail `json:"latest_fail,omitempty"`
}

type RunSummaryGetOptions added in v3.37.0

type RunSummaryGetOptions struct {
	Result          string
	IncludeFailures bool
	State           string
}

type RunSummaryLatestFail added in v3.37.0

type RunSummaryLatestFail struct {
	FailureReason   string                      `json:"failure_reason"`
	FailureExpanded []buildkite.FailureExpanded `json:"failure_expanded,omitempty"`
}

type RunSummaryResponse added in v3.37.0

type RunSummaryResponse struct {
	Tests RunSummaryTests `json:"tests"`
}

func (RunSummaryResponse) SummaryResult added in v3.37.0

func (r RunSummaryResponse) SummaryResult() SummaryResult

type RunSummaryRun added in v3.37.0

type RunSummaryRun struct {
	Suite   RunSummarySuite `json:"suite"`
	Passed  int             `json:"passed"`
	Failed  int             `json:"failed"`
	Skipped int             `json:"skipped"`
}

type RunSummaryService added in v3.37.0

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

func NewRunSummaryService added in v3.37.0

func NewRunSummaryService(client *buildkite.Client) *RunSummaryService

func (*RunSummaryService) Get added in v3.37.0

type RunSummarySuite added in v3.37.0

type RunSummarySuite struct {
	ID   string `json:"id"`
	Slug string `json:"slug"`
	Name string `json:"name"`
}

type RunSummaryTests added in v3.37.0

type RunSummaryTests struct {
	Runs     map[string]RunSummaryRun `json:"runs"`
	Failures []RunSummaryFailure      `json:"failures"`
}

type SnapshotOption

type SnapshotOption func(*snapshotConfig)

SnapshotOption configures Snapshot behavior.

func WithDebug

func WithDebug() SnapshotOption

WithDebug enables verbose git output on failure.

type SnapshotResult

type SnapshotResult struct {
	Commit string
	Ref    string
	Branch string
	Files  []FileChange
}

SnapshotResult holds the output of a successful snapshot operation.

func Snapshot

func Snapshot(dir string, preflightID uuid.UUID, opts ...SnapshotOption) (*SnapshotResult, error)

Snapshot pushes the current working tree state to a remote preflight ref. It always creates a distinct commit on top of HEAD (even when the worktree is clean) without touching the real git index.

func (SnapshotResult) ShortCommit added in v3.35.0

func (r SnapshotResult) ShortCommit() string

type SourceContext added in v3.36.0

type SourceContext struct {
	Branch string
	Commit string
}

SourceContext describes the original git state that preflight was created from.

func ResolveSourceContext added in v3.36.0

func ResolveSourceContext(dir string, debug bool) (SourceContext, error)

ResolveSourceContext returns the current branch name (if any) and HEAD commit.

type SummaryFailureDetail added in v3.37.0

type SummaryFailureDetail struct {
	Backtrace []string `json:"backtrace"`
	Expanded  []string `json:"expanded"`
}

type SummaryOptions added in v3.37.0

type SummaryOptions struct {
	IncludeFailures bool
}

type SummaryResult added in v3.37.0

type SummaryResult struct {
	Tests SummaryTests `json:"tests"`
}

type SummaryTestFailure added in v3.37.0

type SummaryTestFailure struct {
	RunID         string                 `json:"run_id"`
	SuiteName     string                 `json:"suite_name,omitempty"`
	SuiteSlug     string                 `json:"suite_slug"`
	Name          string                 `json:"name"`
	Location      string                 `json:"location"`
	Message       string                 `json:"message"`
	FailureReason string                 `json:"failure_reason"`
	FailureDetail []SummaryFailureDetail `json:"failure_detail"`
}

type SummaryTestRun added in v3.37.0

type SummaryTestRun struct {
	RunID     string `json:"run_id"`
	SuiteName string `json:"suite_name,omitempty"`
	SuiteSlug string `json:"suite_slug"`
	Passed    int    `json:"passed"`
	Failed    int    `json:"failed"`
	Skipped   int    `json:"skipped"`
}

type SummaryTests added in v3.37.0

type SummaryTests struct {
	Runs     map[string]SummaryTestRun `json:"runs"`
	Failures []SummaryTestFailure      `json:"failures"`
}

Jump to

Keyboard shortcuts

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