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

Update rules_go and gazelle #802

Merged
merged 4 commits into from
Nov 13, 2018
Merged

Conversation

drigz
Copy link
Contributor

@drigz drigz commented Nov 9, 2018

This requires/allows the following changes:

Also, enforce up-to-date build files in the CI check.

This requires/allows the following changes:
- rerun Gazelle to regenerate the build files
- fix marshal_jsonpb_test to assert correct behavior when
  EnumsAsInts == false
- remove `repositories.bzl` (replaced by @go_googleapis)

Also, enforce up-to-date build files in the CI check.

Note: this version of the commit includes an out-of-date BUILD file to
test the CI check.
@johanbrandhorst
Copy link
Collaborator

What's next to do here? I've lost sight a bit. Do you need anything from us?

@drigz
Copy link
Contributor Author

drigz commented Nov 12, 2018

TBH I'm hoping someone who understands this "enums inside maps" issue will appear and tell me what to do. I don't want to change the behavior of grpc-gateway without understanding the consequences.

Alternatively, we may be able to keep the old behavior by setting EnumsAsInts appropriately for marshalling and unmarshalling. However, I don't have a lot of time to spend on this, as this is "just" a cleanup task on my side.

@johanbrandhorst
Copy link
Collaborator

If the behavior has been incorrect I think we can safely correct it without worrying about backwards compatibility. Is that simply a matter of copying the fix from the protobuf repo?

@drigz
Copy link
Contributor Author

drigz commented Nov 12, 2018

I wasn't able to easily fix node_test, as changing ints to strings introduced another error. Additionally, I need to regenerate the examples, which I haven't worked out how to do yet.

@johanbrandhorst
Copy link
Collaborator

Regenerating everything should be covered in https://github.com/grpc-ecosystem/grpc-gateway/blob/master/CONTRIBUTING.md#i-want-to-regenerate-the-files-after-making-changes.

If fixing the tests is a pain, lets raise an issue and solve it in a separate PR. Is it necessarily part of this cleanup? Don't want to waste your time with red tape.

The generated code changed with the updated dependencies.
@johanbrandhorst
Copy link
Collaborator

Right I see what happened, we updated our dependency of golang/protobuf, and all of a sudden incorrect behaviour that we depended on was fixed, and now our tests fail. It seems we have to fix it in this PR then. I'm not too familiar with this code unfortunately, so I think we just have to do a little digging to get to the bottom of it. Changing the test is correct, so any part of our json marshaller that is doing the wrong thing is what needs to be fixed now.

Is that a correct summary?

@johanbrandhorst
Copy link
Collaborator

Node tests are failing with:

Expected $.map_value.a = 'ONE' to equal 1.

I wonder if it's just a matter of fixing these tests too?

Enum values inside maps are now supported.
@johanbrandhorst
Copy link
Collaborator

🤞

@johanbrandhorst
Copy link
Collaborator

This has become bigger than initially anticipated I think, but lets wait for @achew22 to have a chance to review it as well before merging. Huge thanks for getting the ball rolling on this though @drigz :).

@johanbrandhorst
Copy link
Collaborator

Node tests are looking good!

@codecov-io
Copy link

Codecov Report

Merging #802 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #802   +/-   ##
=======================================
  Coverage   53.27%   53.27%           
=======================================
  Files          30       30           
  Lines        3369     3369           
=======================================
  Hits         1795     1795           
  Misses       1399     1399           
  Partials      175      175

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ff87af...f6ea87e. Read the comment docs.

@drigz
Copy link
Contributor Author

drigz commented Nov 12, 2018

Yep, looks like I gave up too quickly. Thanks for the encouragement :)


gazelle_dependencies()

load("@bazel_gazelle//:def.bzl", "go_repository")
load("//:repositories.bzl", "repositories")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not objecting, just trying to learn: Why remove repositories.bzl? Wouldn't it be better to allow third parties to import a repositories.bzl and transitively depend?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repository defined by repositories.bzl is obsolete, having been replaced by @go_googleapis (created by go_rules_dependencies()). Since repositories.bzl is unable to call go_rules_dependencies() (bazelbuild/bazel#1550) there's nothing left for it to do.

@@ -21,12 +29,10 @@ http_archive(
url = "https://github.com/bazelbuild/buildtools/archive/e90e7cc6ef3e6d08d4ca8a982935c3eed638e058.tar.gz",
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

gazelle_dependencies()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nob objecting, just trying to learn: Maybe I'm not tracking developments in Bazel world closely enough, but if gazelle_dependencies() is no longer imported, where is this defined? Why does this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gazelle_dependencies is still loaded from bazel_gazelle//:deps.bzl, along with go_repository. The only change here is that two load() statements have been consolidated into one.

@achew22
Copy link
Collaborator

achew22 commented Nov 13, 2018

This has become bigger than initially anticipated I think, but lets wait for @achew22 to have a chance to review it as well before merging. Huge thanks for getting the ball rolling on this though @drigz :).

I think we should merge this as is. It will probably break people but upstream changed on us and we don't have much of an option. If this behavior is required by integrators there is a parameter they can set.

@achew22 achew22 merged commit a7c0cd0 into grpc-ecosystem:master Nov 13, 2018
@drigz drigz mentioned this pull request Nov 19, 2018
# https://github.com/bazelbuild/rules_go/blob/436452edc29a2f1e0edc22d180fbb57c27e6d0af/go/private/repositories.bzl#L75
version = "1.1.0"
# https://github.com/bazelbuild/rules_go/blob/109c520465fcb418f2c4be967f3744d959ad66d3/go/private/repositories.bzl#L52
revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
Copy link

@javasgl javasgl Dec 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

master: Could not introduce github.com/grpc-ecosystem/grpc-gateway@master, as it has a dependency on github.com/golang/protobuf with constraint aa810b61a9c79d51363740d207bb46cf8e620ed5, which has no overlap with existing constraint master from github.com/grpc-ecosystem/go-grpc-middleware@master
@achew22 @drigz

broken!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a go dep but I don't think this change introduced the problem, as even before the version was constrained and would have conflicted with go-grpc-middleware's constraint. @javasgl Maybe you need to use an override to resolve the difference?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I've explained the situation in #829

adasari pushed a commit to adasari/grpc-gateway that referenced this pull request Apr 9, 2020
* Update rules_go and gazelle

This requires/allows the following changes:
- rerun Gazelle to regenerate the build files
- fix marshal_jsonpb_test to assert correct behavior when
  EnumsAsInts == false
- remove `repositories.bzl` (replaced by @go_googleapis)

Also, enforce up-to-date build files in the CI check.

Note: this version of the commit includes an out-of-date BUILD file to
test the CI check.

* Update Gopkg.toml and Gopkg.lock

* Update generated proto code

The generated code changed with the updated dependencies.

* Fix node_test

Enum values inside maps are now supported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants