bazel: add tidy and check

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2023-03-13 18:33:31 +01:00
parent 9b3af5af76
commit 02c97fac03
12 changed files with 267 additions and 111 deletions

View file

@ -96,9 +96,7 @@ After updating a dependency, you will have to run `bazel run //:gazelle-update-r
Bazel is the primary build system for this project. It is used to build all Go code and will be used to build all artifacts in the future.
Still, we aim to keep the codebase compatible with `go build` and `go test` as well.
Whenever Go code is changed, you will have to run `bazel run //:gazelle` to regenerate the Bazel build files for Go code.
The CI will check if the Bazel build files are up to date with `bazel run //:gazelle-check`.
Optionally, you can use [autogazelle](https://github.com/bazelbuild/bazel-gazelle/tree/master/cmd/autogazelle) to regenerate the Bazel build files automatically on save. This is not tested and might not work properly.
Whenever Go code is changed, you will have to run `bazel run //:tidy` to regenerate the Bazel build files for Go code.
## Bazel commands
@ -111,11 +109,8 @@ Optionally, you can use [autogazelle](https://github.com/bazelbuild/bazel-gazell
* `bazel run --run_under="cd $PWD &&" //cli:cli_oss -- create -c 1 -w 1` - build + run a target with arguments in current working directory
* `bazel cquery --output=files //subfolder:target` - get location of a build artifact
* `bazel test //...` - run all tests
* `bazel run //:gazelle` - regenerate Bazel build files for Go code
* `bazel run //:gazelle-check` - check if Bazel build files for Go code are up to date
* `bazel run //:gazelle-update-repos` - update Bazel workspace with changes from `go.mod` and `go.sum` files
* `bazel run //:buildifier-fix` - format Bazel build files
* `bazel test //:buildifier-check` - lint Bazel build files
* `bazel run //:tidy` - tidy, format and generate
* `bazel run //:check` - execute checks and linters
## Editor integration