Skip to content

Commit

Permalink
fix: unnecessary empty cache logs (#9301)
Browse files Browse the repository at this point in the history
### Description

In #9236 I added a check if the task output globs are empty. Turns out
we need to check if the output globs only has a single entry for the log
file.

Fixes #9291

### Testing Instructions

`basic_monorepo` has both a task that has globs and no outputs and a
task that has empty globs and no outputs. Note that we warn for one and
not the other.
  • Loading branch information
NicholasLYang authored Oct 21, 2024
1 parent bf8fa90 commit 82f0633
Show file tree
Hide file tree
Showing 34 changed files with 6 additions and 78 deletions.
6 changes: 5 additions & 1 deletion crates/turborepo-lib/src/task_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ pub struct TaskOutputs {
}

impl TaskOutputs {
// We consider an empty outputs to be a log output and nothing else
pub fn is_empty(&self) -> bool {
self.inclusions.is_empty() && self.exclusions.is_empty()
self.inclusions.len() == 1
&& self.inclusions[0].ends_with(".log")
&& self.exclusions.is_empty()
}

pub fn validated_inclusions(&self) -> Result<Vec<ValidatedGlob>, GlobError> {
self.inclusions
.iter()
Expand Down
1 change: 0 additions & 1 deletion turborepo-tests/integration/tests/filter-run.t
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Setup
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`

Non existent package name should error
$ ${TURBO} run build --filter="foo" --output-logs none
Expand Down
3 changes: 0 additions & 3 deletions turborepo-tests/integration/tests/global-env.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Setup
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`
# run again and ensure there's a cache hit
$ ${TURBO} run build --filter=util --output-logs=hash-only
\xe2\x80\xa2 Packages in scope: util (esc)
Expand All @@ -37,7 +36,6 @@ Setup
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`
# set env var with "THASH" and ensure cache miss
$ SOMETHING_THASH_YES=hi ${TURBO} run build --filter=util --output-logs=hash-only
\xe2\x80\xa2 Packages in scope: util (esc)
Expand All @@ -60,7 +58,6 @@ Setup
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`
# THASH deprecation doesn't break --dry=json
$ SOMETHING_THASH_YES=hi ${TURBO} run build --filter=util --dry=json | jq -r '.tasks[0].environmentVariables.global[0]'
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Populate cache
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task a#build. Please check your `outputs` key in `turbo.json`
$ ${TURBO} build --filter=b
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -26,7 +25,6 @@ Populate cache
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`

Bump dependency for b and rebuild
Only b should have a cache miss
Expand Down Expand Up @@ -55,7 +53,6 @@ Only b should have a cache miss
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`
Add lockfile changes to a commit
$ git add . && git commit -m "bump lockfile" --quiet
Only root and b should be rebuilt since only the deps for b had a version bump
Expand All @@ -79,7 +76,6 @@ Bump of root workspace invalidates all packages
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task a#build. Please check your `outputs` key in `turbo.json`
$ ${TURBO} build --filter=b
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -91,7 +87,6 @@ Bump of root workspace invalidates all packages
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`
Add lockfile changes to a commit
$ git add . && git commit -m "global lockfile change" --quiet
Everything should be rebuilt as a dependency of the root package got bumped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Populate cache
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task a#build. Please check your `outputs` key in `turbo.json`
$ ${TURBO} build --filter=b
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -34,7 +33,6 @@ Populate cache
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`

Bump dependency for b and rebuild
Only b should have a cache miss
Expand Down Expand Up @@ -71,7 +69,6 @@ Only b should have a cache miss
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`
Add lockfile changes to a commit
$ git add . && git commit -m "bump lockfile" --quiet
Only root and b should be rebuilt since only the deps for b had a version bump
Expand Down Expand Up @@ -99,7 +96,6 @@ Bump of root workspace invalidates all packages
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task a#build. Please check your `outputs` key in `turbo.json`
$ ${TURBO} build --filter=b
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -115,7 +111,6 @@ Bump of root workspace invalidates all packages
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`
Add lockfile changes to a commit
$ git add . && git commit -m "global lockfile change" --quiet
Everything should be rebuilt as a dependency of the root package got bumped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Populate cache
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task a#build. Please check your `outputs` key in `turbo.json`
$ ${TURBO} build --filter=b
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -34,7 +33,6 @@ Populate cache
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`

Bump dependency for b and rebuild
Only b should have a cache miss
Expand Down Expand Up @@ -71,7 +69,6 @@ Only b should have a cache miss
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`
Add lockfile changes to a commit
$ git add . && git commit -m "bump pnpm-lock" --quiet
Only root and b should be rebuilt since only the deps for b had a version bump
Expand Down Expand Up @@ -124,7 +121,6 @@ Bump of root workspace invalidates all packages
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)
WARNING no output files found for task a#build. Please check your `outputs` key in `turbo.json`
$ ${TURBO} build --filter=b
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -140,7 +136,6 @@ Bump of root workspace invalidates all packages
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)
WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`
Add lockfile changes to a commit
$ git add . && git commit -m "global lockfile change" --quiet
Everything should be rebuilt as a dependency of the root package got bumped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Populate cache
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task a#build. Please check your `outputs` key in `turbo.json`
$ ${TURBO} build --filter=b
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -34,7 +33,6 @@ Populate cache
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`

Bump dependency for b and rebuild
Only b should have a cache miss
Expand Down Expand Up @@ -71,7 +69,6 @@ Only b should have a cache miss
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`
Add lockfile changes to a commit
$ git add . && git commit -m "bump lockfile" --quiet
Only root and b should be rebuilt since only the deps for b had a version bump
Expand Down Expand Up @@ -124,7 +121,6 @@ Bump of root workspace invalidates all packages
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)
WARNING no output files found for task a#build. Please check your `outputs` key in `turbo.json`
$ ${TURBO} build --filter=b
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -140,7 +136,6 @@ Bump of root workspace invalidates all packages
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)
WARNING no output files found for task b#build. Please check your `outputs` key in `turbo.json`
Add lockfile changes to a commit
$ git add . && git commit -m "global lockfile change" --quiet
Everything should be rebuilt as a dependency of the root package got bumped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@
Cached: 0 cached, 1 total
Time:\s+[.0-9]+m?s (re)

WARNING no output files found for task app-a#dev. Please check your `outputs` key in `turbo.json`
1 change: 0 additions & 1 deletion turborepo-tests/integration/tests/pkg-inference.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ Setup
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ Make sure that the internal util package is part of the prune output
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task docs#new-task. Please check your `outputs` key in `turbo.json`


Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Run a build to get a local cache.
Time:\s+[.0-9]+m?s (re)

WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`


Do a dry run so we can see the state of the cache
Expand Down
2 changes: 0 additions & 2 deletions turborepo-tests/integration/tests/run-logging/errors-only.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Setup
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task app-a#build. Please check your `outputs` key in `turbo.json`



Expand All @@ -29,7 +28,6 @@ Setup
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task app-a#buildsuccess. Please check your `outputs` key in `turbo.json`


# [x] error exit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ because otherwise prysk interprets them as multiline commands
Cached: 0 cached, 2 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`
# Build as if we are in Github Actions with a task log prefix.
$ GITHUB_ACTIONS=1 ${TURBO} run build --force --log-prefix="task" --filter=util
\xe2\x80\xa2 Packages in scope: util (esc)
Expand All @@ -52,7 +50,6 @@ because otherwise prysk interprets them as multiline commands
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`

Verify that errors are grouped properly
$ GITHUB_ACTIONS=1 ${TURBO} run fail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
Cached: 0 cached, 2 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`


# We can get the same behavior with an env var
Expand All @@ -53,8 +51,6 @@
Cached: 0 cached, 2 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`

# The flag wins over the env var
$ TURBO_LOG_ORDER=stream ${TURBO} run build --log-order grouped --force
Expand All @@ -80,6 +76,4 @@
Cached: 0 cached, 2 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`

Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
Cached: 0 cached, 2 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`

The env var set to stream works (this is default, so this test doesn't guarantee the env var is "working"),
it just guarantees setting this env var won't crash.
Expand All @@ -53,8 +51,6 @@ it just guarantees setting this env var won't crash.
Cached: 0 cached, 2 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`

The flag wins over the env var
$ TURBO_LOG_ORDER=grouped ${TURBO} run build --log-order stream --force
Expand All @@ -80,6 +76,4 @@ The flag wins over the env var
Cached: 0 cached, 2 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`


1 change: 0 additions & 1 deletion turborepo-tests/integration/tests/run-logging/log-prefix.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Setup
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task app-a#build. Please check your `outputs` key in `turbo.json`
# Check that the cached logs don't have prefixes
$ cat app-a/.turbo/turbo-build.log

Expand Down
2 changes: 0 additions & 2 deletions turborepo-tests/integration/tests/run-logging/verbosity.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Verbosity level 1
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`
$ ${TURBO} build --verbosity=1 --filter=util --force
\xe2\x80\xa2 Packages in scope: util (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -33,7 +32,6 @@ Verbosity level 1
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`

Verbosity level 2
$ ${TURBO} build -vv --filter=util --force 1> VERBOSEVV 2>&1
Expand Down
1 change: 0 additions & 1 deletion turborepo-tests/integration/tests/run-summary/enable.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Setup
$ rm -rf .turbo/runs
$ TURBO_RUN_SUMMARY=true ${TURBO} run build > /dev/null
WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`
$ /bin/ls .turbo/runs/*.json | wc -l
\s*1 (re)
# env var=true, --flag=true: yes
Expand Down
1 change: 0 additions & 1 deletion turborepo-tests/integration/tests/run-summary/monorepo.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Setup

$ ${TURBO} run build --summarize -- someargs > /dev/null # first run (should be cache miss)
WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`

# HACK: Generated run summaries are named with a ksuid, which is a time-sorted ID. This _generally_ works
# but we're seeing in this test that sometimes a summary file is not sorted (with /bin/ls) in the order we expect
Expand Down
1 change: 0 additions & 1 deletion turborepo-tests/integration/tests/run/continue.t
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,5 @@ Run with --continue
Time:\s*[\.0-9]+m?s (re)
Failed: other-app#build, some-lib#build

WARNING no output files found for task my-app#build. Please check your `outputs` key in `turbo.json`
ERROR run failed: command exited (1)
[1]
2 changes: 0 additions & 2 deletions turborepo-tests/integration/tests/run/gitignored-inputs.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Some helper functions to parse the summary file

Just run the util package, it's simpler
$ ${TURBO} run build --filter=util --output-logs=hash-only --summarize | grep "util:build: cache"
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`
util:build: cache miss, executing 11cff3dd389fdfed

$ FIRST=$(/bin/ls .turbo/runs/*.json | head -n1)
Expand All @@ -31,7 +30,6 @@ Change the content of internal.txt

Hash does not change, because it is gitignored
$ ${TURBO} run build --filter=util --output-logs=hash-only --summarize | grep "util:build: cache"
WARNING no output files found for task util#build. Please check your `outputs` key in `turbo.json`
util:build: cache miss, executing a489883a3c7cd307

The internal.txt hash should be different from the one before
Expand Down
2 changes: 0 additions & 2 deletions turborepo-tests/integration/tests/run/one-script-error.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Note that npm reports any failed script as exit code 1, even though we "exit 2"
Time:\s*[\.0-9]+m?s (re)
Failed: my-app#error

WARNING no output files found for task my-app#okay. Please check your `outputs` key in `turbo.json`
ERROR run failed: command exited (1)
[1]

Expand Down Expand Up @@ -99,6 +98,5 @@ Make sure error code isn't swallowed with continue
Time:\s*[\.0-9]+m?s (re)
Failed: my-app#error

WARNING no output files found for task my-app#okay2. Please check your `outputs` key in `turbo.json`
ERROR run failed: command exited (1)
[1]
Loading

0 comments on commit 82f0633

Please sign in to comment.