Skip to content

Commit

Permalink
fix: sort tasks in run summary output by task id (#4837)
Browse files Browse the repository at this point in the history
### Description

Was using `--summarize` to debug a run and got annoyed that tasks were
getting reordered.

### Testing Instructions

Inspect output of a summary json and verify that tasks no longer have a
random order.
  • Loading branch information
chris-olszewski committed May 10, 2023
1 parent 345cc7c commit 705b385
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit 705b385

Please sign in to comment.