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

fix: sort tasks in run summary output by task id #4837

Merged
merged 3 commits into from May 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions cli/internal/runsummary/format_json.go
Expand Up @@ -2,6 +2,7 @@ package runsummary

import (
"encoding/json"
"sort"

"github.com/pkg/errors"
"github.com/segmentio/ksuid"
Expand Down Expand Up @@ -47,8 +48,16 @@ func (rsm *Meta) normalize() {
task.cleanForSinglePackage()
}
}

sort.Sort(byTaskID(rsm.RunSummary.Tasks))
}

type byTaskID []*TaskSummary

func (a byTaskID) Len() int { return len(a) }
func (a byTaskID) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a byTaskID) Less(i, j int) bool { return a[i].TaskID < a[j].TaskID }

// nonMonorepoRunSummary is an exact copy of RunSummary, but the JSON tags are structured
// for rendering a single-package run of turbo. Notably, we want to always omit packages
// since there is no concept of packages in a single-workspace repo.
Expand Down