chore: setup a buildifier pre-commit hook (#661)

Matches the one just landed in rules_apple: 61bc7c01ae
This commit is contained in:
Alex Eagle 2021-06-03 13:30:26 -07:00 committed by GitHub
parent eb72705d3d
commit 118c55d424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 51 deletions

View File

@ -187,4 +187,5 @@ tasks:
buildifier: buildifier:
version: latest version: latest
# keep this argument in sync with .pre-commit-config.yaml
warnings: "all" warnings: "all"

13
.pre-commit-config.yaml Normal file
View File

@ -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

View File

@ -3,6 +3,19 @@
We'd love to accept your patches and contributions to this project. There are We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow. 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 ## Contributor License Agreement
Contributions to this project must be accompanied by a Contributor License Contributions to this project must be accompanied by a Contributor License

View File

@ -1,81 +1,81 @@
package(default_visibility = ['//visibility:public']) package(default_visibility = ["//visibility:public"])
filegroup( filegroup(
name = 'gcc', name = "gcc",
srcs = [ srcs = [
'bin/arm-linux-gnueabihf-gcc', "bin/arm-linux-gnueabihf-gcc",
], ],
) )
filegroup( filegroup(
name = 'ar', name = "ar",
srcs = [ srcs = [
'bin/arm-linux-gnueabihf-ar', "bin/arm-linux-gnueabihf-ar",
], ],
) )
filegroup( filegroup(
name = 'ld', name = "ld",
srcs = [ srcs = [
'bin/arm-linux-gnueabihf-ld', "bin/arm-linux-gnueabihf-ld",
], ],
) )
filegroup( filegroup(
name = 'nm', name = "nm",
srcs = [ srcs = [
'bin/arm-linux-gnueabihf-nm', "bin/arm-linux-gnueabihf-nm",
], ],
) )
filegroup( filegroup(
name = 'objcopy', name = "objcopy",
srcs = [ srcs = [
'bin/arm-linux-gnueabihf-objcopy', "bin/arm-linux-gnueabihf-objcopy",
], ],
) )
filegroup( filegroup(
name = 'objdump', name = "objdump",
srcs = [ srcs = [
'bin/arm-linux-gnueabihf-objdump', "bin/arm-linux-gnueabihf-objdump",
], ],
) )
filegroup( filegroup(
name = 'strip', name = "strip",
srcs = [ srcs = [
'bin/arm-linux-gnueabihf-strip', "bin/arm-linux-gnueabihf-strip",
], ],
) )
filegroup( filegroup(
name = 'as', name = "as",
srcs = [ srcs = [
'bin/arm-linux-gnueabihf-as', "bin/arm-linux-gnueabihf-as",
], ],
) )
filegroup( filegroup(
name = 'compiler_pieces', name = "compiler_pieces",
srcs = glob([ srcs = glob([
'arm-linux-gnueabihf/**', "arm-linux-gnueabihf/**",
'libexec/**', "libexec/**",
'lib/gcc/arm-linux-gnueabihf/**', "lib/gcc/arm-linux-gnueabihf/**",
'include/**', "include/**",
]), ]),
) )
filegroup( filegroup(
name = 'compiler_components', name = "compiler_components",
srcs = [ srcs = [
':gcc', ":ar",
':ar', ":as",
':ld', ":gcc",
':nm', ":ld",
':objcopy', ":nm",
':objdump', ":objcopy",
':strip', ":objdump",
':as', ":strip",
], ],
) )