runsummary

package
v0.0.0-...-0a43815 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MPL-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package runsummary implements structs that report on a `turbo run` and `turbo run --dry`

Index

Constants

View Source
const (
	TargetBuilding executionEventName
	TargetBuildStopped
	TargetExecuted
	TargetBuilt
	TargetCached
	TargetBuildFailed
)

The collection of expected build result statuses.

View Source
const MissingTaskLabel = "<NONEXISTENT>"

MissingTaskLabel is printed when a package is missing a definition for a task that is supposed to run E.g. if `turbo run build --dry` is run, and package-a doesn't define a `build` script in package.json, the RunSummary will print this, instead of the script (e.g. `next build`).

Variables

This section is empty.

Functions

This section is empty.

Types

type GlobalEnvConfiguration

type GlobalEnvConfiguration struct {
	Env            []string `json:"env"`
	PassThroughEnv []string `json:"passThroughEnv"`
}

GlobalEnvConfiguration contains the environment variable inputs for the global hash

type GlobalEnvVarSummary

type GlobalEnvVarSummary struct {
	Specified GlobalEnvConfiguration `json:"specified"`

	Configured  env.EnvironmentVariablePairs `json:"configured"`
	Inferred    env.EnvironmentVariablePairs `json:"inferred"`
	PassThrough env.EnvironmentVariablePairs `json:"passthrough"`
}

GlobalEnvVarSummary contains the environment variables that impacted the global hash

type GlobalHashSummary

type GlobalHashSummary struct {
	GlobalCacheKey       string                                `json:"rootKey"`
	GlobalFileHashMap    map[turbopath.AnchoredUnixPath]string `json:"files"`
	RootExternalDepsHash string                                `json:"hashOfExternalDependencies"`
	DotEnv               turbopath.AnchoredUnixPathArray       `json:"globalDotEnv"`
	EnvVars              GlobalEnvVarSummary                   `json:"environmentVariables"`
}

GlobalHashSummary contains the pieces of data that impacted the global hash (then then impacted the task hash)

func NewGlobalHashSummary

func NewGlobalHashSummary(
	globalCacheKey string,
	fileHashMap map[turbopath.AnchoredUnixPath]string,
	rootExternalDepsHash string,
	globalEnv []string,
	globalPassThroughEnv []string,
	globalDotEnv turbopath.AnchoredUnixPathArray,
	resolvedEnvVars env.DetailedMap,
	resolvedPassThroughEnvVars env.EnvironmentVariableMap,
) *GlobalHashSummary

NewGlobalHashSummary creates a GlobalHashSummary struct from a set of fields.

type Meta

type Meta struct {
	RunSummary *RunSummary
	// contains filtered or unexported fields
}

Meta is a wrapper around the serializable RunSummary, with some extra information about the Run and references to other things that we need.

func NewRunSummary

func NewRunSummary(
	startAt time.Time,
	repoRoot turbopath.AbsoluteSystemPath,
	repoPath turbopath.RelativeSystemPath,
	turboVersion string,
	apiClient *client.APIClient,
	spacesClient *client.APIClient,
	runOpts util.RunOpts,
	packages []string,
	globalEnvMode util.EnvMode,
	envAtExecutionStart env.EnvironmentVariableMap,
	globalHashSummary *GlobalHashSummary,
	synthesizedCommand string,
) Meta

NewRunSummary returns a RunSummary instance

func (*Meta) Close

func (rsm *Meta) Close(ctx context.Context, exitCode int, workspaceInfos workspace.Catalog, ui cli.Ui) error

Close wraps up the RunSummary at the end of a `turbo run`.

func (*Meta) CloseTask

func (rsm *Meta) CloseTask(task *TaskSummary, logs []byte)

CloseTask posts the result of the Task to Spaces

func (Meta) FormatAndPrintText

func (rsm Meta) FormatAndPrintText(workspaceInfos workspace.Catalog, ui cli.Ui) error

FormatAndPrintText prints a Run Summary to the Terminal UI

func (*Meta) FormatJSON

func (rsm *Meta) FormatJSON() ([]byte, error)

FormatJSON returns a json string representing a RunSummary

func (*Meta) SpacesIsEnabled

func (rsm *Meta) SpacesIsEnabled() bool

SpacesIsEnabled returns true if this run summary is going to send to a spaces backend

type RunSummary

type RunSummary struct {
	ID                 ksuid.KSUID        `json:"id"`
	Version            string             `json:"version"`
	TurboVersion       string             `json:"turboVersion"`
	Monorepo           bool               `json:"monorepo"`
	GlobalHashSummary  *GlobalHashSummary `json:"globalCacheInputs"`
	Packages           []string           `json:"packages"`
	EnvMode            util.EnvMode       `json:"envMode"`
	FrameworkInference bool               `json:"frameworkInference"`
	ExecutionSummary   *executionSummary  `json:"execution,omitempty"`
	Tasks              []*TaskSummary     `json:"tasks"`
	User               string             `json:"user"`
	SCM                *scmState          `json:"scm"`
}

