common

package
v0.0.0-...-11046fd Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: BSD-3-Clause Imports: 22 Imported by: 11

Documentation

Index

Constants

View Source
const BazelCleanIfLowDiskSpaceContextKey = bazelCleanIfLowDiskSpaceContextKeyType("overwriteBazelCleanIfLowDiskSpaceDiskFns")

BazelCleanIfLowDiskSpaceContextKey is a context key that can be used from tests to override the functions used by BazelCleanIfLowDiskSpace to compute the free space on the partition where the Bazel cache lives. Values associated to this context key should be of type BazelCleanIfLowDiskSpaceContextValue.

View Source
const PerfGCSBucketName = "skia-perf"

PerfGCSBucketName is the name of the perf.skia.org GCS bucket.

Variables

This section is empty.

Functions

func BazelCleanIfLowDiskSpace

func BazelCleanIfLowDiskSpace(ctx context.Context, bazelCacheDir, bazelWorkspaceDir, pathToBazel string) error

BazelCleanIfLowDiskSpace runs "bazel clean" as a task driver step if disk space is too low. This step should be added at the end of any task driver that shells out to Bazel in order to prevent DiskSpaceLow alerts due to the Bazel cache (usually at /mnt/pd0/bazel_cache) growing too large.

Ideally, we would like to tell Bazel to prevent the cache from growing above a certain size, but there is currently no way to do this. See discussion in the below links:

- https://github.com/bazelbuild/bazel/issues/1035 - https://github.com/bazelbuild/bazel/issues/5139

Testing: Set the BazelCleanIfLowDiskSpaceContextKey context key to override the functions that compute the free space (measured in bytes) on the partition where the Bazel cache lives.

func ComputeBenchmarkTestRunnerCLIFlags

func ComputeBenchmarkTestRunnerCLIFlags(benchmarkInfo BenchmarkInfo) []string

ComputeBenchmarkTestRunnerCLIFlags returns the command-line flags that should be passed to the benchmark test runner.

func ExtractOutputsZip

func ExtractOutputsZip(ctx context.Context, outputsZipPath string) (string, error)

ExtractOutputsZip extracts the undeclared outputs ZIP archive into a temporary directory, and returns the path to said directory.

func UploadToGold

func UploadToGold(ctx context.Context, utgArgs UploadToGoldArgs, outputsZIPOrDir string) error

UploadToGold uploads any GM results to Gold via goldctl.

func UploadToPerf

func UploadToPerf(ctx context.Context, gcsClient gcs.GCSClient, benchmarkInfo BenchmarkInfo, outputsZIPOrDir string) error

func ValidateLabelAndReturnOutputsZipPath

func ValidateLabelAndReturnOutputsZipPath(checkoutDir, label string) (string, error)

ValidateLabelAndReturnOutputsZipPath validates the given Bazel label and returns the path within the checkout directory where the ZIP archive with undeclared test outputs will be found, if applicable.

func WithEnoughSpaceOnBazelCachePartitionTestOnlyContext

func WithEnoughSpaceOnBazelCachePartitionTestOnlyContext(ctx context.Context) (context.Context, string)

WithEnoughSpaceOnBazelCachePartitionTestOnlyContext returns a context that makes common.BazelCleanIfLowDiskSpace() think there is enough space on the partition where the Bazel cache is found. It also returns a path within said partition where the Bazel cache is assumed to live, which should be passed to the code under test that invokes common.BazelCleanIfLowDiskSpace().

This function is placed here rather than in the testutils Go package to avoid an import cycle.

Types

type BazelCleanIfLowDiskSpaceContextValue

type BazelCleanIfLowDiskSpaceContextValue = struct {
	GetPartitionMountpoints func() ([]string, error)
	FreeBytesOnPartition    func(string) (uint64, error)
}

BazelCleanIfLowDiskSpaceContextValue is the type of the value associated with the BazelCleanIfLowDiskSpaceContextKey context key.

type BazelFlags

type BazelFlags struct {
	Label                *string
	Config               *string
	DeviceSpecificConfig *string
	AdditionalArgs       *[]string
	CacheDir             *string
	// contains filtered or unexported fields
}

BazelFlags is a struct that holds common flags for task drivers that shell out to Bazel.

func MakeBazelFlags

func MakeBazelFlags(opts MakeBazelFlagsOpts) *BazelFlags

MakeBazelFlags declares common Bazel flags.

func (*BazelFlags) Validate

func (f *BazelFlags) Validate(ctx context.Context)

Validate performs common flag validation steps.

type BenchmarkInfo

type BenchmarkInfo struct {
	GitCommit     string
	TaskName      string
	TaskID        string
	ChangelistID  string
	PatchsetOrder string
}

BenchmarkInfo contains information about the CI task under which a benchmark is executed.

type MakeBazelFlagsOpts

type MakeBazelFlagsOpts struct {
	Label                bool
	Config               bool
	DeviceSpecificConfig bool
	AdditionalArgs       bool
}

MakeBazelFlagsOpts controls which flags are defiend by MakeBazelFlags.

type UploadToGoldArgs

type UploadToGoldArgs struct {
	BazelLabel                string
	DeviceSpecificBazelConfig string
	GoldctlPath               string
	GitCommit                 string
	ChangelistID              string
	PatchsetOrder             string // 1, 2, 3, etc.
	TryjobID                  string

	// TestOnlyAllowAnyBazelLabel should only be used from tests. If true, the
	// goldctlBazelLabelAllowList will be ignored.
	//
	// TODO(lovisolo): Delete once migration is complete.
	TestOnlyAllowAnyBazelLabel bool
}

UploadToGoldArgs gathers the inputs to the UploadToGold function.

Jump to

Keyboard shortcuts

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