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: extract bootstrap into separate project with tests #1172

Merged
merged 5 commits into from
Jan 25, 2024
Merged

Conversation

aajtodd
Copy link
Collaborator

@aajtodd aajtodd commented Jan 8, 2024

Issue #

n/a

Description of changes

refactor: Add a new .brazil.json file with the transform logic for just aws-sdk-kotlin. NOTE: This will not take effect until we release a new version of kat and update the release pipeline to use it. Until then the "global" transform config from repo tools is still the one being used. I tested this locally already on 5 services (all protocols) + the runtime and diffed the transform output using the one from repo tools and this new localized copy
refactor: Extract a lot of the logic used to bootstrap the AWS services codegen tasks into a separate composite build. This allows us to actually add tests for our logic and have higher confidence in changes to the build. There is more to do here but I think this is a decent point to stop and review before continuing with any refactoring or adding additional tests.

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

@aajtodd aajtodd added the no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. label Jan 8, 2024
@aajtodd aajtodd requested a review from a team as a code owner January 8, 2024 21:20
Copy link

github-actions bot commented Jan 8, 2024

A new generated diff is ready to view.

},
"packageHandlingRules": {
"versioning": {
"defaultVersionLayout": "{MAJOR}.0.x"
Copy link
Member

Choose a reason for hiding this comment

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

note: We will have to remember to change this for our next minor version bump. There's a tradeoff between security (not accidentally bumping version) and maintainability (remembering this also needs to change).

Maybe this should be documented somewhere (e.g internal runbook) for bumping versions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note: We will have to remember to change this for our next minor version bump.

If we land where I hope we land (which is to have only one internal major version) then I expect this won't ever change even when we bump minor version externally. This is set for now to preserve the existing major version and not accidentally bump it (introducing a new MV internally).

project.logger.info("discovered service: ${serviceTrait.sdkId}")
AwsService(
serviceShapeId = service.id.toString(),
packageName = packageNamespaceForService(sdkId),
Copy link
Member

Choose a reason for hiding this comment

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

correctness: should this be packageNameForService(sdkId)?
it's correct, but I had a comment about the naming below

/**
* Get the package namespace for a service from it's `sdkId`
*/
fun packageNamespaceForService(sdkId: String): String = "$SDK_PACKAGE_NAME_PREFIX${packageNameForService(sdkId)}"
Copy link
Member

Choose a reason for hiding this comment

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

naming: namespacedPackageNameForService?

while reading this, I was expecting packageNamespace to just return $SDK_PACKAGE_NAME_PREFIX, not the package name as well

fun Membership.isMember(vararg memberNames: String): Boolean =
memberNames.none(exclusions::contains) && (inclusions.isEmpty() || memberNames.any(inclusions::contains))
fun parseMembership(rawList: String?): Membership {
if (rawList == null) return Membership()
Copy link
Member

Choose a reason for hiding this comment

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

nit: this early return seems not necessary

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Much of this was ported as is

Comment on lines +13 to +17
fun packageNameForService(sdkId: String): String =
sdkId.replace(" ", "")
.replace("-", "")
.lowercase()
.kotlinNamespace()
Copy link
Member

Choose a reason for hiding this comment

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

simplification: fun packageNameForService(sdkId: String): String = sdkIdToArtifactName(sdkId).kotlinNamespace()

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 didn't want to change anything from what it was (yet anyway) so much of the naming is ported exactly as it was.

Comment on lines +35 to +42
listOf(
RestJson1Trait.ID,
RestXmlTrait.ID,
AwsJson1_0Trait.ID,
AwsJson1_1Trait.ID,
AwsQueryTrait.ID,
Ec2QueryTrait.ID,
).first { hasTrait(it) }.name
Copy link
Member

Choose a reason for hiding this comment

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

comment: I feel like Smithy should provide this list of protocol traits

they don't (I checked) but it seems like this defining this custom list will break something in the future

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah this is unfortunate but luckily the list of protocols doesn't change much over time.

Copy link

github-actions bot commented Jan 9, 2024

A new generated diff is ready to view.

Copy link

A new generated diff is ready to view.

Copy link

A new generated diff is ready to view.

Copy link

A new generated diff is ready to view.

Copy link

Quality Gate Passed Quality Gate passed

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

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

See analysis details on SonarCloud

Copy link

A new generated diff is ready to view.

@aajtodd aajtodd merged commit 6ebeb63 into main Jan 25, 2024
15 of 16 checks passed
@aajtodd aajtodd deleted the publishing-qa branch January 25, 2024 16:24
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.

4 participants