Open boschni opened 1 year ago
Realistically this is a bug. We take too-conservative of an approach in calculating whether or not a package has changed.
In particular, getChangedFiles
should be taking into account the inputs
for each of the tasks here:
https://github.com/vercel/turbo/blob/main/cli/internal/scope/scope.go#L363-L380
We capture the need to make this change here: https://github.com/vercel/turbo/blob/main/cli/internal/scope/scope.go#L212-L213
I am able to reproduce this bug using the example repo and latest canary.
npx create-turbo@v2.0.13-canary.0
"inputs": ["$TURBO_DEFAULT$", "!README.md"]
to the lint
task in turbo.json (exactly like in the docs), commitnpm run lint -- -F='[HEAD^1]'
-> runs lint
task in the ui
package, even though only README.md
has changedRunning with dry-run=json
: README.md
is not part of inputs (correct)
Running with -vvv
: globwalk
includes the README file in each package rather than excluding it. I haven't dived into the source code but you get the feeling that it should be the opposite.
Which project is this feature idea for?
Turborepo
Describe the feature you'd like to request
I would like to be able to skip tasks when the
inputs
did not change.For example, given the following workspace:
And the following turbo configuration:
Then in a CI pipeline I want to be able to:
build
task whenindex.ts
changed, or anyinputs
from the tasks specified independsOn
.test
task whenindex.ts
orindex.spec.ts
changed, or anyinputs
from the tasks specified independsOn
.Currently, a commit that only modifies
README.md
will causeturbo run <task> --filter=...[HEAD^1]
to always run the given task even though this might not be needed.Describe the solution you'd like
A possible solution would be to:
Add a CLI command like
--filter-inputs
to filter by theinputs
of the given tasks.Running
turbo run build --filter=...[HEAD^1] --filter-inputs
would only includeindex.ts
.Running
turbo run test --filter=...[HEAD^1] --filter-inputs
would only includeindex.ts
andindex.spec.ts
.Running
turbo run build test --filter=...[HEAD^1] --filter-inputs
would be less useful as it would includeindex.ts
andindex.spec.ts
for both tasks. To support multiple tasks turbo would need to be be able to filter individual tasks instead of files but I'm not sure if this aligns well with how turbo currently works.Describe alternatives you've considered
It is possible to ignore files with
turbo run <task> --filter=...[HEAD^1] --ignore "**/*.md"
but this does not scale as each workspace and task might have different requirements.