See [Goal arguments](🔗) for the normal techniques for telling Pants what to run on.
See [Project introspection](🔗) for queries that you can run and then pipe into another Pants run, such as finding the dependencies of a target or file.
## Running over changed files with `
Because Pants understands Git, it can find which files have changed since a certain commit through the `
For example, to lint all uncommitted files, run:
To run against another branch, run:
By default, `
--changed-since` will only run over files directly changed. Often, though, you will want to run over any [dependees](🔗) of those changed files, meaning any targets that depend on the changed files. Use `
--changed-dependees=direct` or `
--changed-dependees=transitive` for this:
Use filters to operate on only targets that match the predicate, e.g. only running Python tests.
Specify a predicate by using one of the below `
filter` options, like `
can use a comma to OR multiple values, meaning that at least one member must be matched. You
can repeat the option multiple times to AND each filter. You can prefix the filter with
-` to negate the filter, meaning that the target must not be true for the filter.
You can combine multiple filter options in the same run, e.g.:
Each value should be the name of a target type, e.g.
./pants --filter-target-type=python_test test ::`.
./pants help targets` to see what targets are registered.
Regex strings for the address, such as
./pants --filter-address-regex='^integration_tests$' test ::`.
Regex strings to match against the `
tags` field, such as
./pants --filter-tag-regex='^skip_lint$' lint ::`.
If you don't need the power of regex, use the simpler `
--tag` global option explained below.
## Tags: annotating targets
Every target type has a field called `
tags`, which allows you to add a sequence of strings. The
strings can be whatever you'd like, such as `
You can then filter by tags with the global `
--tag` [option](🔗), like this:
To exclude certain tags, prefix with a `
You can even combine multiple includes and excludes:
--filter-tag-regex` instead for more complex queries.
The global option `
--spec-files` allows you to pass a file containing target addresses and/or file names/globs to Pants.
Each entry must be separated by a new line.
Tip: centralized allow/block lists
tags` are useful for _decentralized_ allow/block lists, `
--spec-files` is useful when you want to define one single list of targets or files.
## Piping to other Pants runs
To pipe a Pants run, use your shell's `
|` pipe operator and `
You can, of course, pipe multiple times:
Alternative: use `
Sometimes, you may want to reuse the output of a Pants run for multiple subsequent Pants runs. Rather than repeating `
xargs` multiple times, you can generate a file through stdout redirection and `
If you don't want to save the output to an actual file—such as to not pollute version control—you can use a variable and a named pipe:
## Sharding the input targets
test` goal natively supports sharding input targets into multiple shards. Use the option `
--test-shard=k/N`, where k is a non-negative integer less than N. For example, you can split up your CI into three shards with `
--shard=1/3`, and `
For other goals, you can leverage shell piping to partition the input targets into multiple shards. For example, to split your `
package` run into 5 shards, and select shard 0: