Skip to content

Commit 118c55d

Browse files
authored
chore: setup a buildifier pre-commit hook (#661)
Matches the one just landed in rules_apple: bazelbuild/rules_apple@61bc7c0
1 parent eb72705 commit 118c55d

File tree

4 files changed

+78
-51
lines changed

4 files changed

+78
-51
lines changed

.bazelci/config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,5 @@ tasks:
187187

188188
buildifier:
189189
version: latest
190+
# keep this argument in sync with .pre-commit-config.yaml
190191
warnings: "all"

.pre-commit-config.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# See CONTRIBUTING.md for instructions.
2+
# See https://pre-commit.com for more information
3+
# See https://pre-commit.com/hooks.html for more hooks
4+
repos:
5+
- repo: https://github.com/keith/pre-commit-buildifier
6+
rev: 4.0.1.1
7+
hooks:
8+
- id: buildifier
9+
args: &args
10+
# Keep this argument in sync with .bazelci/config.yaml
11+
- --warnings=all
12+
- id: buildifier-lint
13+
args: *args

CONTRIBUTING.md

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
We'd love to accept your patches and contributions to this project. There are
44
just a few small guidelines you need to follow.
55

6+
## Formatting
7+
8+
Starlark files should be formatted by buildifier.
9+
We suggest using a pre-commit hook to automate this.
10+
First [install pre-commit](https://pre-commit.com/#installation),
11+
then run
12+
13+
```shell
14+
pre-commit install
15+
```
16+
17+
Otherwise the Buildkite CI will yell at you about formatting/linting violations.
18+
619
## Contributor License Agreement
720

821
Contributions to this project must be accompanied by a Contributor License
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
1-
package(default_visibility = ['//visibility:public'])
1+
package(default_visibility = ["//visibility:public"])
22

33
filegroup(
4-
name = 'gcc',
5-
srcs = [
6-
'bin/arm-linux-gnueabihf-gcc',
7-
],
4+
name = "gcc",
5+
srcs = [
6+
"bin/arm-linux-gnueabihf-gcc",
7+
],
88
)
99

1010
filegroup(
11-
name = 'ar',
12-
srcs = [
13-
'bin/arm-linux-gnueabihf-ar',
14-
],
11+
name = "ar",
12+
srcs = [
13+
"bin/arm-linux-gnueabihf-ar",
14+
],
1515
)
1616

1717
filegroup(
18-
name = 'ld',
19-
srcs = [
20-
'bin/arm-linux-gnueabihf-ld',
21-
],
18+
name = "ld",
19+
srcs = [
20+
"bin/arm-linux-gnueabihf-ld",
21+
],
2222
)
2323

2424
filegroup(
25-
name = 'nm',
26-
srcs = [
27-
'bin/arm-linux-gnueabihf-nm',
28-
],
25+
name = "nm",
26+
srcs = [
27+
"bin/arm-linux-gnueabihf-nm",
28+
],
2929
)
3030

3131
filegroup(
32-
name = 'objcopy',
33-
srcs = [
34-
'bin/arm-linux-gnueabihf-objcopy',
35-
],
32+
name = "objcopy",
33+
srcs = [
34+
"bin/arm-linux-gnueabihf-objcopy",
35+
],
3636
)
3737

3838
filegroup(
39-
name = 'objdump',
40-
srcs = [
41-
'bin/arm-linux-gnueabihf-objdump',
42-
],
39+
name = "objdump",
40+
srcs = [
41+
"bin/arm-linux-gnueabihf-objdump",
42+
],
4343
)
4444

4545
filegroup(
46-
name = 'strip',
47-
srcs = [
48-
'bin/arm-linux-gnueabihf-strip',
49-
],
46+
name = "strip",
47+
srcs = [
48+
"bin/arm-linux-gnueabihf-strip",
49+
],
5050
)
5151

5252
filegroup(
53-
name = 'as',
54-
srcs = [
55-
'bin/arm-linux-gnueabihf-as',
56-
],
53+
name = "as",
54+
srcs = [
55+
"bin/arm-linux-gnueabihf-as",
56+
],
5757
)
5858

5959
filegroup(
60-
name = 'compiler_pieces',
61-
srcs = glob([
62-
'arm-linux-gnueabihf/**',
63-
'libexec/**',
64-
'lib/gcc/arm-linux-gnueabihf/**',
65-
'include/**',
66-
]),
60+
name = "compiler_pieces",
61+
srcs = glob([
62+
"arm-linux-gnueabihf/**",
63+
"libexec/**",
64+
"lib/gcc/arm-linux-gnueabihf/**",
65+
"include/**",
66+
]),
6767
)
6868

6969
filegroup(
70-
name = 'compiler_components',
71-
srcs = [
72-
':gcc',
73-
':ar',
74-
':ld',
75-
':nm',
76-
':objcopy',
77-
':objdump',
78-
':strip',
79-
':as',
80-
],
70+
name = "compiler_components",
71+
srcs = [
72+
":ar",
73+
":as",
74+
":gcc",
75+
":ld",
76+
":nm",
77+
":objcopy",
78+
":objdump",
79+
":strip",
80+
],
8181
)

0 commit comments

Comments
 (0)