Skip to content

Catch more file patterns - #1463

Merged
vladmos merged 2 commits into
bazel-contrib:mainfrom
keith:ks/catch-more-file-patterns
May 28, 2026
Merged

vladmos merged 2 commits into
bazel-contrib:mainfrom
keith:ks/catch-more-file-patterns

Conversation

@keith

@keith keith commented Apr 14, 2026

Copy link
Copy Markdown
Member

Previously buildifier -r . would not pick up foo.BUILD.bazel files
or foo.BUILD files even though the runner.bash.template would. This
attempts to unify these.

@keith
keith requested a review from a team as a code owner April 14, 2026 20:50
@keith
keith requested review from vladmos and removed request for a team April 14, 2026 20:50

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request unifies the identification of Starlark files by updating patterns in the bash runner and the Go utility. The changes simplify extension matching and add support for WORKSPACE.bzlmod. A review comment points out inconsistencies between the two implementations, specifically missing patterns in the bash template for *.star, WORKSPACE.bzlmod, and BUILD.oss.

Comment thread buildifier/runner.bash.template Resolved
Previously `buildifier -r .` would not pick up `foo.BUILD.bazel` files
or `foo.BUILD` files even though the `runner.bash.template` would. This
attempts to unify these.
@keith
keith force-pushed the ks/catch-more-file-patterns branch from 3eae3b4 to 4a9d78a Compare April 14, 2026 20:53
@keith

keith commented May 27, 2026

Copy link
Copy Markdown
Member Author

@vladmos ptal

@vladmos vladmos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@vladmos
vladmos merged commit 84fa6c3 into bazel-contrib:main May 28, 2026
1 check passed
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Sep 29, 2026
### What does this PR do?
Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer`
and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to
`v10.1.0` (now `bazel-contrib/buildtools`) in:
- `bazel/prebuilt_buildtools.json`,
- the corresponding `http_archive` in `MODULE.bazel` (invocation helpers).

Add a `go_shim` target to `buildozer` so the bumped binary is directly
runnable via `bazel run //:buildozer -- ...`.

Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against
`v10.1.0`, which allows us to drop a patch whose purpose is now subsumed
by upstream's own generalized `*.bazel` glob in `runner.bash.template`
(bazel-contrib/buildtools#1463).

Apply `bazel run //bazel/buildifier`'s resulting formatting fixes across
matched files.

### Motivation
Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so
newer `buildozer` capabilities were unavailable, which surfaced while
working on #56440: an `invoke` task needs to update a dict-of-lists
attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]).

At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that
shape: `dict_set` only accepts a scalar value, and `dict_list_add`
silently sorts the list it builds, which would swap `filename` and
`sha256` whereas `rules_go` unpacks that pair **positionally**.

The fix, a `set attr:expr <literal>` command, landed in
bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move
past it.

### Describe how you validated your changes
`bazel run //bazel/buildifier` works on both Linux **and Windows**.

### Additional Notes
`module-docstring` is suppressed in `.buildifier.json` for unrelated,
pre-existing reasons predating this PR.

[ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Sep 29, 2026
### What does this PR do?
Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer`
and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to
`v10.1.0` (now `bazel-contrib/buildtools`) in:
- `bazel/prebuilt_buildtools.json`,
- the corresponding `http_archive` in `MODULE.bazel` (invocation helpers).

Add a `go_shim` target to `buildozer` so the bumped binary is directly
runnable via `bazel run //:buildozer -- ...`.

Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against
`v10.1.0`, which allows us to drop a patch whose purpose is now subsumed
by upstream's own generalized `*.bazel` glob in `runner.bash.template`
(bazel-contrib/buildtools#1463).

Apply `bazel run //bazel/buildifier`'s resulting formatting fixes across
matched files.

### Motivation
Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so
newer `buildozer` capabilities were unavailable, which surfaced while
working on #56440: an `invoke` task needs to update a dict-of-lists
attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]).

At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that
shape: `dict_set` only accepts a scalar value, and `dict_list_add`
silently sorts the list it builds, which would swap `filename` and
`sha256` whereas `rules_go` unpacks that pair **positionally**.

The fix, a `set attr:expr <literal>` command, landed in
bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move
past it.

### Describe how you validated your changes
`bazel run //bazel/buildifier` works on both Linux **and Windows**.

### Additional Notes
`module-docstring` is suppressed in `.buildifier.json` for unrelated,
pre-existing reasons predating this PR.

[ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Sep 29, 2026
### What does this PR do?
Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer`
and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to
`v10.1.0` (now `bazel-contrib/buildtools`) in:
- `bazel/prebuilt_buildtools.json`,
- the corresponding `http_archive` in `MODULE.bazel` (invocation helpers).

Add a `go_shim` target to `buildozer` so the bumped binary is directly
runnable via `bazel run //:buildozer -- ...`.

Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against
`v10.1.0`, which allows us to drop a patch whose purpose is now subsumed
by upstream's own generalized `*.bazel` glob in `runner.bash.template`
(bazel-contrib/buildtools#1463).

Apply `bazel run //bazel/buildifier`'s resulting formatting fixes across
matched files.

### Motivation
Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so
newer `buildozer` capabilities were unavailable, which surfaced while
working on #56440: an `invoke` task needs to update a dict-of-lists
attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]).

At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that
shape: `dict_set` only accepts a scalar value, and `dict_list_add`
silently sorts the list it builds, which would swap `filename` and
`sha256` whereas `rules_go` unpacks that pair **positionally**.

The fix, a `set attr:expr <literal>` command, landed in
bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move
past it.

### Describe how you validated your changes
`bazel run //bazel/buildifier` works on both Linux **and Windows**.

### Additional Notes
`module-docstring` is suppressed in `.buildifier.json` for unrelated,
pre-existing reasons predating this PR.

[ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/datadog-agent that referenced this pull request Sep 29, 2026
…57078)

### What does this PR do?
Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer` and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to `v10.1.0` (now `bazel-contrib/buildtools`) in:
- `bazel/prebuilt_buildtools.json`,
- the corresponding `http_archive` in `MODULE.bazel` (invocation helpers).

Add a `go_shim` target to `buildozer` so the bumped binary is directly runnable via `bazel run //:buildozer -- ...`.

Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against `v10.1.0`, which allows us to drop a patch whose purpose is now subsumed by upstream's own generalized `*.bazel` glob in `runner.bash.template` (bazel-contrib/buildtools#1463).

### Motivation
Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so newer `buildozer` capabilities were unavailable, which surfaced while working on #56440: an `invoke` task needs to update a dict-of-lists attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]).

At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that shape: `dict_set` only accepts a scalar value, and `dict_list_add` silently sorts the list it builds, which would swap `filename` and `sha256` whereas `rules_go` unpacks that pair **positionally**.

The fix, a `set attr:expr <literal>` command, landed in bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move past it.

### Describe how you validated your changes
`bazel run //bazel/buildifier` works on both Linux **and Windows**.

### Additional Notes
This change was too large, leading to the extraction of following prerequisites:
- #57087
- #57088
- #57090

[ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

Co-authored-by: regis.desgroppes <[email protected]>
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.

2 participants