Add protobuf linting using Buf#14540
Conversation
Ah, I wasn't careful enough in my comment. I agree with your decision to use |
Eric-Arellano
left a comment
There was a problem hiding this comment.
Huzzah!
change the rule to use TransitiveTargets instead somehow
Idk how Buf works, but Protoc does need all transitive deps to be present:
pants/src/python/pants/backend/codegen/protobuf/python/rules.py
Lines 65 to 70 in e45b00d
Once direct deps are working, it'd be great to update the test to check transitive deps are handled, like:
but I believe using StrippedSourceFiles would be a more proper solution by the sound of it
That is what we do for Protoc
pants/src/python/pants/backend/codegen/protobuf/python/rules.py
Lines 72 to 84 in e45b00d
It would indeed be great to update tests to use source roots, at least one test with no source root (i.e. /) and one with multiple. rules_integration_test.py might give some inspiration.
--
I'm not sure what is going wrong with dependencies..it looks right to me. Let me know if you feel stuck on it, I can try to play around with it or pair program :) I'm definitely not a Protobuf expert, but implemented the original Protoc support so could hopefully be helpful.
|
All comments have been addressed. Managed to get dependencies and source roots working after scratching my head for a bit. Added a test for it to make sure it really works :) |
Eric-Arellano
left a comment
There was a problem hiding this comment.
This is awesome. Thank you so much! This will be a main highlight for Pants 2.11 :)
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust]
This PR aims to add initial linting support for protobufs.
Some notes:
backend/codegen/protobuf/lint/buffor now, though happy to move it tobackend/protobuf/lint/bufinstead (as suggested in Protobuf linting (and more!) using Buf CLI #13189).backend/codegen/protobufinstead of inbackend/codegen/protobuf/lint/bufsince I imagine it can and will be reused to future Buf functionality (like the BC breaking check).TransitiveTargetsinstead somehow, or integrate directly withinfer_protobuf_dependencies(). Leaving that to the experts :)--pathare prefixed with their source root(s). I got around it in my own PoC plugin by simply telling Buf about my source roots in its config file, but I believe usingStrippedSourceFileswould be a more proper solution by the sound of it (not to mention that the config key I used in the PoC only works in their v1beta config format).