Skip to content

Commit c7d8b15

Browse files
authored
Add buildifier hook (#3529)
Replace the buildifier CI call with the pre-commit hook. Now developers can run exactly the same formatting and linting as we use in CI
1 parent 8c153c9 commit c7d8b15

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

.github/workflows/formatting.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17-
- name: Buildifier
18-
run: |
19-
wget "https://github.com/bazelbuild/buildtools/releases/download/v${BUILDIFIER_VERSION}/buildifier-linux-amd64" -O buildifier
20-
chmod +x ./buildifier
21-
./buildifier -lint=warn -mode=check -warnings=all -r ${{ github.workspace }}
22-
rm ./buildifier
23-
env:
24-
BUILDIFIER_VERSION: 8.2.0
2517
- uses: actionsx/prettier@v2
2618
with:
2719
args: --config "${{ github.workspace }}/.prettierrc.toml" --write "**/*.{js,mjs,cjs,jsx,ts,tsx}"

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ repos:
44
hooks:
55
- id: check-hooks-apply
66
- id: check-useless-excludes
7+
- repo: https://github.com/Warchant/pre-commit-buildifier
8+
rev: 0.1.5
9+
hooks:
10+
- id: buildifier
11+
args: [--version, "v8.2.0"]
12+
- id: buildifier-lint
13+
args: [--version, "v8.2.0", --warnings=all]
714
- repo: https://github.com/crate-ci/typos
815
rev: v1.33.1
916
hooks:

examples/all_deps_vendor/WORKSPACE.bzlmod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# https://bazel.build/external/migration#hybrid-mode
55
###############################################################################
66
# rule http_archive
7-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
8-
7+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load
98
load("//:sys_deps.bzl", "sys_deps")
10-
sys_deps()
9+
10+
sys_deps()

examples/ffi/WORKSPACE.bzlmod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1010
# https://github.com/bazelbuild/rules_cc/releases
1111
http_archive(
1212
name = "rules_cc",
13-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.10-rc1/rules_cc-0.0.10-rc1.tar.gz"],
1413
sha256 = "d75a040c32954da0d308d3f2ea2ba735490f49b3a7aa3e4b40259ca4b814f825",
15-
)
14+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.10-rc1/rules_cc-0.0.10-rc1.tar.gz"],
15+
)

0 commit comments

Comments
 (0)