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

feat(filter): error on invalid filters #8142

Merged

Conversation

chris-olszewski
Copy link
Member

Description

This PR changes --filter so it now will error on certain malformed filters:

  • Name filters with no globs that don't match any packages e.g. --filter=fo instead of --filter=foo
  • Directory filters that reference a directory that doesn't exist: e.g. --filter='./pakcages/*'

Each commit of the PR can be reviewed on it's own.

Testing Instructions

Updated existing unit tests. Added additional ones along with an integration test.

Copy link

vercel bot commented May 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2024 4:01pm
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2024 4:01pm
8 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 4:01pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 4:01pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 4:01pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 4:01pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 4:01pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 4:01pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 4:01pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 4:01pm

Copy link
Contributor

github-actions bot commented May 14, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Base automatically changed from chrisolszewski/turbo-3125-stop-inference-of-package-names-in-scope to turborepo_2 May 15, 2024 00:20
Copy link
Contributor

github-actions bot commented May 15, 2024

🟢 CI successful 🟢

Thanks

Copy link
Contributor

@mehulkar mehulkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, reviewed by commit. What happens if -F ./packages/* is given and packages dir exists, but doesn't have any subdirectories? Do we care about erroring on that case?

crates/turborepo-lib/src/run/scope/filter.rs Show resolved Hide resolved
@@ -2,13 +2,17 @@ Setup
$ . ${TESTDIR}/../../../helpers/setup_integration_test.sh

# Save JSON to tmp file so we don't need to keep re-running the build
$ ${TURBO} run build --dry=json --filter=main > tmpjson.log
$ ${TURBO} run build --dry=json --filter='[main]' > tmpjson.log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I wrote these tests? but I am not sure if even this is valid usage of --filter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you wanted to write a filter for changes since main, but without the brackets it was just a filter for the non-existent main package.

@chris-olszewski
Copy link
Member Author

What happens if -F ./packages/* is given and packages dir exists, but doesn't have any subdirectories? Do we care about erroring on that case?

I don't think we should since we decided to only error on clearly wrong filters and not all filters that don't run tasks. For a similar reason we don't error if the user runs turbo build --filter=foo if foo doesn't have a build task.

@chris-olszewski chris-olszewski enabled auto-merge (squash) May 16, 2024 15:53
@chris-olszewski chris-olszewski merged commit 450419a into turborepo_2 May 16, 2024
55 checks passed
@chris-olszewski chris-olszewski deleted the chrisolszewski/turbo-2711-make-filter-strict branch May 16, 2024 16:52
chris-olszewski added a commit that referenced this pull request May 20, 2024
### Description

This PR changes `--filter` so it now will error on certain malformed
filters:
- Name filters with no globs that don't match any packages e.g.
`--filter=fo` instead of `--filter=foo`
- Directory filters that reference a directory that doesn't exist: e.g.
`--filter='./pakcages/*'`

Each commit of the PR can be reviewed on it's own.

### Testing Instructions

Updated existing unit tests. Added additional ones along with an
integration test.
chris-olszewski added a commit that referenced this pull request May 22, 2024
### Description

This PR changes `--filter` so it now will error on certain malformed
filters:
- Name filters with no globs that don't match any packages e.g.
`--filter=fo` instead of `--filter=foo`
- Directory filters that reference a directory that doesn't exist: e.g.
`--filter='./pakcages/*'`

Each commit of the PR can be reviewed on it's own.

### Testing Instructions

Updated existing unit tests. Added additional ones along with an
integration test.
chris-olszewski added a commit that referenced this pull request May 28, 2024
### Description

This PR changes `--filter` so it now will error on certain malformed
filters:
- Name filters with no globs that don't match any packages e.g.
`--filter=fo` instead of `--filter=foo`
- Directory filters that reference a directory that doesn't exist: e.g.
`--filter='./pakcages/*'`

Each commit of the PR can be reviewed on it's own.

### Testing Instructions

Updated existing unit tests. Added additional ones along with an
integration test.
chris-olszewski added a commit that referenced this pull request May 29, 2024
### Description

This PR changes `--filter` so it now will error on certain malformed
filters:
- Name filters with no globs that don't match any packages e.g.
`--filter=fo` instead of `--filter=foo`
- Directory filters that reference a directory that doesn't exist: e.g.
`--filter='./pakcages/*'`

Each commit of the PR can be reviewed on it's own.

### Testing Instructions

Updated existing unit tests. Added additional ones along with an
integration test.
chris-olszewski added a commit that referenced this pull request May 31, 2024
### Description

This PR changes `--filter` so it now will error on certain malformed
filters:
- Name filters with no globs that don't match any packages e.g.
`--filter=fo` instead of `--filter=foo`
- Directory filters that reference a directory that doesn't exist: e.g.
`--filter='./pakcages/*'`

Each commit of the PR can be reviewed on it's own.

### Testing Instructions

Updated existing unit tests. Added additional ones along with an
integration test.
chris-olszewski added a commit that referenced this pull request Jun 4, 2024
### Description

This PR changes `--filter` so it now will error on certain malformed
filters:
- Name filters with no globs that don't match any packages e.g.
`--filter=fo` instead of `--filter=foo`
- Directory filters that reference a directory that doesn't exist: e.g.
`--filter='./pakcages/*'`

Each commit of the PR can be reviewed on it's own.

### Testing Instructions

Updated existing unit tests. Added additional ones along with an
integration test.
@zouguangxian
Copy link

zouguangxian commented Jul 17, 2024

@chris-olszewski
Is it possible to support run build on a package only if there are changes between the main branch and HEAD, it is very helpful in the Github workflow actions.

turbo run build --filter='core[main...HEAD]'

it works with Turbo v1, but it will throw errors with Turbo v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants