Skip to content

Windows fixes for buildifier check, fix and test#89

Open
peakschris wants to merge 1 commit intokeith:mainfrom
peakschris:windows
Open

Windows fixes for buildifier check, fix and test#89
peakschris wants to merge 1 commit intokeith:mainfrom
peakschris:windows

Conversation

@peakschris
Copy link

@peakschris peakschris commented Jun 27, 2024

This PR includes fixes to support check, fix and test on Windows. Fixes #88

Tested with bazel 7.2.1 and both --noenable_runfiles and --enable_runfiles
All validations performed with --windows_enable_symlinks enabled

for buildifier.test to work, I used the following config. I could not get test to work without specifying workspace and no_sandbox.

buildifier_test(
    name = "buildifier.test",
    srcs = ["BUILD"],
    exclude_patterns = [
        "./.git/*",
    ],
    lint_mode = "warn",
    no_sandbox = True,
    workspace = "WORKSPACE",
)

@keith
Copy link
Owner

keith commented Jun 28, 2024

any way we can verify the previous failure on CI?

@peakschris
Copy link
Author

@keith @cgrindel I've merged #90 here. Please would you run this CI?

Expected results:
Windows: all tests pass
Linux: 1 test fails. 4 of 6 sub-tests pass. 2 fail as the linux path does not do manifest lookups.

How should we handle the linux failure? change the test to ignore that failure and raise an extra defect?

Thanks, Chris

@keith
Copy link
Owner

keith commented Jun 30, 2024

Started CI

@peakschris
Copy link
Author

@keith thank you. Results as expected. Would to like me to disable the two failing cases for non-windows?

@keith
Copy link
Owner

keith commented Jun 30, 2024

Looks like it failed on Linux but not windows? Maybe misunderstanding what you expected?

@peakschris
Copy link
Author

I added new cases within my new test for:

buildifier invoke (norunfiles) - passes windows & linux
buildifier check (norunfiles) - passes windows, fails linux
buildifier fix (norunfiles) - passes windows, fails linux
buildifier invoke (w/runfiles) - passes windows & linux
buildifier check (w/runfiles) - passes windows & linux
buildifier fix (w/runfiles) - passes windows & linux

The linux failures are demonstrating existing problems (or limitations), and are not addressed by this PR.

If you agree, I can I open a new defect and disable these two cases on linux for now. Most people won't hit these as no runfiles on linux is uncommon. I won't have time to work on these.

Cheers, Chris

@peakschris
Copy link
Author

I have opened #91 for the linux issue, updated the test cases.

@keith @cgrindel Please rerun CI, I'd expect all to pass now.

@cgrindel
Copy link
Collaborator

cgrindel commented Jul 1, 2024

I just approved CI.

@peakschris
Copy link
Author

@cgrindel could you rerun this one?

@peakschris
Copy link
Author

Awesome! Windows & Linux are clean... Mac seems to be waiting on a runner... What are next steps with this PR?

data = [
"//tests/unittest",
"@bazel_tools//tools/bash/runfiles",
"//:WORKSPACE",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why you are exporting the WORKSPACE and including it in this test? If it is to create a workspace for the test, it is better to create a new WORKSPACE that refers to the parent using local_repository.

Copy link
Author

@peakschris peakschris Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cgrindel sorry for the delay, if you look at runner.bat.template line 24, we need to find the absolute path to the workspace directory (it is available through envvar during bazel run, but not bazel test), and there is no good way in bat/bazel to do this other than looking at the target of a symlink. Exporting and depending on WORKSPACE gives us this symlink. Any other file in root folder of workspace would also be fine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you trying to find the root of a test workspace? I would expect a buildifier test to create a workspace, execute buildifier, and then verify the changes. I don't believe that any of that requires access to this repository's WORKSPACE file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildifier_test already has sandbox escape mechanism, implemented as the 'sandbox' and 'workspace' attributes to buildifier_test macro. This is documented here:

"no_sandbox": attr.bool(
, and is one of the things that this PR fixes on windows.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, I am not familiar enough with this use case. I will defer to @keith.

@rdesgroppes
Copy link

I was about to work on a fix but found out you already did it. May I ask what remains to be done here?

rdesgroppes added a commit to rdesgroppes/buildifier-prebuilt that referenced this pull request Sep 26, 2025
rdesgroppes added a commit to rdesgroppes/buildifier-prebuilt that referenced this pull request Sep 26, 2025
This applies Windows fixes proposed by:
keith#89
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Sep 29, 2025
Currently, `buildifier` targets don't work out of the box on Windows -
credits to Ofek for reporting.

Sadly, it turns out that two separate attempts have already been made to
remedy this:
1. In the upstream `bazelbuild/buildtools` (`go` source, but `workspace`
   suitable):
   bazelbuild/buildtools#1230 (merged)
2. `keith/buildifier-prebuilt` (`bzlmod` suitable, providing slightly
   outdated `go` binaries published by `bazelbuild/buildtools`):
   keith/buildifier-prebuilt#89 (well tested,
   but pending CI feedback... for months!)

Inspired by Tony's
[tips](https://datadoghq.atlassian.net/browse/ABLD-174?focusedCommentId=2644283),
the present change proposes the "least intrusive" change so that:
- we don't need to start a third effort (rules, `.bash` and `.bat`
  scripts),
- we benefit from the validated and merged upstream behavior,
- we don't depend on the goodwill of `keith/buildifier-prebuilt` to
  publish the version `8.2.1` of the binaries (nor subsequent versions),
- we don't have to manage a complex patch, but instead simply inhibit
  the upstream lines that we do not need, given `buildifier`
  implementations are provided by `multitool` again.

In short, this change combines the best of both worlds through a simple
indirection made possible by the configurability of upstream rules
which, unlike `keith/buildifier-prebuilt`, allow us to define which
implementation of `buildifier` to use.
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Sep 29, 2025
Currently, `buildifier` targets don't work out of the box on Windows -
credits to Ofek for reporting.

Sadly, it turns out that two separate attempts have already been made to
remedy this:
1. In the upstream `bazelbuild/buildtools` (`go` source, but `workspace`
   suitable):
   bazelbuild/buildtools#1230 (merged)
2. `keith/buildifier-prebuilt` (`bzlmod` suitable, providing slightly
   outdated `go` binaries published by `bazelbuild/buildtools`):
   keith/buildifier-prebuilt#89 (well tested,
   but pending CI feedback... for months!)

Inspired by Tony's
[tips](https://datadoghq.atlassian.net/browse/ABLD-174?focusedCommentId=2644283),
the present change proposes the "least intrusive" change so that:
- we don't need to start a third effort (rules, `.bash` and `.bat`
  scripts),
- we benefit from the validated and merged upstream behavior,
- we don't depend on the goodwill of `keith/buildifier-prebuilt` to
  publish the version `8.2.1` of the binaries (nor subsequent versions),
- we don't have to manage a complex patch, but instead simply inhibit
  the upstream lines that we do not need, given `buildifier`
  implementations are provided by `multitool` again.

In short, this change combines the best of both worlds through a simple
indirection made possible by the configurability of upstream rules
which, unlike `keith/buildifier-prebuilt`, allow us to define which
implementation of `buildifier` to use.
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Sep 29, 2025
### Motivation
Currently, `buildifier` targets don't work out of the box on Windows -
credits to @ofek for reporting.

Sadly, it turns out that two separate attempts have already been made to
remedy this:
1. In the upstream `bazelbuild/buildtools` (`go` source, but only
`workspace`-suitable):
bazelbuild/buildtools#1230 (merged)
2. `keith/buildifier-prebuilt` (`bzlmod`-suitable, and providing
-slightly outdated- `go` binaries published by `bazelbuild/buildtools`):
keith/buildifier-prebuilt#89 (well tested, but
pending CI feedback... for months!)

### What does this PR do?
Inspired by some of @aiuto's
[tips](https://datadoghq.atlassian.net/browse/ABLD-174?focusedCommentId=2644283):
> [1.b.] instead of pointing to the toolchain type defined in
buildifier_prebuilt, point to buildifier via multitools.
> [2.a.] revert prebuilt_buildtools.json to
5fd6373

The present change proposes the "least intrusive" change so that:
- we don't need to start a third effort (own rules, `.bash` and `.bat`
scripts),
- we benefit from the validated and merged upstream behavior,
- we don't depend on the goodwill of `keith/buildifier-prebuilt` to
publish the version `8.2.1` of the binaries (nor subsequent versions),
- we don't have to manage a complex patch, but instead simply inhibit
the upstream lines that we do not need, given `buildifier`
implementations are provided by `multitool` (again).

In short, this change combines the best of both worlds through a simple
indirection made possible by the configurability of upstream rules
which, unlike `keith/buildifier-prebuilt`, allow us to define which
implementation of `buildifier` to use.

### Describe how you validated your changes
I used another branch to verify this works under Windows as well:
https://github.com/DataDog/datadog-agent/blob/026042234ee811fd1641a2417893c08008860186/.gitlab/bazel/build-deps.yaml#L39
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Sep 30, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two disinct community efforts wrt runner
script templates, the present/upstream `bazelbuild/buildtools` and the
derived `keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts like for Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Sep 30, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Sep 30, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Sep 30, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Sep 30, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Oct 7, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Nov 6, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Nov 6, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Nov 6, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Nov 7, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
rdesgroppes added a commit to rdesgroppes/buildtools that referenced this pull request Nov 7, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- bazelbuild#1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
AnnaSvalova pushed a commit to bazelbuild/buildtools that referenced this pull request Nov 10, 2025
This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- #1230
- keith/buildifier-prebuilt#89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
@vadikmironov
Copy link

One point that might be missing is the handling of ++ characters in bzlmod case which I think would still be failing after this patch. Though given that this one goes on for 18 months+ it would be great to merge as is and then add ++ handling as a minor patch on top of this one as a separate issue (trivial powershell or some not so trivial workarounds without powershell). @keith , @cgrindel , would it be possible to re-trigger CI and if all great to merge this one?

@cgrindel
Copy link
Collaborator

I don't see an option to trigger CI again.

image

@keith
Copy link
Owner

keith commented Jan 22, 2026

rebased in order to get it to run again

@vadikmironov
Copy link

rebased in order to get it to run again

@keith, thanks a lot - this is now all green. Anything else left to do on this PR or is it ready to be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

buildifier test passes on failing build files

5 participants