If we agree on this, then we can convert this into PR at a click of a button.
Description
Buildifier (format + lint for BUILD, .bzl, and MODULE.bazel files) currently
runs as a standalone GitHub Actions workflow
(.github/workflows/buildifier.yaml) that downloads its own binary and
caches it independently. This should be migrated to the Bazel lint umbrella
(//:lint_test and //:fix_lint) for consistency with how TCL linting
already works.
Current state
The GitHub Actions workflow does two things:
# Format check
./buildifier -r -mode=check -lint=off .
# Lint check
./buildifier -r -lint=warn .
The tool version (v8.2.1) is pinned in the workflow YAML, not in Bazel's
dependency management. A .buildifier.json config already exists at the
repo root.
Problem
-
Cannot run locally — developers must push and wait for CI to discover
buildifier violations. This violates
POLA:
bazelisk run //:fix_lint should fix everything it can and report the
rest, but currently it knows nothing about BUILD files.
-
Version drift — the buildifier version is pinned in GitHub Actions
YAML, separate from Bazel's hermetic dependency management
(bazel/requirements.in, MODULE.bazel). It can drift out of sync
with what developers run locally (if they run it at all).
-
Inconsistent pattern — TCL linting already uses the Bazel lint
umbrella. Every additional language that stays outside the umbrella is
a special case that new contributors have to discover separately.
Proposed targets
Per the naming convention:
| Target |
What it does |
//:lint_bzl_test |
buildifier -r -mode=check -lint=warn . (read-only) |
//:fmt_bzl_test |
buildifier -r -mode=check -lint=off . (format only) |
//:tidy_bzl |
buildifier -r -mode=fix -lint=fix . (auto-fix) |
Wire into umbrellas:
- Add
lint_bzl_test and fmt_bzl_test to //:lint_test
- Add buildifier fix step to
bazel/fix_lint.sh
Suggested Solution
- Add buildifier as a Bazel-managed tool dependency (it's already available
as a @buildifier Bazel module)
- Create
bazel/bzl_lint_test.sh, bazel/bzl_fmt_test.sh, bazel/bzl_tidy.sh
following the same pattern as bazel/tcl_lint_test.sh etc.
- Add
sh_test / sh_binary targets in BUILD.bazel
- Wire into
//:lint_test and bazel/fix_lint.sh
- Once validated, retire
.github/workflows/buildifier.yaml
The .buildifier.json config (mode: fix, lint: fix, warnings: all)
already exists and can be reused by the new scripts.
Additional Context
- Bazel Lint Targets — umbrella framework and naming convention
- Shell Script Conventions — idiom for new wrapper scripts
.github/workflows/buildifier.yaml — current CI workflow to be retired
.buildifier.json — existing buildifier config
Suggested Solution
No response
Additional Context
No response
If we agree on this, then we can convert this into PR at a click of a button.
Description
Buildifier (format + lint for BUILD, .bzl, and MODULE.bazel files) currently
runs as a standalone GitHub Actions workflow
(
.github/workflows/buildifier.yaml) that downloads its own binary andcaches it independently. This should be migrated to the Bazel lint umbrella
(
//:lint_testand//:fix_lint) for consistency with how TCL lintingalready works.
Current state
The GitHub Actions workflow does two things:
The tool version (
v8.2.1) is pinned in the workflow YAML, not in Bazel'sdependency management. A
.buildifier.jsonconfig already exists at therepo root.
Problem
Cannot run locally — developers must push and wait for CI to discover
buildifier violations. This violates
POLA:
bazelisk run //:fix_lintshould fix everything it can and report therest, but currently it knows nothing about BUILD files.
Version drift — the buildifier version is pinned in GitHub Actions
YAML, separate from Bazel's hermetic dependency management
(
bazel/requirements.in,MODULE.bazel). It can drift out of syncwith what developers run locally (if they run it at all).
Inconsistent pattern — TCL linting already uses the Bazel lint
umbrella. Every additional language that stays outside the umbrella is
a special case that new contributors have to discover separately.
Proposed targets
Per the naming convention:
//:lint_bzl_testbuildifier -r -mode=check -lint=warn .(read-only)//:fmt_bzl_testbuildifier -r -mode=check -lint=off .(format only)//:tidy_bzlbuildifier -r -mode=fix -lint=fix .(auto-fix)Wire into umbrellas:
lint_bzl_testandfmt_bzl_testto//:lint_testbazel/fix_lint.shSuggested Solution
as a
@buildifierBazel module)bazel/bzl_lint_test.sh,bazel/bzl_fmt_test.sh,bazel/bzl_tidy.shfollowing the same pattern as
bazel/tcl_lint_test.shetc.sh_test/sh_binarytargets inBUILD.bazel//:lint_testandbazel/fix_lint.sh.github/workflows/buildifier.yamlThe
.buildifier.jsonconfig (mode: fix,lint: fix,warnings: all)already exists and can be reused by the new scripts.
Additional Context
.github/workflows/buildifier.yaml— current CI workflow to be retired.buildifier.json— existing buildifier configSuggested Solution
No response
Additional Context
No response