Skip to content

Commit

Permalink
Add a spinner after 1s while uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulkar committed Apr 19, 2023
1 parent 893a92e commit c6f1522
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions cli/internal/run/run.go
Expand Up @@ -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,
Expand Down
18 changes: 17 additions & 1 deletion cli/internal/runsummary/run_summary.go
Expand Up @@ -2,6 +2,7 @@
package runsummary

import (
"context"
"encoding/json"
"fmt"
"path/filepath"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -105,6 +109,7 @@ func NewRunSummary(
GlobalHashSummary: globalHashSummary,
},
ui: ui,
ctx: ctx,
runType: runType,
repoRoot: repoRoot,
singlePackage: singlePackage,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c6f1522

Please sign in to comment.