-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(cx-api): cannot detect CloudAssembly across different libraries #32998
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter fails with the following errors:
❌ Fixes must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed, add Clarification Request
to a comment.
2680942
to
ed53139
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32998 +/- ##
=======================================
Coverage 81.44% 81.44%
=======================================
Files 225 225
Lines 13702 13702
Branches 2404 2404
=======================================
Hits 11160 11160
Misses 2267 2267
Partials 275 275
Flags with carried forward coverage won't be shown. Click here to find out more.
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
### Issue Relates to aws/aws-cdk#32998 ### Reason for this change We are publishing the `cx-api` package twice: Once as a standalone package `@aws-cdk/cx-api` and once as part of the construct library under `aws-cdk-lib/cx-api`. The code is copied during the release and the same versions of the packages will have the same code. However this makes it difficult for other packages to take a type dependency on types from this package. The most common class that's used from `cx-api` is `CloudAssembly` - the result of `app.synth()`. Previously a package had to take a dependency on the very large `aws-cdk-lib` just to use a single type. It would be better if other packages could instead depend on the smaller, much more focused `@aws-cdk/cx-api` package. ### Description of changes In aws/aws-cdk#32998 we are adding a mechanism to detect cross-library compatibility of the `CloudAssembly` class. **However, that alone doesn't help us with type checking.** Instead we introduce a new type `ICloudAssembly` into the Cloud Assembly Schema. This interface only declares a single property: `directory`. Consumers can use this type to indicate where they would like to receive a `CloudAssembly`. They can then use runtime code to either confirm a provided object already satisfies the requirements or fallback to creating a new `CloudAssembly` from the directory.
Reason for this change
We are publishing the
cx-api
package twice: Once as a standalone package@aws-cdk/cx-api
and once as part of the construct library underaws-cdk-lib/cx-api
. The code is copied during the release and the same versions of the packages will have the same code.However this makes it difficult for other packages to take a type dependency on types from this package. The most common class that's used from
cx-api
isCloudAssembly
- the result ofapp.synth()
. Previously a package had to take a dependency on the very largeaws-cdk-lib
just to use a single type. It would be better if other packages could instead depend on the smaller, much more focused@aws-cdk/cx-api
package.Description of changes
This adds the same mechanism to
CloudAssembly
to detect cross-library compatibility, that we already use for constructs likeStack
orApp
. In TypeScript, it's now possible for a consuming package to receive an object from either package and check at runtime if it satisfies the requirements.We cannot get around type checking with this. Instead we introduce a new type
ICloudAssembly
into the Cloud Assembly Schema package (cdklabs/cloud-assembly-schema#133). This interface only declares a single property:directory
. Consumers can use this type to indicate where they would like to receive aCloudAssembly
. They can then use runtime code to either confirm a provided object already satisfies the requirements or fallback to creating a newCloudAssembly
from the directory.Because the
CloudAssembly
incxapi
implements the new interface, this approach will work in all jsii languages. In TypeScript it's even compatible with older version ofaws-cdk-lib
. Jsii language will only support this going forward.Describe any new or updated permissions being added
n/a
Description of how you validated changes
Unit tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license