Documentation ¶
Overview ¶
Package cq provides tools for interacting with the CQ tools.
Index ¶
- Constants
- Variables
- func CloneBranch(f *build.File, oldBranch, newBranch string, ...) error
- func CopyExprSlice(slice []build.Expr) []build.Expr
- func DeleteBranch(f *build.File, branch string) error
- func FindAssignExpr(callExpr *build.CallExpr, identifier string) (int, *build.AssignExpr, error)
- func FindExprForBranch(f *build.File, branch string) (int, *build.CallExpr, error)
- func GetCQJobsToConfig(repo *gitiles.Repo, ref string) (map[string]*specs.CommitQueueJobConfig, error)
- func GetCQTryBots(cqJobsToConfig map[string]*specs.CommitQueueJobConfig) ([]string, error)
- func GetSkiaCQTryBots() ([]string, error)
- func GetSkiaInfraCQTryBots() ([]string, error)
- func WithUpdateCQConfig(ctx context.Context, starlarkConfigFile, generatedDir string, ...) error
- func WithUpdateCQConfigBytes(filename string, oldCfgBytes []byte, fn func(*build.File) error) ([]byte, error)
- type Client
- func (c *Client) RefreshCQTryBots() error
- func (c *Client) ReportCQStats(ctx context.Context, change int64, ...) error
- func (c *Client) ReportCQStatsForInFlightCL(cqBuilds []*buildbucketpb.Build, gerritURL string, ...)
- func (c *Client) ReportCQStatsForLandedCL(cqBuilds []*buildbucketpb.Build, gerritURL string, ...)
- type GetCQTryBotsFn
Constants ¶
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 ¶
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 ¶
CopyExprSlice returns a shallow copy of the []Expr.
func DeleteBranch ¶
DeleteBranch updates the given CQ config to delete the config matching the given branch.
func FindAssignExpr ¶
FindAssignExpr finds the AssignExpr with the given identifier.
func FindExprForBranch ¶
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 ¶
GetSkiaCQTryBots is a Skia implementation of GetCQTryBotsFn.
func GetSkiaInfraCQTryBots ¶
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.
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 ¶
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 ¶
GetCQTryBotsFn is an interface for returing the CQ trybots of a project.