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

List goal with --changed-since doesn't list BUILD file changes #21763

Open
KristianTashkov opened this issue Dec 16, 2024 · 2 comments
Open

List goal with --changed-since doesn't list BUILD file changes #21763

KristianTashkov opened this issue Dec 16, 2024 · 2 comments
Labels

Comments

@KristianTashkov
Copy link

Describe the bug
Making a change in a BUILD file and then running on changed targets has differing behavior depending on whether you use --changed-since as a goal filter or if you save the result into a file via list and use --spec-files on the lint goal.

Steps to reproduce:

git clone https://github.com/pantsbuild/example-python
cd example-python
echo "" >> helloworld/BUILD

# This correctly fails black because the BUILD file format has an extra new line in the end
pants --changed-since=HEAD lint 

# runs linter only on source mapped inside changed BUILD FILE, but not the BUILD file itself so black passes.
pants --changed-since=HEAD list > changed_targets.txt 
pants --spec-files=changed_targets.txt lint   

With the contents of changed_targets.txt:

helloworld:pex_binary
helloworld/__init__.py:lib
helloworld/main.py:lib

Pants version
2.23.0

OS
MacOS

Additional info

@lilatomic
Copy link
Contributor

The list goal:

Lists all targets matching the file or target arguments.

I think the list & --spec-files might be working as intended, since BUILD files are not targets. I'm actually a little surprised that pants --changed-since=HEAD lint includes the BUILD file. I thought it would only be linted with pants update-build-files --check. So maybe the --changed-since is incorrect.

@KristianTashkov
Copy link
Author

Is there a reason there is no build_source target automatically generated for each BUILD file?
I agree that list specifically mentions outputting only targets, while --spec-files works with both targets and files, so the current behavior makes sense from a functional standpoint. From a practical standpoint we probably would want to have a way to run all relevant linters on changed (similar to how pants --changed-since=HEAD lint does it), but with a deferred saved list targets.

Keep in mind that pants lint :: also lints BUILD files, so update-build-files is not the only way to run linters on BUILD files currently.

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

No branches or pull requests

2 participants