bazel-contrib / rules_go

Go rules for Bazel
Apache License 2.0
1.39k stars 664 forks source link

Allow bazel test //... to run out-of-the-box #4150

Closed eljobe closed 1 month ago

eljobe commented 1 month ago

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

This PR fixes 3 issues which caused an invocation of bazel test //... in a clean checkout of the repository to fail depending on potential contributor's development environment.

  1. Contributors needed to know to run generate_imported_dylib.sh
  2. Contributors needed to have $JAVA_HOME set
  3. Contributors needed NOT to have go env GOTOOLCHAIN set

For 1, this PR wraps the generate_imported_dylib.sh in genrules so that the build will just automatically create the dynamic libraries appropriate for the platform.

For 2, the PR adds a --java_runtime_version=remotejdk_21 argument to the one test in lcov_coverage_test.go that needs to be able to build a Java rule.

For 3, the PR upgrades gazellle to version 0.39.1 and updates the excludes lists in the popular_repos.py file to handle the latest versions of those popular repos. This upgrade addresses the problem because https://github.com/bazel-contrib/bazel-gazelle/issues/1858 is fixed in that version of gazelle.

BONUS: Also, there were a few TODOs left in the WORKSPACE and .bazelrc files which were addressed by upgrading to the latest gazelle version. So, this PR cleans those up at the same time.

Which issues(s) does this PR fix?

Fixes #4149

Other notes for review

I have tested this on the following two machines:

macos (M3 arm64) linux (amd64)

In both cases, I can clone the repository into an fresh directory hop onto the build-fixes branch and run:

❯ bazel test -j 8 //...

And, it actually has all 452 tests passing within 30 minutes or so.

On both machines, go env GOTOOLCHAIN is go1.23.2 and $JAVA_HOME is not set on either machine.

sluongng commented 3 weeks ago

Amazing PR. Thanks so much 🙏