common

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BenchmarkPhaseBaseline = "baseline"
	BenchmarkPhaseWarmup   = "warmup"

	BuildToolGradle = "gradle"
	BuildToolXcode  = "xcode"
	BuildToolBazel  = "bazel"
)
View Source
const (
	// CIProviderBitrise ...
	CIProviderBitrise = "bitrise"
	// CIProviderCircleCI ...
	CIProviderCircleCI = "circle-ci"
	// CIProviderGitHubActions ...
	CIProviderGitHubActions = "github-actions"
	// CIProviderGitLabCI ...
	CIProviderGitLabCI = "gitlab-ci"

	RedactorSeed = "BitriseBuildCacheRedactor"
)

Variables

View Source
var (
	ErrAuthTokenNotProvided   = errors.New("BITRISE_BUILD_CACHE_AUTH_TOKEN or BITRISEIO_BITRISE_SERVICES_ACCESS_TOKEN environment variable not set")
	ErrWorkspaceIDNotProvided = errors.New("BITRISE_BUILD_CACHE_WORKSPACE_ID environment variable not set")
)

Functions

func BenchmarkPhaseFilePath added in v1.5.0

func BenchmarkPhaseFilePath() (string, error)

BenchmarkPhaseFilePath returns the path to the benchmark phase file.

func GetCLIVersion added in v1.0.15

func GetCLIVersion(logger log.Logger) string

func ReadBenchmarkPhaseFile added in v1.5.0

func ReadBenchmarkPhaseFile(logger log.Logger) string

ReadBenchmarkPhaseFile reads the benchmark phase from the JSON file. Returns empty string if the file doesn't exist or can't be read.

func SelectCacheEndpointURL added in v0.15.12

func SelectCacheEndpointURL(endpointURL string, envs map[string]string) string

SelectCacheEndpointURL - if endpointURL provided use that, otherwise select the best build cache endpoint automatically

func SelectRBEEndpointURL added in v0.15.12

func SelectRBEEndpointURL(endpointURL string, envs map[string]string) string

SelectRBEEndpointURL - if endpointURL provided use that, otherwise select the RBE endpoint from environment

func WriteBenchmarkPhaseFile added in v1.5.0

func WriteBenchmarkPhaseFile(phase string, logger log.Logger)

WriteBenchmarkPhaseFile writes the benchmark phase to a JSON file.

Types

type BenchmarkPhaseClient added in v1.1.0

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

BenchmarkPhaseClient fetches the benchmark phase for a Gradle build from the Bitrise API.

func NewBenchmarkPhaseClient added in v1.1.0

func NewBenchmarkPhaseClient(baseURL string, authConfig CacheAuthConfig, logger log.Logger) *BenchmarkPhaseClient

NewBenchmarkPhaseClient creates a new BenchmarkPhaseClient.

func (*BenchmarkPhaseClient) GetBenchmarkPhase added in v1.1.0

func (c *BenchmarkPhaseClient) GetBenchmarkPhase(buildTool string, metadata CacheConfigMetadata) (string, error)

GetBenchmarkPhase fetches the benchmark phase for the current build. The buildTool parameter specifies the build tool (gradle, xcode, bazel). Returns empty string if no benchmark phase is active or if the build can't be identified.

type BenchmarkPhaseFile added in v1.5.0

type BenchmarkPhaseFile struct {
	Phase string `json:"phase"`
}

BenchmarkPhaseFile is the JSON structure for the benchmark phase file.

type BenchmarkPhaseProvider added in v1.1.0

type BenchmarkPhaseProvider interface {
	GetBenchmarkPhase(buildTool string, metadata CacheConfigMetadata) (string, error)
}

BenchmarkPhaseProvider fetches the benchmark phase for a build.

type CacheAuthConfig

type CacheAuthConfig struct {
	AuthToken   string
	WorkspaceID string
	IsJWT       bool
}

CacheAuthConfig holds the auth config for the cache.

func ReadAuthConfigFromEnvironments

func ReadAuthConfigFromEnvironments(envs map[string]string) (CacheAuthConfig, error)

ReadAuthConfigFromEnvironments reads auth information from the environment variables

func (CacheAuthConfig) TokenInGradleFormat

func (cac CacheAuthConfig) TokenInGradleFormat() string

TokenInGradleFormat returns the auth token in gradle format. For JWT tokens, the token is sent as-is (the workspace ID is embedded in the JWT). For PAT tokens, the format is "workspaceID:token".

type CacheConfigMetadata added in v0.7.0

type CacheConfigMetadata struct {
	CIProvider   string
	CLIVersion   string
	RedactedEnvs map[string]string
	HostMetadata HostMetadata
	GitMetadata  GitMetadata
	// BitriseCI specific
	BitriseAppID           string
	BitriseWorkflowName    string
	BitriseBuildID         string
	BitriseStepExecutionID string
	Datacenter             string
	// External CI identifiers (non-Bitrise CI providers)
	ExternalAppID        string
	ExternalBuildID      string
	ExternalWorkflowName string
	// BenchmarkPhase is the benchmark phase (baseline, warmup, etc.)
	BenchmarkPhase string
}

func NewMetadata added in v0.16.10

func NewMetadata(envs map[string]string, commandFunc CommandFunc, logger log.Logger) CacheConfigMetadata

NewMetadata creates a new CacheConfigMetadata instance based on the environment variables.

type CommandFunc added in v0.15.23

type CommandFunc func(string, ...string) (string, error)

type GitMetadata added in v1.0.1

type GitMetadata struct {
	RepoURL     string
	CommitHash  string
	Branch      string
	CommitEmail string
}

type HostMetadata added in v0.15.23

type HostMetadata struct {
	OS             string
	CPUCores       int
	MemSize        int64
	Locale         string
	DefaultCharset string
	Hostname       string
	Username       string
}

HostMetadata contains metadata about the local environment. Only used for Bazel to generate bazelrc. For Gradle, it's done by the plugin dynamically.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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