Documentation ¶
Overview ¶
Copyright Thought Machine, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func CloseAndIgnoreError(closer interface{ ... })
- func Fprintf(writer io.Writer, format string, args ...interface{})
- func GetPackageTaskFromId(taskId string) (packageName string, task string)
- func GetTaskId(pkgName interface{}, target string) string
- func HelpForCobraCmd(cmd *cobra.Command) string
- func InitPrintf()
- func IsPackageTask(task string) bool
- func IsTaskInPackage(task string, packageName string) bool
- func ParseConcurrency(concurrencyRaw string) (int, error)
- func PositiveMod(x, d int) int
- func Printf(format string, args ...interface{})
- func RootTaskID(target string) string
- func RootTaskTaskName(taskID string) string
- func Sprintf(format string, args ...interface{}) string
- func StripPackageName(taskID string) string
- func ToTaskOutputModeString(value TaskOutputMode) (string, error)
- func ValidateGraph(graph *dag.AcyclicGraph) error
- type CacheDisabledError
- type CachingStatus
- type EnvMode
- type ExitCodeError
- type Hashable
- type RunOpts
- type Semaphore
- type Set
- func (s Set) Add(v interface{})
- func (s Set) Copy() Set
- func (s Set) Delete(v interface{})
- func (s Set) Difference(other Set) Set
- func (s Set) Filter(cb func(interface{}) bool) Set
- func (s Set) Includes(v interface{}) bool
- func (s Set) Intersection(other Set) Set
- func (s Set) Len() int
- func (s Set) List() []interface{}
- func (s Set) Some(cb func(interface{}) bool) bool
- func (s Set) UnsafeListOfStrings() []string
- type TaskOutputMode
Constants ¶
const ( // TaskDelimiter separates a package name from a task name in a task id TaskDelimiter = "#" // RootPkgName is the reserved name that specifies the root package RootPkgName = "//" )
Variables ¶
var TaskOutputModeStrings = []string{
fullTaskOutputString,
noTaskOutputString,
hashTaskOutputString,
newTaskOutputString,
errorTaskOutputString,
}
TaskOutputModeStrings is an array containing the string representations for task output modes
Functions ¶
func CloseAndIgnoreError ¶
func CloseAndIgnoreError(closer interface{ Close() error })
CloseAndIgnoreError is a utility to tell our linter that we explicitly deem it okay to not check a particular error on closing of a resource.
We use `errcheck` as a linter, which is super-opinionated about checking errors, even in places where we don't necessarily care to check the error.
`golangci-lint` has a default ignore list for this lint problem (EXC0001) which can be used to sidestep this problem but it's possibly a little too-heavy-handed in exclusion. At the expense of discoverability, this utility function forces opt-in to ignoring errors on closing of things that can be `Close`d.
func GetPackageTaskFromId ¶
GetPackageTaskFromId returns a tuple of the package name and target task
func HelpForCobraCmd ¶
HelpForCobraCmd returns the help string for a given command Note that this overwrites the output for the command
func IsPackageTask ¶
IsPackageTask returns true if input is a package-specific task whose name has a length greater than 0.
Accepted: myapp#build Rejected: #build, build
func IsTaskInPackage ¶
IsTaskInPackage returns true if the task does not belong to a different package note that this means unscoped tasks will always return true
func ParseConcurrency ¶
ParseConcurrency parses a concurrency value, which can be a number (e.g. 2) or a percentage (e.g. 50%).
func PositiveMod ¶
PostitiveMod returns a modulo operator like JavaScripts
func RootTaskID ¶
RootTaskID returns the task id for running the given task in the root package
func RootTaskTaskName ¶
RootTaskTaskName returns the task portion of a root task taskID
func Sprintf ¶
printf is used throughout this package to print something to stderr with some replacements for pseudo-shell variables for ANSI formatting codes.
func StripPackageName ¶
StripPackageName removes the package portion of a taskID if it is a package task. Non-package tasks are returned unmodified
func ToTaskOutputModeString ¶
func ToTaskOutputModeString(value TaskOutputMode) (string, error)
ToTaskOutputModeString converts a task output mode enum value into the string representation
func ValidateGraph ¶
func ValidateGraph(graph *dag.AcyclicGraph) error
ValidateGraph checks that a given DAG has no cycles and no self-referential edges. We differ from the underlying DAG Validate method in that we allow multiple roots.
Types ¶
type CacheDisabledError ¶
type CacheDisabledError struct { Status CachingStatus Message string }
CacheDisabledError is an error used to indicate that remote caching is not available.
func (*CacheDisabledError) Error ¶
func (cd *CacheDisabledError) Error() string
type CachingStatus ¶
type CachingStatus int
CachingStatus represents the api server's perspective on whether remote caching should be allowed
const ( // CachingStatusDisabled indicates that the server will not accept or serve artifacts CachingStatusDisabled CachingStatus = iota // CachingStatusEnabled indicates that the server will accept and serve artifacts CachingStatusEnabled // CachingStatusOverLimit indicates that a usage limit has been hit and the // server will temporarily not accept or serve artifacts CachingStatusOverLimit // CachingStatusPaused indicates that a customer's spending has been paused and the // server will temporarily not accept or serve artifacts CachingStatusPaused )
func CachingStatusFromString ¶
func CachingStatusFromString(raw string) (CachingStatus, error)
CachingStatusFromString parses a raw string to a caching status enum value
type EnvMode ¶
type EnvMode string
EnvMode specifies if we will be using strict env vars
func (EnvMode) MarshalText ¶
MarshalText implements TextMarshaler for the struct.
type ExitCodeError ¶
type ExitCodeError struct {
ExitCode int
}
ExitCodeError is a specific error that is returned by the command to specify the exit code
func (*ExitCodeError) Error ¶
func (e *ExitCodeError) Error() string
type Hashable ¶
type Hashable interface {
Hashcode() interface{}
}
Hashable is the interface used by set to get the hash code of a value. If this isn't given, then the value of the item being added to the set itself is used as the comparison value.
type RunOpts ¶
type RunOpts struct { // Force execution to be serially one-at-a-time Concurrency int // Whether to execute in parallel (defaults to false) Parallel bool EnvMode EnvMode // Whether or not to infer the framework for each workspace. FrameworkInference bool // The filename to write a perf profile. Profile string // If true, continue task executions even if a task fails. ContinueOnError bool PassThroughArgs []string // Restrict execution to only the listed task names. Default false Only bool // Dry run flags DryRun bool DryRunJSON bool // Graph flags GraphDot bool GraphFile string Daemon bool NoDaemon bool SinglePackage bool // logPrefix controls whether we should print a prefix in task logs LogPrefix string // The order of the logs, either 'grouped' or 'stream' LogOrder string // Whether turbo should create a run summary Summarize bool ExperimentalSpaceID string // Whether this run is in Github Actions IsGithubActions bool }
RunOpts holds the options that control the execution of a turbo run
type Semaphore ¶
type Semaphore chan struct{}
Semaphore is a wrapper around a channel to provide utility methods to clarify that we are treating the channel as a semaphore
func NewSemaphore ¶
NewSemaphore creates a semaphore that allows up to a given limit of simultaneous acquisitions
func (Semaphore) Acquire ¶
func (s Semaphore) Acquire()
Acquire is used to acquire an available slot. Blocks until available.
func (Semaphore) Release ¶
func (s Semaphore) Release()
Release is used to return a slot. Acquire must be called as a pre-condition.
func (Semaphore) TryAcquire ¶
TryAcquire is used to do a non-blocking acquire. Returns a bool indicating success
type Set ¶
type Set map[interface{}]interface{}
Set is a set data structure.
func SetFromStrings ¶
SetFromStrings creates a Set containing the strings from the given slice
func (Set) Difference ¶
Difference returns a set with the elements that s has but other doesn't.
func (Set) Filter ¶
Filter returns a set that contains the elements from the receiver where the given callback returns true.
func (Set) Intersection ¶
Intersection computes the set intersection with other.
func (Set) Some ¶
Some tests whether at least one element in the array passes the test implemented by the provided function. It returns a Boolean value.
func (Set) UnsafeListOfStrings ¶
UnsafeListOfStrings dangerously casts list to a string
type TaskOutputMode ¶
type TaskOutputMode int
TaskOutputMode defines the ways turbo can display task output during a run
const ( // FullTaskOutput will show all task output FullTaskOutput TaskOutputMode = iota // NoTaskOutput will hide all task output NoTaskOutput // HashTaskOutput will display turbo-computed task hashes HashTaskOutput // NewTaskOutput will show all new task output and turbo-computed task hashes for cached output NewTaskOutput // ErrorTaskOutput will show task output for failures only; no cache miss/hit messages are emitted ErrorTaskOutput )
func FromTaskOutputModeString ¶
func FromTaskOutputModeString(value string) (TaskOutputMode, error)
FromTaskOutputModeString converts a task output mode's string representation into the enum value
func (TaskOutputMode) MarshalJSON ¶
func (c TaskOutputMode) MarshalJSON() ([]byte, error)
MarshalJSON converts a task output mode to its string representation
func (*TaskOutputMode) UnmarshalJSON ¶
func (c *TaskOutputMode) UnmarshalJSON(data []byte) error
UnmarshalJSON converts a task output mode string representation into an enum