buildbucket

package
v0.0.0-...-8be5f70 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const BuildSummaryStorageDuration = time.Hour * 24 * 30 * 20 // ~20 months

BuildSummaryStorageDuration is the maximum lifetime of a BuildSummary.

Lifetime is the time elapsed since the Build creation time. Cron runs periodically to scan and remove all the Builds of which lifetime exceeded this duration.

BuildSummaries are kept alive longer than builds in buildbuckets. So we can compute blamelist for builds that are at the end of their lifetime.

TODO(weiweilin): expose BuildStorageDuration from buildbucket and compute BuildSummaryStorageDuration base on that (e.g. add two months). So we can ensure BuildSummaries are kept alive longer than builds.

View Source
const BuildSummarySyncThreshold = time.Hour * 24 * 2 // 2 days

BuildSummarySyncThreshold is the maximum duration before Milo attempts to sync non-terminal builds with buildbucket.

Cron runs periodically to scan and sync all the non-terminal Builds of that was updated more than `BuildSummarySyncThreshold` ago.

Variables

View Source
var (
	ErrNotFound    = errors.Reason("Build not found").Tag(grpcutil.NotFoundTag).Err()
	ErrNotLoggedIn = errors.Reason("not logged in").Tag(grpcutil.UnauthenticatedTag).Err()
)
View Source
var (
	FullBuildMask = &field_mask.FieldMask{
		Paths: []string{
			"id",
			"builder",
			"number",
			"created_by",
			"canceled_by",
			"create_time",
			"start_time",
			"end_time",
			"update_time",
			"status",
			"input",
			"output",
			"steps",
			"infra",
			"tags",
			"summary_markdown",
			"canary",
			"exe",
		},
	}
	TagsAndGitilesMask = &field_mask.FieldMask{
		Paths: []string{
			"id",
			"number",
			"builder",
			"input.gitiles_commit",
			"tags",
		},
	}
)

Functions

func BuildAddress

func BuildAddress(build *buildbucketpb.Build) string

BuildAddress constructs the build address of a buildbucketpb.Build. This is used as the key for the BuildSummary entity.

func CancelBuild

func CancelBuild(c context.Context, id int64, reason string) (*buildbucketpb.Build, error)

CancelBuild cancels the build with the given ID.

func DeleteOldBuilds

func DeleteOldBuilds(c context.Context) error

DeleteOldBuilds is a cron job that deletes BuildSummaries that are older than BuildSummaryStorageDuration.

func FilterVisibleBuilders

func FilterVisibleBuilders(c context.Context, builders []*buildbucketpb.BuilderID, project string) ([]*buildbucketpb.BuilderID, error)

FilterVisibleBuilders returns a list of builders that are visible to the current user. When project is not an empty string, only builders in the specified project will be returned.

func GetBuildSummary

func GetBuildSummary(c context.Context, id int64) (*model.BuildSummary, error)

GetBuildSummary fetches a build summary where the Context URI matches the given address.

func GetBuilderID

func GetBuilderID(c context.Context, id int64) (builder *buildbucketpb.BuilderID, number int32, err error)

GetBuilderID returns the builder, and maybe the build number, for a build id.

func GetHost

func GetHost(c context.Context) (string, error)

func GetRelatedBuildsTable

func GetRelatedBuildsTable(c context.Context, buildbucketID int64) (*ui.RelatedBuildsTable, error)

GetRelatedBuildsTable fetches all the related builds of the given build from Buildbucket.

func ProdBuildsClientFactory

func ProdBuildsClientFactory(c context.Context, host string, as auth.RPCAuthorityKind, opts ...auth.RPCOption) (buildbucketpb.BuildsClient, error)

func PubSubHandler

func PubSubHandler(c context.Context, message pubsub.Message, buildPubSub *buildbucketpb.BuildsV2PubSub) error

func RetryBuild

func RetryBuild(c context.Context, buildbucketID int64, requestID string) (*buildbucketpb.Build, error)

RetryBuild retries the build with the given ID and returns the new build.

func SyncBuilds

func SyncBuilds(c context.Context) error

SyncBuilds is a cron job that sync BuildSummaries that are not in terminal state and haven't been updated recently.

func WithBuildsClientFactory

func WithBuildsClientFactory(c context.Context, factory buildsClientFactory) context.Context

WithBuildsClientFactory installs a buildbucket rpc builds client in the context.

Types

type BlamelistOption

type BlamelistOption int

BlamelistOption specifies whether the blamelist should be fetched as part of the build page request.

var (
	// NoBlamelist means blamelist shouldn't be fetched.
	NoBlamelist BlamelistOption = 0
	// GetBlamelist means blamelist should be fetched with a short timeout.
	GetBlamelist BlamelistOption = 1
	// ForceBlamelist means blamelist should be fetched with a long timeout.
	ForceBlamelist BlamelistOption = 2
)

Jump to

Keyboard shortcuts

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