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

feat(rosetta): find fixtures based on submodules #3131

Merged
merged 7 commits into from
Nov 8, 2021

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Nov 5, 2021

The rosetta fixtures directory is assembly-scoped. That means that in
the monocdk transform, all Rosetta fixtures from the individual
assemblies need to be tossed together into one rosetta directory for
all of them.

Inevitably this leads to conflicts, where the various individual
default.ts-fixture files compete with each other to be the one,
global default.ts-fixture. What ends up happening is they end up
overwriting each other and the last module to get copied in wins.
All other modules' examples fail to compile.

Ideally the ubergen tool that combines these fixtures would ensure
it doesn't clobber existing files, and renames the fixtures to unique
names (maybe s3.default.ts-fixture). But if it does that, none of them are
called default.ts-fixture and so all snippets require explicit
fixture references.

Unfortunately, we now need to also automatically add in those references
and it's nontrivial to do this automatically. ubergen would need to
parse and generate both Markdown and Typescript, to add these markers
in the right places.

Instead, this PR adds the concept of scoped fixtures. If a class
(or README) is defined in a submodule, say aws_s3, then we will
first try rosetta/aws_s3/default.ts-fixture before trying
rosetta/default.ts-fixture.

That way, ubergen and other tools like it will have an easier
time combining default fixtures.

Also renamed AssemblyFixture => TestJsiiModule and made a distinction
between the two directories exposed by the object for more clarity on
what it's doing.


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

The `rosetta` fixtures directory is assembly-scoped. That means that in
the monocdk transform, all Rosetta fixtures from the individual
assemblies need to be tossed together into one `rosetta` directory for
all of them.

Inevitably this leads to conflicts, where the various individual
`default.ts-fixture` files compete with each other to be the one,
global `default.ts-fixture`. What ends up happening is they end up
overwriting each other and the last module to get copied in wins.
All other modules' examples fail to compile.

Ideally the `ubergen` tool that combines these fixtures would ensure
it doesn't clobber existing files, and renames the fixtures to unique
names (maybe `s3.default.ts-fixture`). But now, *none* of them are
called `default.ts-fixture` and so all snippets require explicit
fixture references.

Unfortunately, we now need to also automatically add in those references
and it's nontrivial to do this automatically. `ubergen` would need to
parse and generate both Markdown and Typescript, to add these markers
in the right places.

Instead, this PR adds the concept of scoped fixtures. If a class
(or README) is defined in a submodule, say `aws_s3`, then we will
first try `rosetta/aws_s3/default.ts-fixture` before trying
`rosetta/default.ts-fixture`.

That way, `ubergen` and other tools like it will have an easier
time combining default fixtures.
@rix0rrr rix0rrr requested a review from a team November 5, 2021 19:28
@rix0rrr rix0rrr self-assigned this Nov 5, 2021
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 5, 2021
@rix0rrr rix0rrr changed the title feat(rosetta): namespace fixtures based on submodules feat(rosetta): find fixtures based on submodules Nov 5, 2021
}

function middle(xs: string[]) {
if (xs.length <= 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[minor] Why is this a special case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, it doesn't need to be.

@mergify
Copy link
Contributor

mergify bot commented Nov 8, 2021

The title of this Pull Request does not conform with [Conventional Commits] guidelines. It will need to be adjusted before the PR can be merged.
[Conventional Commits]: https://www.conventionalcommits.org

@mergify
Copy link
Contributor

mergify bot commented Nov 8, 2021

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Nov 8, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 8, 2021

Merging (with squash)...

@mergify mergify bot merged commit 236dd88 into main Nov 8, 2021
@mergify mergify bot deleted the huijbers/rosetta-multiple-fixtures branch November 8, 2021 13:40
@mergify
Copy link
Contributor

mergify bot commented Nov 8, 2021

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Nov 8, 2021
mergify bot pushed a commit to aws/aws-cdk that referenced this pull request Nov 10, 2021
Currently ubergen bundles all fixtures into the same `rosetta` folder.
This means that all fixtures in files called `default.ts-fixture` replace
each other as they are found and vie to be the last `default.ts-fixture`
standing in the `rosetta` folder. This causes unintended compiliation
failures for `yarn rosetta:extract --compile` in projects that rely on
ubergen, since they will be copied into the wrong `default.ts-fixture`.

The solution here in jsii is to find fixtures based on submodules: aws/jsii#3131.
This PR updates ubergen to construct the necessary subfolders in
`rosetta` so that the expected submodule fixtures can be found. 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Currently ubergen bundles all fixtures into the same `rosetta` folder.
This means that all fixtures in files called `default.ts-fixture` replace
each other as they are found and vie to be the last `default.ts-fixture`
standing in the `rosetta` folder. This causes unintended compiliation
failures for `yarn rosetta:extract --compile` in projects that rely on
ubergen, since they will be copied into the wrong `default.ts-fixture`.

The solution here in jsii is to find fixtures based on submodules: aws/jsii#3131.
This PR updates ubergen to construct the necessary subfolders in
`rosetta` so that the expected submodule fixtures can be found. 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants