yoheimuta / go-protoparser

Yet another Go package which parses a Protocol Buffer file (proto2+proto3)
MIT License
166 stars 20 forks source link

Bazelify go-protoparser, and use it in CI tests #81

Open shaldengeki opened 5 months ago

shaldengeki commented 5 months ago

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 running bazel test //.... If you don't have bazel, recommend you install bazelisk, which will manage your bazel version for you: https://bazel.build/install/bazelisk

Roughly, this is the result of:

You 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

INFO: Elapsed time: 6.377s, Critical Path: 0.09s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
//interpret/unordered:unordered_test                            (cached) PASSED in 0.1s
//lexer:lexer_test                                              (cached) PASSED in 0.1s
//lexer/scanner:scanner_test                                    (cached) PASSED in 0.1s
//parser:parser_test                                            (cached) PASSED in 0.1s
//parser/meta:meta_test                                         (cached) PASSED in 0.1s
Executed 0 out of 5 tests: 5 tests pass.

(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.

ehrktia commented 4 months ago

@shaldengeki out of curiosity, I have the following queries