diff --git a/cli/internal/run/real_run.go b/cli/internal/run/real_run.go index dd4542c443a07..50725e539cc5e 100644 --- a/cli/internal/run/real_run.go +++ b/cli/internal/run/real_run.go @@ -224,6 +224,9 @@ func (ec *execContext) exec(ctx gocontext.Context, packageTask *nodes.PackageTas return nil, nil } + // Set building status now that we know it's going to run. + tracer(runsummary.TargetBuilding, nil, &successCode) + var prefix string var prettyPrefix string if ec.rs.Opts.runOpts.logPrefix == "none" { diff --git a/cli/internal/runsummary/execution_summary.go b/cli/internal/runsummary/execution_summary.go index 4244ad4f712cd..278758b55dfbc 100644 --- a/cli/internal/runsummary/execution_summary.go +++ b/cli/internal/runsummary/execution_summary.go @@ -35,7 +35,8 @@ type executionEventName int // The collection of expected build result statuses. const ( - targetBuilding executionEventName = iota + targetInitialized executionEventName = iota + TargetBuilding TargetBuildStopped TargetBuilt TargetCached @@ -44,7 +45,9 @@ const ( func (en executionEventName) toString() string { switch en { - case targetBuilding: + case targetInitialized: + return "initialized" + case TargetBuilding: return "building" case TargetBuildStopped: return "buildStopped" @@ -107,10 +110,10 @@ type executionSummary struct { profileFilename string // These get serialized to JSON - success int - failure int - cached int - attempted int + success int // number of tasks that exited successfully (does not include cache hits) + failure int // number of tasks that exited with failure + cached int // number of tasks that had a cache hit + attempted int // number of tasks that started startedAt time.Time endedAt time.Time exitCode int @@ -164,7 +167,7 @@ func (es *executionSummary) run(taskID string) (func(outcome executionEventName, taskExecutionSummary := es.add(&executionEvent{ Time: start, Label: taskID, - Status: targetBuilding, + Status: targetInitialized, }) tracer := chrometracing.Event(taskID) @@ -219,15 +222,14 @@ func (es *executionSummary) add(event *executionEvent) *TaskExecutionSummary { } switch { + case event.Status == TargetBuilding: + es.attempted++ case event.Status == TargetBuildFailed: es.failure++ - es.attempted++ case event.Status == TargetCached: es.cached++ - es.attempted++ case event.Status == TargetBuilt: es.success++ - es.attempted++ } return es.tasks[event.Label] diff --git a/cli/internal/runsummary/format_execution_summary.go b/cli/internal/runsummary/format_execution_summary.go index 22d6ef6e252b1..647bddb3fd032 100644 --- a/cli/internal/runsummary/format_execution_summary.go +++ b/cli/internal/runsummary/format_execution_summary.go @@ -14,7 +14,13 @@ func (rsm *Meta) printExecutionSummary() { summary := rsm.RunSummary ui := rsm.ui - if summary.ExecutionSummary.cached == summary.ExecutionSummary.attempted && summary.ExecutionSummary.attempted > 0 { + attempted := summary.ExecutionSummary.attempted + successful := summary.ExecutionSummary.cached + summary.ExecutionSummary.success + cached := summary.ExecutionSummary.cached + // TODO: can we use a method on ExecutionSummary here? + duration := time.Since(summary.ExecutionSummary.startedAt).Truncate(time.Millisecond) + + if cached == attempted && attempted > 0 { terminalProgram := os.Getenv("TERM_PROGRAM") // On the macOS Terminal, the rainbow colors show up as a magenta background // with a gray background on a single letter. Instead, we print in bold magenta @@ -26,14 +32,16 @@ func (rsm *Meta) printExecutionSummary() { } } - if summary.ExecutionSummary.attempted == 0 { + if attempted == 0 { ui.Output("") // Clear the line ui.Warn("No tasks were executed as part of this run.") } ui.Output("") // Clear the line - ui.Output(util.Sprintf("${BOLD} Tasks:${BOLD_GREEN} %v successful${RESET}${GRAY}, %v total${RESET}", summary.ExecutionSummary.cached+summary.ExecutionSummary.success, summary.ExecutionSummary.attempted)) - ui.Output(util.Sprintf("${BOLD}Cached: %v cached${RESET}${GRAY}, %v total${RESET}", summary.ExecutionSummary.cached, summary.ExecutionSummary.attempted)) - ui.Output(util.Sprintf("${BOLD} Time: %v${RESET} %v${RESET}", time.Since(summary.ExecutionSummary.startedAt).Truncate(time.Millisecond), maybeFullTurbo)) + + // The whitespaces in the string are to align the UI in a nice way. + ui.Output(util.Sprintf("${BOLD} Tasks:${BOLD_GREEN} %v successful${RESET}${GRAY}, %v total${RESET}", successful, attempted)) + ui.Output(util.Sprintf("${BOLD}Cached: %v cached${RESET}${GRAY}, %v total${RESET}", cached, attempted)) + ui.Output(util.Sprintf("${BOLD} Time: %v${RESET} %v${RESET}", duration, maybeFullTurbo)) ui.Output("") }