cq

package
v0.0.0-...-1483051 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: BSD-3-Clause Imports: 23 Imported by: 2

Documentation

Overview

Package cq provides tools for interacting with the CQ tools.

Index

Constants

View Source
const (
	MAIN_REF = git_common.RefsHeadsPrefix + git.MainBranch

	// Constants for in-flight metrics.
	INFLIGHT_METRIC_NAME     = "in_flight"
	INFLIGHT_TRYBOT_DURATION = "trybot_duration"
	INFLIGHT_TRYBOT_NUM      = "trybot_num"
	INFLIGHT_WAITING_IN_CQ   = "waiting_in_cq"

	// Constants for landed metrics.
	LANDED_METRIC_NAME     = "after_commit"
	LANDED_TRYBOT_DURATION = "trybot_duration"
	LANDED_TOTAL_DURATION  = "total_duration"
)

Variables

View Source
var (
	// Slice of all known presubmit bot names.
	PRESUBMIT_BOTS = []string{"skia_presubmit-Trybot"}
)

Functions

func CloneBranch

func CloneBranch(f *build.File, oldBranch, newBranch string, includeExperimental, includeTreeCheck bool, excludeTrybotRegexp []*regexp.Regexp) error

CloneBranch updates the given CQ config to create a config for a new branch based on a given existing branch. Optionally, include experimental tryjobs, include the tree-is-open check, and exclude trybots matching regular expressions.

func CopyExprSlice

func CopyExprSlice(slice []build.Expr) []build.Expr

CopyExprSlice returns a shallow copy of the []Expr.

func DeleteBranch

func DeleteBranch(f *build.File, branch string) error

DeleteBranch updates the given CQ config to delete the config matching the given branch.

func FindAssignExpr

func FindAssignExpr(callExpr *build.CallExpr, identifier string) (int, *build.AssignExpr, error)

FindAssignExpr finds the AssignExpr with the given identifier.

func FindExprForBranch

func FindExprForBranch(f *build.File, branch string) (int, *build.CallExpr, error)

FindExprForBranch finds the CallExpr for the given branch.

func GetCQJobsToConfig

func GetCQJobsToConfig(repo *gitiles.Repo, ref string) (map[string]*specs.CommitQueueJobConfig, error)

GetCQJobsToConfig returns the Config for the given repo.

func GetCQTryBots

func GetCQTryBots(cqJobsToConfig map[string]*specs.CommitQueueJobConfig) ([]string, error)

GetCQTryBots is a convenience method for retrieving the list of CQ trybots from a Config.

func GetSkiaCQTryBots

func GetSkiaCQTryBots() ([]string, error)

GetSkiaCQTryBots is a Skia implementation of GetCQTryBotsFn.

func GetSkiaInfraCQTryBots

func GetSkiaInfraCQTryBots() ([]string, error)

GetSkiaInfraCQTryBots is a Skia Infra implementation of GetCQTryBotsFn.

func WithUpdateCQConfig

func WithUpdateCQConfig(ctx context.Context, starlarkConfigFile, generatedDir string, fn func(*build.File) error) error

WithUpdateCQConfig reads the given Starlark config file, runs the given function to modify it, then writes it back to disk and runs lucicfg to generate the proto config files in the given directory. Expects lucicfg to be in PATH and "lucicfg auth-login" to have already been run. generatedDir must be a descendant of the directory which contains starlarkConfigFile.

func WithUpdateCQConfigBytes

func WithUpdateCQConfigBytes(filename string, oldCfgBytes []byte, fn func(*build.File) error) ([]byte, error)

WithUpdateCQConfigBytes parses the given bytes as a Config, runs the given function to modify the Config, then returns the updated bytes.

Types

type Client

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

func NewClient

func NewClient(gerritClient *gerrit.Gerrit, cqTryBotsFunc GetCQTryBotsFn, metricName string) (*Client, error)

NewClient creates a new client for interacting with CQ tools.

func (*Client) RefreshCQTryBots

func (c *Client) RefreshCQTryBots() error

RefreshCQTryBots refreshes the slice of CQ trybots on the instance. Access to the trybots is protected by a RWMutex.

func (*Client) ReportCQStats

func (c *Client) ReportCQStats(ctx context.Context, change int64, reportedMetrics map[metrics2.Int64Metric]struct{}) error

ReportCQStats reports all relevant stats for the specified Gerrit change. Note: Different stats are reported depending on whether the change has been merged or not. All created metrics will be registered in reportedMetrics.

func (*Client) ReportCQStatsForInFlightCL

func (c *Client) ReportCQStatsForInFlightCL(cqBuilds []*buildbucketpb.Build, gerritURL string, reportedMetrics map[metrics2.Int64Metric]struct{})

ReportCQStatsForInFlightCL reports the following metrics for the specified change and patchsetID: * How long CQ trybots have been running for. * How many CQ trybots have been triggered. All created metrics will be registered in reportedMetrics.

func (*Client) ReportCQStatsForLandedCL

func (c *Client) ReportCQStatsForLandedCL(cqBuilds []*buildbucketpb.Build, gerritURL string, reportedMetrics map[metrics2.Int64Metric]struct{})

ReportCQStatsForLandedCL reports the following metrics for the specified change and patchsetID: * The total time the change spent waiting for CQ trybots to complete. * The time each CQ trybot took to complete. All created metrics will be registered in reportedMetrics.

type GetCQTryBotsFn

type GetCQTryBotsFn func() ([]string, error)

GetCQTryBotsFn is an interface for returing the CQ trybots of a project.

Jump to

Keyboard shortcuts

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