RunSummary contains a summary of what happens in the `turbo run` command and why.

func (*RunSummary) TrackTask

func (summary *RunSummary) TrackTask(taskID string) (func(outcome executionEventName, err error, exitCode *int), *TaskExecutionSummary)

TrackTask makes it possible for the consumer to send information about the execution of a task.

type TaskCacheSummary

type TaskCacheSummary struct {
	Local     bool   `json:"local"`            // Deprecated, but keeping around for --dry=json
	Remote    bool   `json:"remote"`           // Deprecated, but keeping around for --dry=json
	Status    string `json:"status"`           // should always be there
	Source    string `json:"source,omitempty"` // can be empty on status:miss
	TimeSaved int    `json:"timeSaved"`        // always include, but can be 0
}

TaskCacheSummary is an extended version of cache.ItemStatus that includes TimeSaved and some better data.

func NewTaskCacheSummary

func NewTaskCacheSummary(itemStatus cache.ItemStatus) TaskCacheSummary

NewTaskCacheSummary decorates a cache.ItemStatus into a TaskCacheSummary Importantly, it adds the derived keys of `source` and `status` based on the local/remote booleans. It would be nice if these were just included from upstream, but that is a more invasive change.

type TaskEnvConfiguration

type TaskEnvConfiguration struct {
	Env            []string `json:"env"`
	PassThroughEnv []string `json:"passThroughEnv"`
}

TaskEnvConfiguration contains the environment variable inputs for a task

type TaskEnvVarSummary

type TaskEnvVarSummary struct {
	Specified TaskEnvConfiguration `json:"specified"`

	Configured  []string `json:"configured"`
	Inferred    []string `json:"inferred"`
	PassThrough []string `json:"passthrough"`
}

TaskEnvVarSummary contains the environment variables that impacted a task's hash

type TaskExecutionSummary

type TaskExecutionSummary struct {
	Duration time.Duration // updated during the task execution
	// contains filtered or unexported fields
}

TaskExecutionSummary contains data about the state of a single task in a turbo run. Some fields are updated over time as the task prepares to execute and finishes execution.

func (*TaskExecutionSummary) ExitCode

func (ts *TaskExecutionSummary) ExitCode() *int

ExitCode access exit code nil means no exit code was received

func (*TaskExecutionSummary) MarshalJSON

func (ts *TaskExecutionSummary) MarshalJSON() ([]byte, error)

MarshalJSON munges the TaskExecutionSummary into a format we want We'll use an anonmyous, private struct for this, so it's not confusingly duplicated

type TaskSummary

type TaskSummary struct {
	TaskID           string                                `json:"taskId,omitempty"`
	Task             string                                `json:"task"`
	Package          string                                `json:"package,omitempty"`
	Hash             string                                `json:"hash"`
	ExpandedInputs   map[turbopath.AnchoredUnixPath]string `json:"inputs"`
	ExternalDepsHash string                                `json:"hashOfExternalDependencies"`
	CacheSummary     TaskCacheSummary                      `json:"cache"`
	Command          string                                `json:"command"`
	CommandArguments []string                              `json:"cliArguments"`
	Outputs          []string                              `json:"outputs"`
	ExcludedOutputs  []string                              `json:"excludedOutputs"`
	// Repo-relative, relative system path
	LogFileRelativePath string `json:"logFile"`
	// Repo-relative, relative system path
	Dir                    string                          `json:"directory,omitempty"`
	Dependencies           []string                        `json:"dependencies"`
	Dependents             []string                        `json:"dependents"`
	ResolvedTaskDefinition *fs.TaskDefinition              `json:"resolvedTaskDefinition"`
	ExpandedOutputs        []turbopath.AnchoredSystemPath  `json:"expandedOutputs"`
	Framework              string                          `json:"framework"`
	EnvMode                util.EnvMode                    `json:"envMode"`
	EnvVars                TaskEnvVarSummary               `json:"environmentVariables"`
	DotEnv                 turbopath.AnchoredUnixPathArray `json:"dotEnv"`
	Execution              *TaskExecutionSummary           `json:"execution,omitempty"` // omit when it's not set
}

TaskSummary contains information about the task that was about to run TODO(mehulkar): `Outputs` and `ExcludedOutputs` are slightly redundant as the information is also available in ResolvedTaskDefinition. We could remove them and favor a version of Outputs that is the fully expanded list of files.

Jump to

Keyboard shortcuts

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