diff --git a/cli/internal/run/run.go b/cli/internal/run/run.go index 2ac114121187d..a650686e390c4 100644 --- a/cli/internal/run/run.go +++ b/cli/internal/run/run.go @@ -362,6 +362,7 @@ func (r *run) run(ctx gocontext.Context, targets []string) error { // RunSummary contains information that is statically analyzable about // the tasks that we expect to run based on the user command. summary := runsummary.NewRunSummary( + ctx, startAt, r.base.UI, r.base.RepoRoot, diff --git a/cli/internal/runsummary/run_summary.go b/cli/internal/runsummary/run_summary.go index 5fbf4a1f8b9d9..3caffa3f0e166 100644 --- a/cli/internal/runsummary/run_summary.go +++ b/cli/internal/runsummary/run_summary.go @@ -2,6 +2,7 @@ package runsummary import ( + "context" "encoding/json" "fmt" "path/filepath" @@ -11,6 +12,7 @@ import ( "github.com/mitchellh/cli" "github.com/segmentio/ksuid" "github.com/vercel/turbo/cli/internal/client" + "github.com/vercel/turbo/cli/internal/spinner" "github.com/vercel/turbo/cli/internal/turbopath" "github.com/vercel/turbo/cli/internal/util" "github.com/vercel/turbo/cli/internal/workspace" @@ -41,6 +43,7 @@ const ( // about the Run and references to other things that we need. type Meta struct { RunSummary *RunSummary + ctx context.Context ui cli.Ui repoRoot turbopath.AbsoluteSystemPath // used to write run summary repoPath turbopath.RelativeSystemPath @@ -66,6 +69,7 @@ type RunSummary struct { // NewRunSummary returns a RunSummary instance func NewRunSummary( + ctx context.Context, startAt time.Time, ui cli.Ui, repoRoot turbopath.AbsoluteSystemPath, @@ -105,6 +109,7 @@ func NewRunSummary( GlobalHashSummary: globalHashSummary, }, ui: ui, + ctx: ctx, runType: runType, repoRoot: repoRoot, singlePackage: singlePackage, @@ -161,8 +166,19 @@ func (rsm *Meta) Close(exitCode int, workspaceInfos workspace.Catalog) error { return nil } - url, errs := rsm.record() + // Wrap the record function so we can hoist out url/errors but keep + // the function signature/type the spinner.WaitFor expects. + var url string + var errs []error + record := func() { + url, errs = rsm.record() + } + + func() { + _ = spinner.WaitFor(rsm.ctx, record, rsm.ui, "...sending run summary...", 1000*time.Millisecond) + }() + // After the spinner is done if len(errs) > 0 { rsm.ui.Warn("Errors recording run to Spaces") for _, err := range errs {