Build caching can dramatically speed up your tasks - but you can do even better by using
npx turbo-ignore. If your workspace is unaffected by your code changes, you can completely skip executing a task altogether.
Let's say you want to skip the unit tests for your
web workspace when there aren't any changes to your
web application (or its package dependencies). If you are already using Remote Caching (opens in a new tab), you will probably get a cache hit, but you would still spend time provisioning the CI container, installing
npm dependencies, and other things that can take a while.
Ideally, we would do a quick check to see if any of that work needs to happen in the first place.
After we've checked out the repo, but before any other work, we can take a few seconds to check that our
web tests have changed since the parent commit.
npx turbo-ignore web --task=test
This command will:
- Filter for the
- Create the
dryoutput for your
testtask compared to your parent commit.
- Parse the output to determine which packages have changed.
- Exit with a
1code if changes are detected. Otherwise, exits with a
While you may have been able to hit a
>>> FULL TURBO cache for this task, we just saved time with all of the other setup tasks required to run your CI.
To skip unaffected work, first ensure that your git history is available on the machine. Then, run
turbo-ignore uses a combination of the
--dry=json flags to find changes from the parent commit to the current commit to identify affected packages. By default,
turbo-ignore finds the difference for the build task in the current working directory, but you can customize this behavior with flags.
Here's an example of the command that will be built and run:
npx turbo run build --filter=@example/web...3c8387ffd98b751305fe3f0284befdd00cbd4610 --dry=json
Note that a dry run does not execute the build task. Instead, it checks your packages to see if your code changes will affect your build (or other task) in only a few seconds.
turbo-ignore finds that the task can be skipped, it will exit the process with a
0 code. If changes have been found, the process will exit with
To specify a workspace, you can add it to your command like:
npx turbo-ignore web
web is your workspace's name.
If you'd like to change more of the default behavior, there are a few flags available:
--task: Specifies the task for the command that
turbo-ignorewill invoke. Defaults to
--fallback: Specify a ref/head to compare against. Defaults to
turbo-ignore on Vercel
npx turbo-ignore on Vercel, you can use the Ignored Build Step (opens in a new tab) feature. Vercel will automatically infer the correct arguments to successfully run