Open shaldengeki opened 5 months ago
@shaldengeki out of curiosity, I have the following queries
go run
, go build
and go test
both in CI and in local env to achieve the same?go test
flags to achieve the same?
Am new to Bazel i.e. - have used it commercially for a year or so not more.
The above queries are based on my understanding of Bazel.
This is a quick first pass at using Bazel in
go-protoparser
. This makes the CI tests run via Bazel. You can do the same on your machine, by runningbazel test //...
. If you don't have bazel, recommend you install bazelisk, which will manage your bazel version for you: https://bazel.build/install/bazeliskRoughly, this is the result of:
WORKSPACE
and rootBUILD.bazel
file, with go rules andgazelle
in itgazelle
against the repo:bazel run //:gazelle
, to generateBUILD.bazel
files for every package_example/dump/main.go
to read_testdata/simple.proto
as a default argument at runtimebazel
commands where possibleYou can see the benefits of the caching in CI, if you rerun the builds -- you'll see that Bazel correctly doesn't re-run the tests again, and the build finishes very quickly: https://github.com/shaldengeki/go-protoparser/actions/runs/7945280017/job/21691752664
(Or you can run
bazel test //...
locally twice, and observe that the second run finishes ~instantly.)I left the linting commands & job un-Bazelified. I think this'll take some more work -- basically, some of the linting packages take some work to bazelify, and doing it only partway will make the lint CI job slow (~40s).
Let me know what you think! I'm happy to keep plugging away at the lints if you'd rather do this in one fell swoop.