mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Bazel: introduce buildifier formatting
This introduces tooling and enforcement for formatting bazel files. The tooling is provided as a bazel run target from [keith/buildifier-prebuilt](https://github.com/keith/buildifier-prebuilt). This is used in a [`pre-commit`](https://pre-commit.com/) hook for those having that installed. In turn this is used in a CI check. Relying on a `pre-commit` action gives us easy checking that buildifying did not change anything in the files and printing the diff, without having to hand-roll the check ourselves. This enforcement will make usage of gazelle easier, as gazelle itself might reformat files, even outside of `go`. Having them properly formatted will allow gazelle to leave them unchanged, without needing to configure awkward exclude directives.
This commit is contained in:
26
.github/workflows/buildifier.yml
vendored
Normal file
26
.github/workflows/buildifier.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: Check bazel formatting
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- "**.bazel"
|
||||
- "**.bzl"
|
||||
branches:
|
||||
- main
|
||||
- "rc/*"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507
|
||||
with:
|
||||
extra_args: buildifier --all-files --show-diff-on-failure
|
||||
- if: failure()
|
||||
run: |
|
||||
echo "In order to format all files, please run:"
|
||||
echo " bazel run //:buildifier"
|
||||
Reference in New Issue
Block a user