-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Added Bazel support #599
Added Bazel support #599
Conversation
Would you be willing to edit |
Sure. I have Bazel setup for a couple projects of mine in Travis CI. |
To be a bit more explicit, could you add to the matrix something like |
runtime/internal/BUILD.bazel
Outdated
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
|
||
package(default_visibility = ["//visibility:public"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make the visibility of the package consistent with the one by go compiler?
i.e. it looks to be better to limit the default visibility to //runtime:__subpackages__
.
BTW, as the original author of Gazelle, I'm sorry -- it should have been done by gazelle. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are excused hehe. Thanks for the Gazelle, it saves tons of time daily for me.
I also made changes to other package visibilities as I saw fit.
"//examples/sub:sub_proto", | ||
"//examples/sub2:sub2_proto", | ||
"//protoc-gen-swagger/options:options_proto", | ||
"@com_github_googleapis_googleapis//google/api:api_proto", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yugui Any idea on how to have Gazelle to respect that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I have no idea. Let me merge this PR as it is once #599 (comment) gets ready.
ac35b66
to
3683241
Compare
@achew22 What do you think of the CI config? We don't need to test using Bazel 3 times. Not sure how to solve that... any ideas? |
cc3ac6d
to
7024322
Compare
I think you can use exclusions to achieve that https://docs.travis-ci.com/user/customizing-the-build#Excluding-Jobs |
It still makes sense to build with different versions of go in Bazel. But either is OK for me. LGTM except for the redundant 3 builds. |
@yugui We can do that in another PR. What if we merge the way it is right now and I focus on improving the CI build? |
I actually need to rebase and add changes merged to master. |
I think @yugui is saying that she would be happy with 3 builds if they built master, 1.10, and 1.9 in Bazel, please correct me if I am wrong. That is totally achievable, but it would require having a custom |
Enhanced default visibilities
ad99237
to
7581b7b
Compare
Update Travis CI 2
7581b7b
to
7dbea4a
Compare
@f0rmiga, thanks so much for your contribution! I look forward to adding more support for Bazel going forward 🎆 |
@achew22 You are very welcome. I look forward to contributing to more stuff! :) |
@f0rmiga Out of curiosity, do you have a theory on how to add swagger generation in Bazel? I'm a little hesitant to use the rules_go tooling around it. WDYT? |
@achew22 Honestly, I tried to integrate it. I think we would need to create a rule similar to |
Fortunately there are other projects who have implemented it in a less go specific way. For example, https://github.com/bazelbuild/rules_closure/blob/dbb96841cc0a5fb2664c37822803b06dab20c7d1/closure/protobuf/closure_proto_library.bzl |
Nice! Good stuff. |
Sorry for the size of the PR. I would be up for a peer review if wanted.
Almost every target was generated by Gazelle.
Gazelle tried to index
//google/api/...
because of the third party protos being used. To solve that I excluded thethird_party
directory from Gazelle and created therepositories.bzl
that at this point:- Downloads the
googleapis
repository.- Adds a
BUILD.bazel
file under//google/api/
with targets for the protos.Gazelle still tries to remove
"@com_github_googleapis_googleapis//google/api:api_proto"
and"@com_github_googleapis_googleapis//google/api:go_default_library"
in favour of//google/api/...
, which is wrong.To check what Gazelle reports in check mode, run
bazel run //:gazelle_diff
.The
third_party
directory is not being used by any Bazel target at all. If the grpc-gateway team decides to move completely to Bazel, this directory can be removed.Every
.pb.go
and.pb.gw.go
can also be removed if this repo moves completely to Bazel. In order to have the swagger generator to work with Bazel, I would need to write a specific rule for that.To compile everything:
To test everything: