Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make # gazelle:proto file work without needing to set different option go_package in .proto files #1765

Merged
merged 18 commits into from
May 20, 2024

Conversation

jeromep-stripe
Copy link
Contributor

@jeromep-stripe jeromep-stripe commented Mar 25, 2024

What type of PR is this?
Feature

What package or component does this PR mostly affect?
language/go

What does this PR do? Why is it needed?
This changes the gazelle's go_proto_library generation behavior.
Previously, in .proto file mode, gazelle would generate a separate go_proto_library target for each proto_library target, and these would have the same values for the importpath attribute. This caused build errors in certain situations.

This change makes Gazelle group proto_library targets which would otherwise have the same go_proto_library importpath, into a single go_proto_library using the protos attribute.

Which issues(s) does this PR fix?

Fixes #1724

Other notes for review

  • While testing this PR, I ran bazelisk test //... and saw two tests fail
FAIL: //cmd/gazelle:gazelle_test (see /private/var/tmp/_bazel/7faad61fac7f6d421e59e31d0146c79e/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/cmd/gazelle/gazelle_test/test.log)
INFO: From Testing //cmd/gazelle:gazelle_test:
==================== Test output for //cmd/gazelle:gazelle_test:
could not locate go tool
================================================================================
FAIL: //internal:bazel_test (see /private/var/tmp/_bazel/7faad61fac7f6d421e59e31d0146c79e/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/internal/bazel_test/test.log)
INFO: From Testing //internal:bazel_test:
==================== Test output for //internal:bazel_test:
error: unknown runfile: ./.bazelrc
================================================================================

This looks like an environment issue. Looks like CI is green though, so I think we can ignore this.

  • When generating a single go_proto_library target for multiple proto_library targets, the change creates a combinedImports platformStringsBuilder variable. I'm not sure if my general approach to combining the dependencies is correct, and would appreciate guidance.

@jeromep-stripe jeromep-stripe marked this pull request as ready for review March 25, 2024 12:15
@ouguoc2-stripe
Copy link

@linzhp FYI -- let @jeromep-stripe know what you think.

@ouguoc2-stripe
Copy link

Ping on this @linzhp -- let us know what we can do to help.

@linzhp
Copy link
Contributor

linzhp commented Apr 29, 2024

Oh, sorry, I missed the previous ping. Let me take a look later this week.

@ouguoc2-stripe
Copy link

(Gentle nudge on this; hope you have a good weekend, happy to discuss if you'd like.)

language/go/config.go Outdated Show resolved Hide resolved
language/go/generate.go Outdated Show resolved Hide resolved
language/go/generate.go Outdated Show resolved Hide resolved
language/go/generate.go Outdated Show resolved Hide resolved
@linzhp
Copy link
Contributor

linzhp commented May 5, 2024

Some minor comments. LGTM overall. I also tested it in Uber's Go repo.

@jeromep-stripe
Copy link
Contributor Author

@linzhp ty for the review, I addressed your comments!

language/go/config.go Outdated Show resolved Hide resolved
@linzhp linzhp enabled auto-merge (squash) May 18, 2024 23:37
@linzhp linzhp merged commit 6a27127 into bazelbuild:master May 20, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants