-
Notifications
You must be signed in to change notification settings - Fork 196
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
Establish the codegen-core
module
#1697
Conversation
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.
Thank you!
I wonder, should we place the Smithy models the integration tests use in a common place?
Currently all of the server ones except pokemon.smithy
and simple.smithy
are symlinks to the actual models that (now) live under codegen-client-test/model
.
Analogously, the client ones are all actual files except for pokemon.smithy
and simple.smithy
, which are symlinks.
I like this idea. Looks like I need to fix the integration tests anyway, so I'll take a stab at it. |
While moving the shared models to a central location, I discovered a few validation errors in |
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.
I'm actually not sure how this ever worked since Smithy refuses to load this model with these errors
That's very interesting. I can indeed reproduce that on upstream/main
, no errors are yielded for misc.smithy
, but now that we're using imports =
in our CodegenTest
s, we get them without 6c74dbf applied. Why can't we load the common models from the classpath (like we do for the protocol tests on awslabs/smithy), instead of using imports?
I guess it didn't run validation for non-imports before
That would be my guess too. Is that intentional on Smithy's behalf? That behavior is unexpected and should be documented if so. But I suspect it's a bug and we should cut them an issue.
but this deserves some additional scrutiny.
The changes in 6c74dbf look good to me. However, is failing build on DANGER events appropriate for http.code
for a 4xx code? The spec says:
The provided value SHOULD be between 100 and 599, and it MUST be between 100 and 999.
I would expect the build to fail were it a MUST, but it's a SHOULD in this case.
fun generateImports(imports: List<String>): String = if (imports.isEmpty()) { | ||
"" | ||
} else { | ||
"\"imports\": [${imports.map { "\"$it\"" }.joinToString(", ")}]," |
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.
"\"imports\": [${imports.map { "\"$it\"" }.joinToString(", ")}]," | |
"\"imports\": [${imports.joinToString(", ") { "\"$it\"" }}]," |
I think it would be a bad idea to have test models in the I suppose we could also have a separate module entirely just for the common models, as an alternative. But I think getting validation via imports is probably better. Edit: Going to hold off on making any changes here. I think this needs to be addressed in Smithy. |
Something seems wrong here. Not sure if it's the spec or the error. I filed smithy-lang/smithy#1386 on Smithy. |
Filed smithy-lang/smithy#1387 on Smithy to track the validation oddity. Also added my findings to #1489. |
The PR bot failure to create a diff is expected since the script is now referencing |
I think this thing of loading using With this patch, if I mess up e.g.
Then the build succeeds. Without this patch, currently on |
Indeed, with this patch applied, if I set a breakpoint in the codegen visitor and inspect the It'd be nice if the models vended by awslabs/smithy were not bundled in the JAR then, which I presume is the reason why they are always being loaded and validated even when you're not generating them. That would speed things up substantially, since they define the bulk of the shapes being loaded (more than 2000). |
Motivation and Context
This PR establishes a
codegen-core
module so that pieces of the oldcodegen
module thatcodegen-server
has been reusing can opportunistically be refactored out so that there is a better separation of the client/server code generation logic. The high level changes are:codegen-core
modulecodegen-core
as a dependency tocodegen
andcodegen-server
Version
class intocodegen-core
so that it has at least one thing in itcodegen
tocodegen-client
codegen-test
tocodegen-client-test
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.