-
Notifications
You must be signed in to change notification settings - Fork 60
fix(toolkit-lib): fromCdkApp fails if working directory is given and outdir is relative #444
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #444 +/- ##
==========================================
+ Coverage 79.18% 79.31% +0.13%
==========================================
Files 54 54
Lines 6895 6895
Branches 772 777 +5
==========================================
+ Hits 5460 5469 +9
+ Misses 1417 1408 -9
Partials 18 18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // THEN - synth succeeds | ||
| expect(assembly.cloudAssembly.stacksRecursively.map(s => s.hierarchicalId)).toEqual(['Stack1', 'Stack2']); | ||
| } finally { | ||
| await fs.rm(path.join(app.workingDirectory, 'relative.dir'), { force: true, recursive: true }); |
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.
This should be automatic with deleteOutdir, right?
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.
Good point!
| * | ||
| * @default - `true` if `outdir` is not given, `false` otherwise | ||
| */ | ||
| readonly deleteOutdir?: boolean; |
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.
Can we have a test for this?
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.
Yes!
…outdir is relative The documentation of `fromCdkApp` falsely claimed that it would create a temporary directory and clean it up. It does not, it emits into `cdk.out` which won't get cleaned up. Update the docs.
Add integration tests for the toolkit library. Introduces the toolkit library as a new "component under test". Because we want to promote writing integ tests against the toolkit library the same way we would write normal production code, the setup is like this: - The toolkit lib is installed as a `devDependency` into the integ test package. This will allow writing tests as if the toolkit lib is "just" a dependency. - At runtime, a version of the toolkit library can be selected and it will be installed into the dependency closure by the runner before the tests are run, so that the imports will still function properly. To signal this, we'll mark `@aws-cdk/toolkit-lib` as an `optionalDependency` as well. (PR includes #444) --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license Signed-off-by: github-actions <github-actions@github.com>
If a working directory is given and outdir is relative, then the CDK app synths relative to the supplied working directory, but the toolkit tries to load the assembly relative to the process'
cwdand fails.Also, the documentation of
fromCdkAppfalsely claimed that by default it will create a temporary directory and clean it up. It does not, by default it emits into a relativecdk.outdirectory which won't get cleaned up. Thecdk.outdirectory also was not entirely consistently evaluated, so we specify that it must be evaluated againstworkingDirectory.While we're at it, immediately add a flag that allows explicit directories to be cleaned up as well so that our tests (which explicitly specify temporary directories and so they don't get cleaned up) don't spam all the way into the system's tempdir.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license