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

Improves calculateTypes: adds returnTypes, recurses into map value ty… #3286

Merged
merged 5 commits into from
Jun 20, 2024

Conversation

brunofrts
Copy link
Collaborator

…pes and generate Kotlin test classes through Wire.

This PR

  1. Introduces returnTypes (similar to responseTypes) in WebActionMetadata. This is useful when the return of a web action is not wrapped (e.g., in a Response).
  2. Removes the hardcoded Kotlin Wire compiled test classes in misk-admin and instead generates them with Gradle as needed. To do this, we duplicate the .proto definitions using different package names so that Wire can process both with different outputs.
  3. Implements Map handling in calculateTypes similarly to how we parse Lists.

…pes and generate Kotlin test classes through Wire.
@brunofrts brunofrts marked this pull request as draft June 5, 2024 22:41
@brunofrts brunofrts requested a review from adrw June 7, 2024 17:58
@brunofrts brunofrts marked this pull request as ready for review June 7, 2024 17:58
@@ -50,6 +54,10 @@ internal class MiskWebFormBuilderTest {
)
)

// Check map value types
Copy link
Collaborator

@alvinsee alvinsee Jun 7, 2024

Choose a reason for hiding this comment

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

this isnt really testing the map type right? SHould we assert on the pretty print Map<K,V> .... like the enum example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So we are calculating the types from Shipment (L27), this assertion tests that we recursed into Warehouse, and then into the map value type (Robot from map<int32, Robot> robots = 7;), correctly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If your point is we didn't check annotations/type on this robots field itself (i.e., as a type inside Warehouse), that is correct. I will add it now for thoroughness.

@brunofrts
Copy link
Collaborator Author

This PR is temporarily blocked (due to item 2 in description) by the unexpected Wire behavior described in this Slack thread.

Copy link
Collaborator

@adrw adrw left a comment

Choose a reason for hiding this comment

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

LG

@@ -50,6 +54,13 @@ internal class MiskWebFormBuilderTest {
)
)

// Check map value types are included
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add assertions that the key type (in this case int32) is also present in the calculated types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do to this I think we would need to change handleField a bit, so I will merge as is and we can work on it in a separate PR.

@oldergod
Copy link
Collaborator

I wrote a fixes #<this PR> in the related Wire PR and this closed this issue.... Sorry about it.

@oldergod oldergod reopened this Jun 15, 2024
* refs/heads/master:
  Move `develocity` block after `plugins` (#3321)
  chore: upgrade dependencies to close security vulnerabilities (#3323)
  Deprecate Config tab in admin dashboard menu (#3322)
  Add description to Metadata class, Add AlertMessage, CodeBlock, ToggleContainer components (#3316)
  Fix Metadata tab overflow scrolling (#3315)
  Add contract to requireRequest (#3318)
  Delete misk-events-testing which has been replaced by misk-events test fixtures (#3317)
  Add id to Metadata tab h1 (#3314)
  Allow dashboard menu links with query parameters (#3313)
  Refactor JvmMetadataAction into Metadata plugin (#3305)
  Fix ConfigMetadata prettyPrint to match Config tab (#3311)
  Make metadata classes internal (#3310)
  Add metadata for cron jobs (#3309)
  Add metadata example to exemplar, make backwards compat (#3306)
  Make AllMetadataAction filterable (#3303)

# Conflicts:
#	misk-admin/src/test/kotlin/misk/web/metadata/all/AllMetadataActionTest.kt
@brunofrts
Copy link
Collaborator Author

brunofrts commented Jun 20, 2024

Tested with Wire-5.0.0-alpha03 locally and working as expected. Merging.

@brunofrts brunofrts merged commit c69fc44 into master Jun 20, 2024
11 checks passed
@brunofrts brunofrts deleted the brunof/improvetypes branch June 20, 2024 20:27
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.

None yet

4 participants