From feb8a0763ab1c61dd3d7330e67fcf639304d2aff Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Thu, 3 Jun 2021 12:37:18 -0700 Subject: [PATCH 1/2] Add a buildifier pre-commit hook Matches the one just landed in rules_apple: bazelbuild/rules_apple@61bc7c0 --- .bazelci/presubmit.yml | 1 + .pre-commit-config.yaml | 13 +++++++++++++ CONTRIBUTING.md | 13 +++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 .pre-commit-config.yaml 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..3532bc4e73 --- /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/config.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 From a31bb39502fca23c204823a614b4eda0dc04ac12 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Tue, 8 Jun 2021 15:51:06 -0700 Subject: [PATCH 2/2] Update .pre-commit-config.yaml Co-authored-by: Jonathon Belotti --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3532bc4e73..79f025d6c7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: hooks: - id: buildifier args: &args - # Keep this argument in sync with .bazelci/config.yaml + # Keep this argument in sync with .bazelci/presubmit.yaml - --warnings=all - id: buildifier-lint args: *args