From a09f38bc32cc230a04fc2abacfcac19173f1d45d Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Fri, 5 May 2023 10:32:20 -0700 Subject: [PATCH] sort tasks in run summary output by task id --- cli/internal/runsummary/format_json.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cli/internal/runsummary/format_json.go b/cli/internal/runsummary/format_json.go index b4e6da9e2dd55..7b753dd0aed9b 100644 --- a/cli/internal/runsummary/format_json.go +++ b/cli/internal/runsummary/format_json.go @@ -2,6 +2,7 @@ package runsummary import ( "encoding/json" + "sort" "github.com/pkg/errors" "github.com/segmentio/ksuid" @@ -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.