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 test case for empty dir hash in gen dir #1024

Merged
merged 4 commits into from
Jan 24, 2024
Merged

Conversation

mfridman
Copy link
Member

@mfridman mfridman commented Jan 24, 2024

This PR adds a defensive check in our plugin tests to avoid passing plugins that generate no code and produce an "empty dir" hash.

There is a historical allowlist of plugins we'll allow, but moving forward we should craft protos to exercise valid code generation, in a similar way as:

https://github.com/bufbuild/plugins/blob/d524f5ffe0e922ac10752db571b60a320f7fc7f4/tests/plugins_test.go#L133-L13

For context, this would help catch #1017 against the typical images we pass in testing.

--- FAIL: TestGeneration (0.42s)
--- FAIL: TestGeneration/plugins/community/mercari-grpc-federation/v0.9.2 (0.00s)
--- FAIL: TestGeneration/plugins/community/mercari-grpc-federation/v0.9.2/eliza (0.83s)
plugins_test.go:99: generated code directory is empty for buf.build/community/mercari-grpc-federation:v0.9.2
--- FAIL: TestGeneration/plugins/community/mercari-grpc-federation/v0.9.2/petapis (0.84s)
plugins_test.go:99: generated code directory is empty for buf.build/community/mercari-grpc-federation:v0.9.2
FAIL
FAIL github.com/bufbuild/plugins/tests 1.852s
FAIL
make: *** [test] Error 1

@@ -37,7 +37,7 @@ type Plugin struct {
}

func (p *Plugin) String() string {
return fmt.Sprintf("%s:%s", p.Identity.IdentityString(), p.Version)
return fmt.Sprintf("%s:%s", p.Identity.IdentityString(), p.PluginVersion)
Copy link
Member Author

Choose a reason for hiding this comment

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

Version here is v1 of the config, it should be the plugin version.

Copy link
Member

Choose a reason for hiding this comment

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

Doh - good catch!

@mfridman mfridman changed the title Update test case for empty gen files Update test case for empty dir hash in gen dir Jan 24, 2024
@mfridman mfridman marked this pull request as ready for review January 24, 2024 19:23
@@ -37,7 +37,7 @@ type Plugin struct {
}

func (p *Plugin) String() string {
return fmt.Sprintf("%s:%s", p.Identity.IdentityString(), p.Version)
return fmt.Sprintf("%s:%s", p.Identity.IdentityString(), p.PluginVersion)
Copy link
Member

Choose a reason for hiding this comment

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

Doh - good catch!

// plugins.
allowedEmptyPluginSums = map[string]bool{
"buf.build/bufbuild/validate-java": true,
"buf.build/grpc-ecosystem/gateway": true,
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to add an exception for thebuf.build/community/mercari-grpc-federation plugin for now until a fix is made available (at least for the current version)?

Copy link
Member Author

@mfridman mfridman Jan 24, 2024

Choose a reason for hiding this comment

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

I want to undo and remove that plugin entirely, and re-open the issue advocating for an upstream fix. Any concerns with that?

It'll eliminate a broken plugin, and we also don't know if they'll fix it upstream. So best to remove and re-open issue imo.

@mfridman mfridman merged commit 7da95c4 into main Jan 24, 2024
8 checks passed
@mfridman mfridman deleted the mf-update-test-case branch January 24, 2024 19:48
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