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

chore: add scaffolding task #1202

Merged
merged 9 commits into from
Feb 6, 2024
Merged

chore: add scaffolding task #1202

merged 9 commits into from
Feb 6, 2024

Conversation

aajtodd
Copy link
Collaborator

@aajtodd aajtodd commented Feb 5, 2024

Issue #

fixes #1189

Description of changes

  • Adds a new scaffold task for service client codegen to generate package metadata once which will be re-used across future build/publish. This allows us to change the logic behind inference over time without breaking existing packages while also serving as a hedge against accidentally breaking existing packages/artifacts.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@aajtodd aajtodd requested a review from a team as a code owner February 5, 2024 20:04
@aajtodd aajtodd force-pushed the publishing-qa-scaffold branch from ec25475 to 60ee9fa Compare February 5, 2024 20:08
Copy link

github-actions bot commented Feb 5, 2024

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK

Copy link

github-actions bot commented Feb 5, 2024

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK

Copy link
Contributor

@ianbotsf ianbotsf left a comment

Choose a reason for hiding this comment

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

I think the term "scaffold" is not clear enough on its own. May I suggest "scaffold-new-packages", "update-package-manifest", etc., as terms which are more clear for a task name or a task class name.

@@ -37,3 +37,16 @@ internal fun sdkIdToArtifactName(sdkId: String): String = sdkId.replace(" ", "")
* catapult! See AwsSdkCatapultWorkspaceTools:lib/source/merge/smithy-model-handler.ts
*/
fun sdkIdToModelFilename(sdkId: String): String = sdkId.trim().replace("""[\s]+""".toRegex(), "-").lowercase()

// FIX - replace with case utils from smithy-kotlin once we verify we can change the implementation
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: FIXFIXME

Comment on lines 52 to 53
check(modelFile.isPresent || modelDir.isPresent) { "one of `model` or `model-dir` is required" }
check(!(modelFile.isPresent && modelDir.isPresent)) { "only one of `model` or `model-dir` can be set" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Style: Could combine:

check(modelFile.isPresent != modelDir.isPresent) { "Exactly one of `model` or `model-dir` must be set" }

Comment on lines 15 to 17
val modelContents = """
${"$"}version: "2.0"
${"$"}version: "2"
namespace gradle.test
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Why did this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've slept and hacked since then and I don't recall. I want to say something about the model discovery and validation triggering something here and so I just fixed it to make smithy happy again.

Copy link
Member

Choose a reason for hiding this comment

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

services still model this as 2.0, so if it breaks in this test, would it also break once we try to use it for a real service?

probably not, because the CI which bootstraps services passes, still weird.

Copy link
Contributor

Choose a reason for hiding this comment

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

In Smithy IDL, both of these statements are valid but seem to mean the exact same thing—tooling must support an IDL version of anywhere from 2.0 (inclusive) to 3.0 (exclusive). I'd be curious what broke and if there's maybe a bug somewhere else.

Comment on lines 82 to 85
val expected = AwsService(
"gradle.test#TestService",
"aws.sdk.kotlin.services.testgradle",
"aws.sdk.kotlin.services.testgradle2",
"1.2.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Is this rename significant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's proving that the namespace is taken from the package manifest given vs the inferred namespace from sdkId.

Comment on lines +48 to +54
@Serializable
data class PackageMetadata(
public val sdkId: String,
public val namespace: String,
public val artifactName: String,
public val brazilName: String,
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Add KDocs. In particular, it's not clear that artifactName means "Maven artifact name (i.e., the 'A' in 'GAV')" solely by looking at the code.

@aajtodd
Copy link
Collaborator Author

aajtodd commented Feb 6, 2024

I think the term "scaffold" is not clear enough on its own. May I suggest "scaffold-new-packages", "update-package-manifest", etc., as terms which are more clear for a task name or a task class name.

As the task name? It is qualified by the project :codegen:sdk:scaffold when invoked to be fair which does give it some additional context.

Task names are (err should be) camel cased though so it would be one of:

  • scaffold
  • scaffoldNewPackages
  • updatePackageManifest
  • etc

I chose scaffold as it sets up any scaffolding for new services. Currently that is only updating the package manifest, in the future it could be more though. Not a hill I want to die on though so if you feel strongly (or anyone else does) just weigh in with your preference.

@lauzadis
Copy link
Member

lauzadis commented Feb 6, 2024

I'd vote for updatePackageManifest for ultimate clarity

Comment on lines 15 to 17
val modelContents = """
${"$"}version: "2.0"
${"$"}version: "2"
namespace gradle.test
Copy link
Member

Choose a reason for hiding this comment

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

services still model this as 2.0, so if it breaks in this test, would it also break once we try to use it for a real service?

probably not, because the CI which bootstraps services passes, still weird.

@@ -185,6 +192,11 @@ tasks.register("bootstrap") {
finalizedBy(stageSdks)
}

tasks.register<Scaffold>("scaffold") {
group = "codegen"
description = "Add a new service to packages.json manifest"
Copy link
Member

Choose a reason for hiding this comment

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

nit: it can add or update multiple services

@aajtodd aajtodd added the no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. label Feb 6, 2024
Copy link

github-actions bot commented Feb 6, 2024

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK

Copy link

sonarqubecloud bot commented Feb 6, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

10 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

github-actions bot commented Feb 6, 2024

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK

@aajtodd aajtodd merged commit fc8538e into main Feb 6, 2024
15 of 16 checks passed
@aajtodd aajtodd deleted the publishing-qa-scaffold branch February 6, 2024 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't sequentially bootstrap more than one SDK client
3 participants