Repository navigation
chore(pkglint): disallow experimental dependencies - #14249
Conversation
| /** | ||
| * Should this package be included in the monolithic package. | ||
| */ | ||
| function isIncludedInMonolith(pkg: PackageJson): boolean { |
There was a problem hiding this comment.
@eladb I ended up duplicating this logic from ubergen. The logic in ubergen relies on the fact that the ubergen.exclude is not set on all modules that needs to excluded :/ . It's kinda of tricky, the TL;DR is that if the module is not uber.exclude there is a special logic that checks if it needs to be considered deprecated: code.
(Open to ideas of course)
|
|
||
| const shortName = dep.split('/')[1]; | ||
| // eslint-disable-next-line @typescript-eslint/no-require-imports | ||
| const stability = require(path.resolve('../', shortName, 'package.json')).stability; |
There was a problem hiding this comment.
Please don't write these kinds of rules that rely on physical locations of files in the source repository.
Instead, if you must find a dependency's package.json, do something like this:
const dependencyPj = path.resolve(`${shortName}/package.json`, { paths: [searchPath] });
const packageJson = await readJson(dependencyPj);There was a problem hiding this comment.
So! We only need to read the package.json file of dependencies, which means they were already loaded during the build phase => we can require the dependency name, and we don't need a path:
const stability = require(`${dep}/package.json`).stability;|
@rix0rrr thanks for the review, I have addressed your comment, can you have another look? 🦄 |
A previous [PR](#13823) added a dependency from the stable module `aws-events-targets` to the experimental module `aws-batch`. Depending on experimental modules is no longer allowed. In fact, this PR build should have failed when attempting to build `aws-cdk-lib`, preventing it from being merged. However, since the dependency was added but not used, the build succeeded, and the PR was merged. ### Why did we expect the PR build of #13823 to fail? In the build step of `aws-cdk-lib` we strip all the L2 of experimental modules. This means that when compiling `aws-cdk-lib` the L2 types of experimental modules does not exists, if a stable module reference such a type, the build of `aws-cdk-lib` will fail. ### Why did the PR build of #13823 succeeded? It added a dependency on the experimental `aws-batch` but didn't use it. ### What are we doing to prevent this from happening in the future? #14249 adds a lint rule that disallow depending on an experimental module. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
A previous [PR](aws#13823) added a dependency from the stable module `aws-events-targets` to the experimental module `aws-batch`. Depending on experimental modules is no longer allowed. In fact, this PR build should have failed when attempting to build `aws-cdk-lib`, preventing it from being merged. However, since the dependency was added but not used, the build succeeded, and the PR was merged. ### Why did we expect the PR build of aws#13823 to fail? In the build step of `aws-cdk-lib` we strip all the L2 of experimental modules. This means that when compiling `aws-cdk-lib` the L2 types of experimental modules does not exists, if a stable module reference such a type, the build of `aws-cdk-lib` will fail. ### Why did the PR build of aws#13823 succeeded? It added a dependency on the experimental `aws-batch` but didn't use it. ### What are we doing to prevent this from happening in the future? aws#14249 adds a lint rule that disallow depending on an experimental module. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
> blocked on aws#14291 This PR adds a pkglint rule to disallow `@aws-cdk` modules to depend on experimental `@aws-cdk` modules. In v2 experimental modules will be released separately from `aws-cdk-lib`. This means that stable modules can not depend on experimental modules as it will create a cyclic dependency. The lint rule **also** ban exp->exp dependencies. The reasoning for the latter is that if an experimental module A, depends on experimental module B, in order to graduate module A, module B will also have to be graduated (to satisfy no stable->exp). Currently there are a few exp->exp dependencies, these might be removed as a part of the work to release the experimental modules separately from `aws-cdk-lib`. In the meantime we explicitly allow them by having an exclusion map. The current implementation executes the check for each modules as a part of its `pkglint` phase, which is O(n^2) (for each module check the stability of all of its dependencies). This can be improved by executing the check only once, in the build of `aws-cdk-lib` (going over all the modules in a topological order and storing the stability). The disadvantage of executing it only on the build of `aws-cdk-lib` is that it will not be executed as a part of a typical developer flow, which is `buildup` from a specific package. I have testes it several times locally in the current implementation adds ~2 seconds to the root level `yarn pkglint`. Since it does not add significant time to our build, and gives better/earlier visibility to contributors I have decided to keep it simple and preform the check on each module build. Happy to discuss more if anyone have concerns or optimizations ideas I missed. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
A previous [PR](aws#13823) added a dependency from the stable module `aws-events-targets` to the experimental module `aws-batch`. Depending on experimental modules is no longer allowed. In fact, this PR build should have failed when attempting to build `aws-cdk-lib`, preventing it from being merged. However, since the dependency was added but not used, the build succeeded, and the PR was merged. ### Why did we expect the PR build of aws#13823 to fail? In the build step of `aws-cdk-lib` we strip all the L2 of experimental modules. This means that when compiling `aws-cdk-lib` the L2 types of experimental modules does not exists, if a stable module reference such a type, the build of `aws-cdk-lib` will fail. ### Why did the PR build of aws#13823 succeeded? It added a dependency on the experimental `aws-batch` but didn't use it. ### What are we doing to prevent this from happening in the future? aws#14249 adds a lint rule that disallow depending on an experimental module. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
> blocked on aws#14291 This PR adds a pkglint rule to disallow `@aws-cdk` modules to depend on experimental `@aws-cdk` modules. In v2 experimental modules will be released separately from `aws-cdk-lib`. This means that stable modules can not depend on experimental modules as it will create a cyclic dependency. The lint rule **also** ban exp->exp dependencies. The reasoning for the latter is that if an experimental module A, depends on experimental module B, in order to graduate module A, module B will also have to be graduated (to satisfy no stable->exp). Currently there are a few exp->exp dependencies, these might be removed as a part of the work to release the experimental modules separately from `aws-cdk-lib`. In the meantime we explicitly allow them by having an exclusion map. The current implementation executes the check for each modules as a part of its `pkglint` phase, which is O(n^2) (for each module check the stability of all of its dependencies). This can be improved by executing the check only once, in the build of `aws-cdk-lib` (going over all the modules in a topological order and storing the stability). The disadvantage of executing it only on the build of `aws-cdk-lib` is that it will not be executed as a part of a typical developer flow, which is `buildup` from a specific package. I have testes it several times locally in the current implementation adds ~2 seconds to the root level `yarn pkglint`. Since it does not add significant time to our build, and gives better/earlier visibility to contributors I have decided to keep it simple and preform the check on each module build. Happy to discuss more if anyone have concerns or optimizations ideas I missed. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
A previous [PR](aws#13823) added a dependency from the stable module `aws-events-targets` to the experimental module `aws-batch`. Depending on experimental modules is no longer allowed. In fact, this PR build should have failed when attempting to build `aws-cdk-lib`, preventing it from being merged. However, since the dependency was added but not used, the build succeeded, and the PR was merged. ### Why did we expect the PR build of aws#13823 to fail? In the build step of `aws-cdk-lib` we strip all the L2 of experimental modules. This means that when compiling `aws-cdk-lib` the L2 types of experimental modules does not exists, if a stable module reference such a type, the build of `aws-cdk-lib` will fail. ### Why did the PR build of aws#13823 succeeded? It added a dependency on the experimental `aws-batch` but didn't use it. ### What are we doing to prevent this from happening in the future? aws#14249 adds a lint rule that disallow depending on an experimental module. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
> blocked on aws#14291 This PR adds a pkglint rule to disallow `@aws-cdk` modules to depend on experimental `@aws-cdk` modules. In v2 experimental modules will be released separately from `aws-cdk-lib`. This means that stable modules can not depend on experimental modules as it will create a cyclic dependency. The lint rule **also** ban exp->exp dependencies. The reasoning for the latter is that if an experimental module A, depends on experimental module B, in order to graduate module A, module B will also have to be graduated (to satisfy no stable->exp). Currently there are a few exp->exp dependencies, these might be removed as a part of the work to release the experimental modules separately from `aws-cdk-lib`. In the meantime we explicitly allow them by having an exclusion map. The current implementation executes the check for each modules as a part of its `pkglint` phase, which is O(n^2) (for each module check the stability of all of its dependencies). This can be improved by executing the check only once, in the build of `aws-cdk-lib` (going over all the modules in a topological order and storing the stability). The disadvantage of executing it only on the build of `aws-cdk-lib` is that it will not be executed as a part of a typical developer flow, which is `buildup` from a specific package. I have testes it several times locally in the current implementation adds ~2 seconds to the root level `yarn pkglint`. Since it does not add significant time to our build, and gives better/earlier visibility to contributors I have decided to keep it simple and preform the check on each module build. Happy to discuss more if anyone have concerns or optimizations ideas I missed. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR adds a pkglint rule to disallow
@aws-cdkmodules to depend on experimental@aws-cdkmodules.In v2 experimental modules will be released separately from
aws-cdk-lib. This means that stable modules can not depend on experimental modules as it will create a cyclic dependency. The lint rule also ban exp->exp dependencies. The reasoning for the latter is that if an experimental module A, depends on experimental module B, in order to graduate module A, module B will also have to be graduated (to satisfy no stable->exp). Currently there are a few exp->exp dependencies, these might be removed as a part of the work to release the experimental modules separately fromaws-cdk-lib. In the meantime we explicitly allow them by having an exclusion map.The current implementation executes the check for each modules as a part of its
pkglintphase, which is O(n^2) (for each module check the stability of all of its dependencies). This can be improved by executing the check only once, in the build ofaws-cdk-lib(going over all the modules in a topological order and storing the stability). The disadvantage of executing it only on the build ofaws-cdk-libis that it will not be executed as a part of a typical developer flow, which isbuildupfrom a specific package. I have testes it several times locally in the current implementation adds ~2 seconds to the root levelyarn pkglint. Since it does not add significant time to our build, and gives better/earlier visibility to contributors I have decided to keep it simple and preform the check on each module build. Happy to discuss more if anyone have concerns or optimizations ideas I missed.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license