Reputation: 3740
I'm getting started with Bazel and I was running if there was a simple way to integrate buildifier every time I run bazel build ?
Upvotes: 3
Views: 1011
Reputation: 338
You can implement this as a test rule, where ctx.file_action can be used to generate a shell script that runs buildifier in "check" mode. The shell scripts exits non-zero if buildifier generates any output (e.g., file is not formatted correctly), and exits zero if everything is OK.
Then you can invoke this rule in all of your BUILD files as a test, so that "bazel test ..." picks it up.
(This is probably not "a simple way", but it is a way.)
Upvotes: 2