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

Add top level exitCode to RunSummary #4343

Merged
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
2 changes: 2 additions & 0 deletions cli/integration_tests/basic_monorepo/run_summary.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Setup
$ cat $(/bin/ls .turbo/runs/*.json | head -n1) | jq '.version'
"0"

$ cat $(/bin/ls .turbo/runs/*.json | head -n1) | jq '.executionSummary.exitCode'
0
$ cat $(/bin/ls .turbo/runs/*.json | head -n1) | jq '.executionSummary.attempted'
2
$ cat $(/bin/ls .turbo/runs/*.json | head -n1) | jq '.executionSummary.cached'
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/run/real_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func RealRun(
base.UI.Error(err.Error())
}

runSummary.Close(base.RepoRoot)
runSummary.Close(exitCode, base.RepoRoot)

if exitCode != 0 {
return &process.ChildExit{
Expand Down
3 changes: 3 additions & 0 deletions cli/internal/runsummary/execution_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type executionSummary struct {
attempted int
startedAt time.Time
endedAt time.Time
exitCode int
}

// MarshalJSON munges the executionSummary into a format we want
Expand All @@ -110,13 +111,15 @@ func (es *executionSummary) MarshalJSON() ([]byte, error) {
Attempted int `json:"attempted"`
StartTime int64 `json:"startTime"`
EndTime int64 `json:"endTime"`
ExitCode int `json:"exitCode"`
}{
StartTime: es.startedAt.UnixMilli(),
EndTime: es.endedAt.UnixMilli(),
Success: es.success,
Failure: es.failure,
Cached: es.cached,
Attempted: es.attempted,
ExitCode: es.exitCode,
}

return json.Marshal(&serializable)
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/runsummary/run_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ func NewRunSummary(
}

// Close wraps up the RunSummary at the end of a `turbo run`.
func (rsm *Meta) Close(dir turbopath.AbsoluteSystemPath) {
func (rsm *Meta) Close(exitCode int, dir turbopath.AbsoluteSystemPath) {
rsm.RunSummary.ExecutionSummary.exitCode = exitCode
rsm.RunSummary.ExecutionSummary.endedAt = time.Now()

summary := rsm.RunSummary
Expand Down