diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 22d31662d3..09af992bf6 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1,6 +1,7 @@ --- buildifier: version: latest + # keep this argument in sync with .pre-commit-config.yaml warnings: "all" all_targets: &all_targets build_targets: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..79f025d6c7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +# See CONTRIBUTING.md for instructions. +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/keith/pre-commit-buildifier + rev: 4.0.1.1 + hooks: + - id: buildifier + args: &args + # Keep this argument in sync with .bazelci/presubmit.yaml + - --warnings=all + - id: buildifier-lint + args: *args diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 680373f516..74afc7e7b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,6 +3,19 @@ We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow. +## Formatting + +Starlark files should be formatted by buildifier. +We suggest using a pre-commit hook to automate this. +First [install pre-commit](https://pre-commit.com/#installation), +then run + +```shell +pre-commit install +``` + +Otherwise the Buildkite CI will yell at you about formatting/linting violations. + ## Contributor License Agreement Contributions to this project must be accompanied by a Contributor License