Skip to content

webview: add buildResult.BuildType to webview proto [ch4520] #2956

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

Merged
merged 8 commits into from
Feb 18, 2020

Conversation

maiamcc
Copy link
Contributor

@maiamcc maiamcc commented Feb 13, 2020

another WIP branch for you -- this one adds BuildResult.BuildTypes to the proto
so that you can access it from the tsx. It'll be a list of enums that you can
look thru to see if there's a LiveUpdate present

again, sorry for the mess, lack of tests, etc. 😬

@maiamcc maiamcc requested a review from hyu February 13, 2020 22:47
@maiamcc maiamcc changed the base branch from master to maiamcc/last-build-duration February 13, 2020 22:47
@@ -22,6 +22,15 @@ message BuildRecord {

// The span id for this build record's logs in the main logstore.
string span_id = 8;

enum BuildType {
Copy link
Member

Choose a reason for hiding this comment

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

i would probably make this a top-level type rather than nesting it in BuildRecord

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is now!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...wait, can you elaborate on why you want this to be top-level? Now that I'm making UpdateType and TargetType into their own enums, I'm running into some name collisions b/c they're both top-level.

Copy link
Member

Choose a reason for hiding this comment

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

This is a common question! The style guide has an answer! :)

https://developers.google.com/protocol-buffers/docs/style#enums

Prefer prefixing enum values instead of surrounding them in an enclosing message.

So it should be BUILD_TYPE_IMAGE

Copy link
Contributor Author

@maiamcc maiamcc Feb 18, 2020

Choose a reason for hiding this comment

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

🤔 yeah I saw that but once you generate the .pb file you get names like BuildType_BUILD_TYPE_IMAGE--but uh, if that's what the style guild says, I guess I'll go with it? (I thought that might be a guideline for like, the generated file as opposed to the .proto file? but, 🤷‍♀ )

Copy link
Member

Choose a reason for hiding this comment

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

ya, there's a long discussion on it here
golang/protobuf#513
(and follow-up issues), the reasons are pretty complex and nuanced

@@ -8,20 +8,31 @@ import "pkg/webview/log.proto";

option go_package = "github.com/windmilleng/tilt/pkg/webview";

enum BuildType {
IMAGE = 0;
Copy link
Member

Choose a reason for hiding this comment

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

in protobufs, the 0 enum value is special, and is generally used for some sort of natural zero value or unspecified value. See:
https://developers.google.com/protocol-buffers/docs/style#enums

because it indicates the case where the field wasn't populated. I would not expect IMAGE to be a zero value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good tip, ty!

@@ -93,6 +104,7 @@ message Resource {
LocalResourceInfo local_resource_info = 17;
string runtime_status = 18;
bool is_tiltfile = 19;
repeated BuildType target_types = 27;
Copy link
Member

Choose a reason for hiding this comment

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

hmmmmm...build types and target types are different enums in our Go data model. Treating them as the same here is going to lead to a lot of confusion.

Can we make this more closely match the Go data model? maybe something like:

repeated TargetSpec specs;

message TargetSpec {
  name string
  type string
  has_live_update bool
}

@maiamcc maiamcc force-pushed the maiamcc/webview-live-update-info branch from 41d7953 to b6f093f Compare February 17, 2020 18:47
@maiamcc maiamcc force-pushed the maiamcc/webview-live-update-info branch from b6f093f to b11c775 Compare February 18, 2020 17:26
@maiamcc maiamcc changed the base branch from maiamcc/last-build-duration to master February 18, 2020 17:28
@maiamcc maiamcc force-pushed the maiamcc/webview-live-update-info branch from 50b44f1 to f4992c4 Compare February 18, 2020 19:55
Copy link
Contributor Author

@maiamcc maiamcc left a comment

Choose a reason for hiding this comment

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

@nick this is ready for review

}

// Correspond to implementations of the TargetSpec interface
enum TargetType {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IDK what the most idiomatic way is to name these such that I avoid name conflicts (i can't have two enums in this package both named "image" e.g.). Or is the solution to have one (or both) of these types be nested? (I share your "ehh this should be top level" feeling but it's just a gut thing for me, idk your reasoning.)

}

func TestBuildHistory(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wanted test coverage for my change, but unsure if this is too finicky, thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

this is fine, tho it might be worthwhile to eventually invest in a kind of golden test around this

@maiamcc maiamcc requested a review from nicks February 18, 2020 20:01
}

func TestBuildHistory(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

this is fine, tho it might be worthwhile to eventually invest in a kind of golden test around this

@maiamcc maiamcc merged commit 856e169 into master Feb 18, 2020
@maiamcc maiamcc deleted the maiamcc/webview-live-update-info branch February 18, 2020 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants