Skip to content

Commit 372bac6

Browse files
committed
docs: Clarifications for --affected.
1 parent ab04627 commit 372bac6

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

docs/repo-docs/crafting-your-repository/constructing-ci.mdx

+18-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ You can filter your tasks using [the `--filter` flag](/repo/docs/reference/run#-
4646
available.
4747
</Callout>
4848

49+
You can also use [the `--affected` flag](#running-only-affected-tasks) to only run tasks that have changes.
50+
4951
## Docker
5052

5153
Docker is an important part of many deployment pipelines. [Turborepo's `prune` subcommand](/repo/docs/reference/prune) helps you ship lightweight images by removing unnecessary dependencies and code from your images.
@@ -54,7 +56,22 @@ For more on how to deploy from a Turborepo with Docker, visit [the dedicated Doc
5456

5557
## Skipping tasks and other unnecessary work
5658

57-
Using Turborepo's built-in caching is a great way to speed up your CI. We encourage you to start by relying on Turborepo's caching and parallelization when you're starting out with Turborepo.
59+
### Running only affected tasks
60+
61+
You can use the `--affected` flag to only run tasks that have changes.
62+
63+
```bash title="Terminal
64+
turbo run build --affected
65+
```
66+
67+
You'll want to use this flag in situations like:
68+
69+
- You're running many tasks across packages in your monorepo, and only want to run those tasks in packages with code changes.
70+
- You’re _not_ using a Remote Cache, but still want to do as little work as possible in CI.
71+
- You _are_ using a Remote Cache, and you’re in a large repository. By minimizing the amount of tasks that will be restored from cache, there will be less data to send across the network, resulting in faster cache restoration.
72+
- You’re already using [advanced filtering techniques](/repo/docs/reference/run#advanced-filtering-examples) or [`turbo-ignore`](/repo/docs/reference/turbo-ignore) to create the same or similar behavior as `--affected`. You likely have the opportunity to simplify your scripting using this new flag.
73+
74+
### Using `turbo-ignore`
5875

5976
As your codebase and CI grow, you may start to look for more ways to get even faster. While hitting cache is useful, you also may be able to skip work entirely. Using `turbo-ignore`, you can skip lengthy container preparation steps like dependency installation that will end up resulting in a cache hit, anyway.
6077

docs/repo-docs/reference/run.mdx

+13-6
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,26 @@ turbo run
3636
3737
Automatically filter to only packages that are affected by changes on the current branch.
3838
39-
By default the changes considered are those between `main` and `HEAD`.
39+
By default, the changes considered are those between `main` and `HEAD` from Git's perspective. Equivalent to `--filter=[main…HEAD]`.
4040
41-
- You can override `main` as the default base by setting `TURBO_SCM_BASE`.
42-
- You can override `HEAD` as the default head by setting `TURBO_SCM_HEAD`.
41+
```bash title="Terminal"
42+
turbo run build lint test --affected
43+
```
44+
45+
You can override the default base and head with their respective [System Environment Variables](/repo/docs/reference/system-environment-variables).
4346
4447
```bash title="Terminal"
48+
# Override Git comparison base
4549
TURBO_SCM_BASE=development turbo run build --affected
50+
51+
# Override Git comparison head
52+
TURBO_SCM_HEAD=your-branch turbo run build --affected
4653
```
4754
4855
<Callout type="warn">
49-
Performing this comparison requires everything between base and head to exist in
50-
the checkout. If the checkout is too shallow, then all packages will be
51-
considered changed.
56+
The comparison requires everything between base and head to exist in the
57+
checkout. If the checkout is too shallow, then all packages will be considered
58+
changed.
5259
</Callout>
5360
5461
### `--cache-dir <path>`

0 commit comments

Comments
 (0)