From 118c55d42418c63212ccc89fdd97460d2949b58f Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Thu, 3 Jun 2021 13:30:26 -0700 Subject: [PATCH] chore: setup a buildifier pre-commit hook (#661) Matches the one just landed in rules_apple: https://github.com/bazelbuild/rules_apple/commit/61bc7c01aeee1324dc276e4f09bba88913ab2a62 --- .bazelci/config.yaml | 1 + .pre-commit-config.yaml | 13 +++ CONTRIBUTING.md | 13 +++ .../compilers/linaro_linux_gcc_5.3.1.BUILD | 102 +++++++++--------- 4 files changed, 78 insertions(+), 51 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.bazelci/config.yaml b/.bazelci/config.yaml index 16464f6..1340336 100644 --- a/.bazelci/config.yaml +++ b/.bazelci/config.yaml @@ -187,4 +187,5 @@ tasks: buildifier: version: latest + # keep this argument in sync with .pre-commit-config.yaml warnings: "all" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3532bc4 --- /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 bb70059..2e91145 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 diff --git a/examples/cmake_crosstool/compilers/linaro_linux_gcc_5.3.1.BUILD b/examples/cmake_crosstool/compilers/linaro_linux_gcc_5.3.1.BUILD index b231d01..db2e9bb 100644 --- a/examples/cmake_crosstool/compilers/linaro_linux_gcc_5.3.1.BUILD +++ b/examples/cmake_crosstool/compilers/linaro_linux_gcc_5.3.1.BUILD @@ -1,81 +1,81 @@ -package(default_visibility = ['//visibility:public']) +package(default_visibility = ["//visibility:public"]) filegroup( - name = 'gcc', - srcs = [ - 'bin/arm-linux-gnueabihf-gcc', - ], + name = "gcc", + srcs = [ + "bin/arm-linux-gnueabihf-gcc", + ], ) filegroup( - name = 'ar', - srcs = [ - 'bin/arm-linux-gnueabihf-ar', - ], + name = "ar", + srcs = [ + "bin/arm-linux-gnueabihf-ar", + ], ) filegroup( - name = 'ld', - srcs = [ - 'bin/arm-linux-gnueabihf-ld', - ], + name = "ld", + srcs = [ + "bin/arm-linux-gnueabihf-ld", + ], ) filegroup( - name = 'nm', - srcs = [ - 'bin/arm-linux-gnueabihf-nm', - ], + name = "nm", + srcs = [ + "bin/arm-linux-gnueabihf-nm", + ], ) filegroup( - name = 'objcopy', - srcs = [ - 'bin/arm-linux-gnueabihf-objcopy', - ], + name = "objcopy", + srcs = [ + "bin/arm-linux-gnueabihf-objcopy", + ], ) filegroup( - name = 'objdump', - srcs = [ - 'bin/arm-linux-gnueabihf-objdump', - ], + name = "objdump", + srcs = [ + "bin/arm-linux-gnueabihf-objdump", + ], ) filegroup( - name = 'strip', - srcs = [ - 'bin/arm-linux-gnueabihf-strip', - ], + name = "strip", + srcs = [ + "bin/arm-linux-gnueabihf-strip", + ], ) filegroup( - name = 'as', - srcs = [ - 'bin/arm-linux-gnueabihf-as', - ], + name = "as", + srcs = [ + "bin/arm-linux-gnueabihf-as", + ], ) filegroup( - name = 'compiler_pieces', - srcs = glob([ - 'arm-linux-gnueabihf/**', - 'libexec/**', - 'lib/gcc/arm-linux-gnueabihf/**', - 'include/**', - ]), + name = "compiler_pieces", + srcs = glob([ + "arm-linux-gnueabihf/**", + "libexec/**", + "lib/gcc/arm-linux-gnueabihf/**", + "include/**", + ]), ) filegroup( - name = 'compiler_components', - srcs = [ - ':gcc', - ':ar', - ':ld', - ':nm', - ':objcopy', - ':objdump', - ':strip', - ':as', - ], + name = "compiler_components", + srcs = [ + ":ar", + ":as", + ":gcc", + ":ld", + ":nm", + ":objcopy", + ":objdump", + ":strip", + ], )