Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] feat(docs): $TURBO_DEFAULT$ #7155

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pages/repo/docs/core-concepts/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Now, make sure that `turbo` is aware of the file by adding it to task inputs. Yo
"pipelines": {
"build-for-platforms": {
"dependsOn": ["^build"],
"inputs": ["turbo-cache-key.json", ...]
"inputs": ["$TURBO_DEFAULT$", "turbo-cache-key.json"]
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions docs/pages/repo/docs/core-concepts/caching/file-inputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ You should aim to have both Git and the Git index of your repository available f

<Callout>
Customizing the `inputs` immediately opts out of the default behavior. You must manually specify via `pipeline.<task>.inputs` all of the files that should be considered.

For convienence, you can use the special string `$TURBO_DEFAULT$` within an inputs array to automatically include all files considered in the default behavior. This allows
you to customize the inputs without needing to manually specify all of the files that would have been considered by default.

</Callout>

For some tasks it is worthwhile to reduce the number of file inputs into the task hash consideration. Very few tasks depend on the contents of `README.md`. Specifying just the files that matter can increase the frequency of cache hits.
Expand Down Expand Up @@ -114,3 +118,16 @@ If a task depends on another task which specifies file dependencies they do not
```

This pattern can be used to save yourself from needing to repetitively enumerate a list of file globs for every single task.

You may also want to keep the default behavior, but only include, or exclude a few files. You can use the special string `$TURBO_DEFAULT$` to include all of the files that would have been considered by default:

```jsonc filename="/turbo.json"
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"inputs": ["$TURBO_DEFAULT$", "!README.md", "a-git-ignored-file.txt"]
}
}
}
```
21 changes: 20 additions & 1 deletion docs/pages/repo/docs/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,12 @@ Defaults to `true`. Whether or not to cache the task [`outputs`](#outputs). Sett

Tells `turbo` the set of files to consider when determining if a package has changed for a particular task.
Setting this to a list of globs will cause the task to only be run when files matching those globs have
changed. This can be helpful if you want to, for example, skip running tests unless a source file changed.
changed. This can be helpful if you want to, for example, skip running tests unless a source file changed, or
explicitly depend on a `.gitignore`d file.

Because specifying an `inputs` key immediately opts out of the default behavior, you may specify
the special string `$TURBO_DEFAULT$` within an inputs array to include all default inputs. This is useful
if you want to add or remove additional inputs from the default set.

The default is `[]` to run the task when any file in the package changes.

Expand All @@ -384,6 +389,20 @@ The default is `[]` to run the task when any file in the package changes.
}
```

`$TURBO_DEFAULT$` **Example**

```jsonc
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"check-types": {
// Consider all default inputs except the README.md
"inputs": ["$TURBO_DEFAULT$", "!README.md"],
}
}
}
```

<Callout type="info">
Note: `turbo.json` is *always* considered an input. If you modify
`turbo.json`, all caches are invalidated.
Expand Down
Loading