Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make attempted include tasks that started but didn't finish #4378

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli/internal/run/real_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
22 changes: 12 additions & 10 deletions cli/internal/runsummary/execution_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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
Comment on lines +113 to +116
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still a little confusing. I would expect:

success + failure = attempted. And cached is <= success

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah agreed, but I don't want to break how success is used right now

startedAt time.Time
endedAt time.Time
exitCode int
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down
18 changes: 13 additions & 5 deletions cli/internal/runsummary/format_execution_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice


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
Expand All @@ -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("")
}