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): make assembly validation opt-in #2252

Merged
merged 3 commits into from
Nov 16, 2020

Conversation

RomainMuller
Copy link
Contributor

Assembly validation (i.e: checking that the content of the .jsii file
correctly implements the @jsii/spec schema) can be slow and memory
intensive. It is however typically not of great use, since we should
normally be able to assume assemblies are valid.

Added a --validate-assemblies option (default false) to control
whether the JSON Schema validation is done or not.


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

Assembly validation (i.e: checking that the content of the `.jsii` file
correctly implements the `@jsii/spec` schema) can be slow and memory
intensive. It is however typically not of great use, since we should
normally be able to assume assemblies are valid.

Added a `--validate-assemblies` option (default `false`) to control
whether the JSON Schema validation is done or not.
@RomainMuller RomainMuller added effort/small Small work item – less than a day of effort contribution/core This is a PR that came from AWS. labels Nov 16, 2020
@RomainMuller RomainMuller requested a review from a team November 16, 2020 14:13
@RomainMuller RomainMuller self-assigned this Nov 16, 2020
Comment on lines +22 to 37
export async function loadAssemblies(
assemblyLocations: readonly string[],
validateAssemblies: boolean,
): Promise<readonly LoadedAssembly[]> {
return Promise.all(assemblyLocations.map(loadAssembly));

async function loadAssembly(location: string): Promise<LoadedAssembly> {
const stat = await fs.stat(location);
if (stat.isDirectory()) {
ret.push({
assembly: await loadAssemblyFromFile(path.join(loc, '.jsii')), // eslint-disable-line no-await-in-loop
directory: loc,
});
} else {
ret.push({
assembly: await loadAssemblyFromFile(loc), // eslint-disable-line no-await-in-loop
directory: path.dirname(loc),
});
return loadAssembly(path.join(location, '.jsii'));
}
return {
assembly: await loadAssemblyFromFile(location, validateAssemblies),
directory: path.dirname(location),
};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-worked this code largely to remove the linter exclusions... It does the same work, except in parallel instead of serially, which could be a little faster, since this involves I/O wait.

@mergify
Copy link
Contributor

mergify bot commented Nov 16, 2020

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 16, 2020
@mergify
Copy link
Contributor

mergify bot commented Nov 16, 2020

Merging (with squash)...

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-5lHf64IXfvmr
  • Commit ID: 6e5cc1a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 302dbb9 into main Nov 16, 2020
@mergify mergify bot deleted the rmuller/rosetta-opt-in-validation branch November 16, 2020 17:44
@mergify
Copy link
Contributor

mergify bot commented Nov 16, 2020

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Nov 16, 2020
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. effort/small Small work item – less than a day of effort
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants