Skip to content

Conversation

@mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Mar 27, 2025

Refactors the cxapp api code to use modern messaging. This had a larger amount of knock-on effects then other refactors, to the PR is a bit bigger.


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

/**
* Compute the bootstrap enviornments
*
* @internal
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was previously missed to mark internal.

*
* @internal
*/
async getEnvironments(ioHost: IIoHost): Promise<cxapi.Environment[]> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it's internal, we can change this.

@aws-cdk-automation aws-cdk-automation requested a review from a team March 27, 2025 14:09
@github-actions github-actions bot added the p2 label Mar 27, 2025
Copy link
Contributor Author

@mrgrain mrgrain Mar 27, 2025

Choose a reason for hiding this comment

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

this turned into a bigger refactor. I realized a lot of these helpers share the same context, so a new abstraction (class) seemed appropriate. No functional changes.

* fine in certain scenarios.
*/
public async defaultEnvVars(): Promise<Env> {
const debugFn = (msg: string) => this.ioHelper.notify(IO.CDK_ASSEMBLY_I0010.msg(msg));
Copy link
Contributor Author

@mrgrain mrgrain Mar 27, 2025

Choose a reason for hiding this comment

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

uses a different code than the other messages in this class. probably doesn't need to. We can make a breaking change at some point.

const assembly = await changeDir(async () =>
withContext(context.all, env, props.synthOptions ?? {}, async (envWithContext, ctx) =>
withEnv(envWithContext, () => {
const x = new ExecutionEnviornment(services, { outdir: props.outdir });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

x for eXecution. Open to better suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe simply execution.

const outdir = assembly.directory;
const fileName = assembly.tree()?.file;
return fileName ? fs.readJSONSync(path.join(outdir, fileName)).tree : {};
return fileName ? fs.readJSONSync(path.join(outdir, fileName)).tree : ({} as ConstructTreeNode);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We always had it like this, but it's an error in my IDE so I thought I might as well cast it.

@mrgrain mrgrain force-pushed the mrgrain/refactor/cxapp-logging branch from 8719052 to edd45e2 Compare March 27, 2025 15:34
@codecov-commenter
Copy link

codecov-commenter commented Mar 27, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 14 lines in your changes missing coverage. Please review.

Project coverage is 85.34%. Comparing base (0db3dc2) to head (868e8e1).

Files with missing lines Patch % Lines
packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts 73.91% 6 Missing ⚠️
packages/aws-cdk/lib/api/cxapp/cloud-executable.ts 70.00% 3 Missing ⚠️
packages/aws-cdk/lib/api/cxapp/exec.ts 96.92% 2 Missing ⚠️
packages/aws-cdk/lib/api/tree.ts 33.33% 2 Missing ⚠️
packages/aws-cdk/lib/cli/cli.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #285   +/-   ##
=======================================
  Coverage   85.33%   85.34%           
=======================================
  Files         222      222           
  Lines       36761    36798   +37     
  Branches     4447     4448    +1     
=======================================
+ Hits        31370    31405   +35     
+ Misses       5294     5292    -2     
- Partials       97      101    +4     
Flag Coverage Δ
suite.unit 85.34% <87.50%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mrgrain mrgrain force-pushed the mrgrain/refactor/cxapp-logging branch from edd45e2 to 802c5c1 Compare March 27, 2025 16:06
@mrgrain mrgrain force-pushed the mrgrain/refactor/cxapp-logging branch from 802c5c1 to e998ab8 Compare March 27, 2025 16:36
Signed-off-by: github-actions <[email protected]>
const assembly = await changeDir(async () =>
withContext(context.all, env, props.synthOptions ?? {}, async (envWithContext, ctx) =>
withEnv(envWithContext, () => {
const x = new ExecutionEnviornment(services, { outdir: props.outdir });
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe simply execution.

() => runCli(args, async (sdk, config) => {
const env = await prepareDefaultEnvironment(sdk);
const context = await prepareContext(config.settings, config.context.all, env);
const env = await prepareDefaultEnvironment(sdk, debugFn);
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this the default value anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

prepareDefaultEnvironment used to have a default for debugFn, but the default was using the old legacy logging system. Removed the default, made the param mandatory. cli-lib-alpha will use legacy logging until further notice, but we plan to deprecate that package anyway soon.

@mrgrain mrgrain temporarily deployed to integ-approval March 28, 2025 11:41 — with GitHub Actions Inactive
@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Mar 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 28, 2025
@mrgrain mrgrain added this pull request to the merge queue Mar 28, 2025
Merged via the queue into main with commit 2a9ee4c Mar 28, 2025
20 checks passed
@mrgrain mrgrain deleted the mrgrain/refactor/cxapp-logging branch March 28, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants