Skip to content

Commit

Permalink
Update log message when cache restoration is skipped (#5127)
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulkar committed Jun 3, 2023
1 parent ec4d69e commit eaf20a2
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 43 deletions.
12 changes: 9 additions & 3 deletions cli/internal/runcache/runcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,24 @@ func (tc *TaskCache) RestoreOutputs(ctx context.Context, prefixedUI *cli.Prefixe
Source: cache.CacheSourceFS,
TimeSaved: timeSavedFromDaemon,
}
prefixedUI.Warn(fmt.Sprintf("Skipping cache check for %v, outputs have not changed since previous run.", tc.pt.TaskID))
}

// Some more context to add into the cache hit messages.
// This isn't the cleanest way to update the log message, so we should revisit during Rust port.
moreContext := ""
if !hasChangedOutputs {
moreContext = " (outputs already on disk)"
}

switch tc.taskOutputMode {
// When only showing new task output, cached output should only show the computed hash
case util.NewTaskOutput:
fallthrough
case util.HashTaskOutput:
prefixedUI.Info(fmt.Sprintf("cache hit, suppressing output %s", ui.Dim(tc.hash)))
prefixedUI.Info(fmt.Sprintf("cache hit%s, suppressing logs %s", moreContext, ui.Dim(tc.hash)))
case util.FullTaskOutput:
progressLogger.Debug("log file", "path", tc.LogFileName)
prefixedUI.Info(fmt.Sprintf("cache hit, replaying output %s", ui.Dim(tc.hash)))
prefixedUI.Info(fmt.Sprintf("cache hit%s, replaying logs %s", moreContext, ui.Dim(tc.hash)))
tc.ReplayLogFile(prefixedUI, progressLogger)
case util.ErrorTaskOutput:
// The task succeeded, so we don't output anything in this case
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/repo/docs/getting-started/create-new.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ When we run `turbo lint`, Turborepo looks at each `lint` script in each workspac

Let's run our `lint` script one more time. You'll notice a few new things appear in the terminal:

1. `cache hit, replaying output` appears for `docs:lint`, `web:lint` and `ui:lint`.
1. `cache hit, replaying logs` appears for `docs:lint`, `web:lint` and `ui:lint`.
2. You'll see `3 cached, 3 total`.
3. The total runtime should be under `100ms`, and `>>> FULL TURBO` appears.

Expand Down
14 changes: 7 additions & 7 deletions turborepo-tests/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function runSmokeTests<T>(

assert.ok(
sinceCommandSecondRunOutput.includes(
`b:build: cache hit, suppressing output ${getHashFromOutput(
`b:build: cache hit, suppressing logs ${getHashFromOutput(
sinceCommandSecondRunOutput,
"b#build"
)}`
Expand All @@ -390,7 +390,7 @@ function runSmokeTests<T>(

assert.ok(
sinceCommandSecondRunOutput.includes(
`a:test: cache hit, suppressing output ${getHashFromOutput(
`a:test: cache hit, suppressing logs ${getHashFromOutput(
sinceCommandSecondRunOutput,
"a#test"
)}`
Expand Down Expand Up @@ -418,7 +418,7 @@ function runSmokeTests<T>(
);
assert.ok(
lintOutput.includes(
`a:lint: cache hit, suppressing output ${getHashFromOutput(
`a:lint: cache hit, suppressing logs ${getHashFromOutput(
lintOutput,
"a#lint"
)}`
Expand Down Expand Up @@ -446,7 +446,7 @@ function runSmokeTests<T>(
);
assert.ok(
secondLintRun.includes(
`a:lint: cache hit, suppressing output ${getHashFromOutput(
`a:lint: cache hit, suppressing logs ${getHashFromOutput(
secondLintRun,
"a#lint"
)}`
Expand Down Expand Up @@ -509,9 +509,9 @@ function runSmokeTests<T>(
);
assert.ok(
commandOnceBHasChangedOutput.findIndex((l) =>
l.startsWith("c:test: cache hit, replaying output")
l.startsWith("c:test: cache hit, replaying logs")
) >= 0,
"After running, changing source of b, and running `turbo run test` again, should print `c:test: cache hit, replaying output` since c should not be impacted by changes to b"
"After running, changing source of b, and running `turbo run test` again, should print `c:test: cache hit, replaying logs` since c should not be impacted by changes to b"
);

const scopeCommandOutput = getCommandOutputAsArray(
Expand Down Expand Up @@ -547,7 +547,7 @@ function runSmokeTests<T>(
);
assert.ok(
secondPass.includes(
`//:special: cache hit, suppressing output ${getHashFromOutput(
`//:special: cache hit, suppressing logs ${getHashFromOutput(
secondPass,
"//#special"
)}`
Expand Down
4 changes: 2 additions & 2 deletions turborepo-tests/integration/tests/global_env.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Setup
\xe2\x80\xa2 Packages in scope: util (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
util:build: cache hit, suppressing output 76ab904c7ecb2d51
util:build: cache hit, suppressing logs 76ab904c7ecb2d51

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand All @@ -42,7 +42,7 @@ Setup
\xe2\x80\xa2 Packages in scope: util (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
util:build: cache hit, suppressing output 76ab904c7ecb2d51
util:build: cache hit, suppressing logs 76ab904c7ecb2d51

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Only b should have a cache miss
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
a:build: cache hit, replaying output [0-9a-f]+ (re)
a:build: cache hit, replaying logs [0-9a-f]+ (re)
a:build: building

Tasks: 1 successful, 1 total
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Only b should have a cache miss
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
a:build: cache hit, replaying output [0-9a-f]+ (re)
a:build: cache hit, replaying logs [0-9a-f]+ (re)
a:build:
a:build: > build
a:build: > echo 'building'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Only b should have a cache miss
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
a:build: cache hit, replaying output [0-9a-f]+ (re)
a:build: cache hit, replaying logs [0-9a-f]+ (re)
a:build:
a:build: > a@ build .*/apps/a (re)
a:build: > echo 'building'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Only b should have a cache miss
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
a:build: cache hit, replaying output [0-9a-f]+ (re)
a:build: cache hit, replaying logs [0-9a-f]+ (re)
a:build: yarn run v1.22.19
a:build: warning package.json: No license field
a:build: $ echo 'building'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Update exluded file and try again
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, replaying output ba39dbae281ef72a
my-app:build: cache hit, replaying logs ba39dbae281ef72a
my-app:build:
my-app:build: > build
my-app:build: > echo 'building'
Expand Down
4 changes: 2 additions & 2 deletions turborepo-tests/integration/tests/run-logging/log_prefix.t
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Setup
\xe2\x80\xa2 Packages in scope: app-a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
cache hit, replaying output 906851cd5c1e12d4
cache hit, replaying logs 906851cd5c1e12d4

\> build (re)
\> echo 'build app-a' (re)
Expand All @@ -47,7 +47,7 @@ Setup
\xe2\x80\xa2 Packages in scope: app-a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
app-a:build: cache hit, replaying output 906851cd5c1e12d4
app-a:build: cache hit, replaying logs 906851cd5c1e12d4
app-a:build:
app-a:build: > build
app-a:build: > echo 'build app-a'
Expand Down
10 changes: 5 additions & 5 deletions turborepo-tests/integration/tests/run/force.t
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ baseline to generate cache
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, suppressing output 0d1e6ee2c143211c
my-app:build: cache hit, suppressing logs 0d1e6ee2c143211c

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand All @@ -82,7 +82,7 @@ baseline to generate cache
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, suppressing output 0d1e6ee2c143211c
my-app:build: cache hit, suppressing logs 0d1e6ee2c143211c

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand All @@ -104,7 +104,7 @@ baseline to generate cache
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, suppressing output 0d1e6ee2c143211c
my-app:build: cache hit, suppressing logs 0d1e6ee2c143211c

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand All @@ -127,7 +127,7 @@ baseline to generate cache
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, suppressing output 0d1e6ee2c143211c
my-app:build: cache hit, suppressing logs 0d1e6ee2c143211c

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand All @@ -149,7 +149,7 @@ baseline to generate cache
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, suppressing output 0d1e6ee2c143211c
my-app:build: cache hit, suppressing logs 0d1e6ee2c143211c

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand Down
4 changes: 2 additions & 2 deletions turborepo-tests/integration/tests/run/one-script-error.t
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Make sure error isn't cached
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running error in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:okay: cache hit, replaying output 9365dd2ae80cb6fb
my-app:okay: cache hit, replaying logs 9365dd2ae80cb6fb
my-app:okay:
my-app:okay: > okay
my-app:okay: > echo 'working'
Expand Down Expand Up @@ -70,7 +70,7 @@ Make sure error code isn't swallowed with continue
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running okay2 in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:okay: cache hit, replaying output 9365dd2ae80cb6fb
my-app:okay: cache hit, replaying logs 9365dd2ae80cb6fb
my-app:okay:
my-app:okay: > okay
my-app:okay: > echo 'working'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Check
$ ${TURBO} run build
\xe2\x80\xa2 Running build (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
build: cache hit, replaying output 95dd1b2d0d9ded60
build: cache hit, replaying logs 95dd1b2d0d9ded60
build: yarn run v1.22.17
build: warning package.json: No license field
build: $ echo 'building' > foo
Expand Down
2 changes: 1 addition & 1 deletion turborepo-tests/integration/tests/single_package/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Run a second time, verify caching works because there is a config
$ ${TURBO} run build --single-package
\xe2\x80\xa2 Running build (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
build: cache hit, replaying output 9d6c858db9fd1eea
build: cache hit, replaying logs 9d6c858db9fd1eea
build:
build: > build
build: > echo 'building' > foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Run a second time, verify caching works because there is a config
$ ${TURBO} run test
\xe2\x80\xa2 Running test (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
build: cache hit, replaying output fdb18de339449827
build: cache hit, replaying logs fdb18de339449827
build:
build: > build
build: > echo 'building' > foo
build:
test: cache hit, replaying output a39dd654f9f3f6a7
test: cache hit, replaying logs a39dd654f9f3f6a7
test:
test: > test
test: > [[ ( -f foo ) && $(cat foo) == 'building' ]]
Expand All @@ -44,8 +44,8 @@ Run with --output-logs=hash-only
$ ${TURBO} run test --output-logs=hash-only
\xe2\x80\xa2 Running test (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
build: cache hit, suppressing output fdb18de339449827
test: cache hit, suppressing output a39dd654f9f3f6a7
build: cache hit, suppressing logs fdb18de339449827
test: cache hit, suppressing logs a39dd654f9f3f6a7

Tasks: 2 successful, 2 total
Cached: 2 cached, 2 total
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ Setup
\xe2\x80\xa2 Packages in scope: add-keys (esc)
\xe2\x80\xa2 Running add-keys-task in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
add-keys:add-keys-underlying-task: cache hit, replaying output 247f839d50093833
add-keys:add-keys-underlying-task: cache hit, replaying logs 247f839d50093833
add-keys:add-keys-underlying-task:
add-keys:add-keys-underlying-task: > add-keys-underlying-task
add-keys:add-keys-underlying-task: > echo "running add-keys-underlying-task"
add-keys:add-keys-underlying-task:
add-keys:add-keys-underlying-task: running add-keys-underlying-task
add-keys:add-keys-task: cache hit, suppressing output be69dcce790fb9c2
add-keys:add-keys-task: cache hit, suppressing logs be69dcce790fb9c2

Tasks: 2 successful, 2 total
Cached: 2 cached, 2 total
Expand Down Expand Up @@ -82,7 +82,7 @@ Setup
\xe2\x80\xa2 Packages in scope: add-keys (esc)
\xe2\x80\xa2 Running add-keys-task in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
add-keys:add-keys-underlying-task: cache hit, replaying output ba66b7cb11224e10
add-keys:add-keys-underlying-task: cache hit, replaying logs ba66b7cb11224e10
add-keys:add-keys-underlying-task:
add-keys:add-keys-underlying-task: > add-keys-underlying-task
add-keys:add-keys-underlying-task: > echo "running add-keys-underlying-task"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Setup
\xe2\x80\xa2 Packages in scope: missing-workspace-config (esc)
\xe2\x80\xa2 Running missing-workspace-config-task in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
missing-workspace-config:missing-workspace-config-task: cache hit, suppressing output 3b9c040c7ac66cfd
missing-workspace-config:missing-workspace-config-task: cache hit, suppressing logs 3b9c040c7ac66cfd

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand Down Expand Up @@ -63,7 +63,7 @@ Setup
\xe2\x80\xa2 Packages in scope: missing-workspace-config (esc)
\xe2\x80\xa2 Running missing-workspace-config-task in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
missing-workspace-config:missing-workspace-config-task: cache hit, suppressing output 395c409c711b5ddd
missing-workspace-config:missing-workspace-config-task: cache hit, suppressing logs 395c409c711b5ddd

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Setup
\xe2\x80\xa2 Packages in scope: omit-keys (esc)
\xe2\x80\xa2 Running omit-keys-task in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
omit-keys:omit-keys-task: cache hit, suppressing output b5601a9434941180
omit-keys:omit-keys-task: cache hit, suppressing logs b5601a9434941180

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand Down Expand Up @@ -66,7 +66,7 @@ Setup
\xe2\x80\xa2 Packages in scope: omit-keys (esc)
\xe2\x80\xa2 Running omit-keys-task in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
omit-keys:omit-keys-task: cache hit, suppressing output d6273078707d2688
omit-keys:omit-keys-task: cache hit, suppressing logs d6273078707d2688

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Setup
\xe2\x80\xa2 Packages in scope: override-values (esc)
\xe2\x80\xa2 Running override-values-task in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
override-values:override-values-task: cache hit, replaying output 676bf15624566937
override-values:override-values-task: cache hit, replaying logs 676bf15624566937
override-values:override-values-task:
override-values:override-values-task: > override-values-task
override-values:override-values-task: > echo "running override-values-task" > lib/bar.min.txt
Expand Down Expand Up @@ -66,7 +66,7 @@ Setup
\xe2\x80\xa2 Packages in scope: override-values (esc)
\xe2\x80\xa2 Running override-values-task in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
override-values:override-values-task: cache hit, replaying output 04f174d88e33b365
override-values:override-values-task: cache hit, replaying logs 04f174d88e33b365
override-values:override-values-task:
override-values:override-values-task: > override-values-task
override-values:override-values-task: > echo "running override-values-task" > lib/bar.min.txt
Expand Down Expand Up @@ -96,7 +96,7 @@ Setup
\xe2\x80\xa2 Packages in scope: override-values (esc)
\xe2\x80\xa2 Running override-values-task in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
override-values:override-values-task: cache hit, replaying output bb2616d0a2d6716c
override-values:override-values-task: cache hit, replaying logs bb2616d0a2d6716c
override-values:override-values-task:
override-values:override-values-task: > override-values-task
override-values:override-values-task: > echo "running override-values-task" > lib/bar.min.txt
Expand Down

1 comment on commit eaf20a2

@vercel
Copy link

@vercel vercel bot commented on eaf20a2 Jun 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.