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

test(cli): ensure that all commands have explicit bundling configurations #33342

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

iankhou
Copy link
Contributor

@iankhou iankhou commented Feb 7, 2025

Issue #31999

Reason for this change

BUNDLING_COMMANDS is a list used to specify CLI commands that require code to be bundled. The CDK Import feature was not added to this list, but requires bundling for certain constructs (like NodeJSFunction lambda).

Description of changes

Removed list BUNDLING_COMMANDS.

Added interface ConfiguredCommand, which requires bundling to be set to a boolean value.

Added type CommandType, which ensures that each Command enum member has a corresponding key in ConfiguredCommands.

Describe any new or updated permissions being added

No permissions changes.

Description of how you validated changes

This is a refactor. The compiler validated the accuracy of the changes.

Integration test run.

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team February 7, 2025 18:57
@github-actions github-actions bot added the p2 label Feb 7, 2025
@iankhou iankhou changed the title ensure that all CLI commands are either set explicitly to bundle, or … test(cli): ensure that all CLI commands are either set explicitly to bundle, or … Feb 7, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 7, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

(This review is outdated)

@iankhou iankhou force-pushed the iankhou-bundling-commands-canary branch from eddb918 to 9e0d3f5 Compare February 7, 2025 19:14
@iankhou iankhou added the pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested label Feb 7, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review February 7, 2025 19:16

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.92%. Comparing base (5160796) to head (cabbb70).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33342   +/-   ##
=======================================
  Coverage   80.92%   80.92%           
=======================================
  Files         236      236           
  Lines       14253    14254    +1     
  Branches     2490     2490           
=======================================
+ Hits        11534    11535    +1     
  Misses       2434     2434           
  Partials      285      285           
Flag Coverage Δ
suite.unit 80.92% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
packages/aws-cdk 79.73% <100.00%> (+<0.01%) ⬆️
packages/aws-cdk-lib/core 82.20% <ø> (ø)

@iankhou iankhou marked this pull request as ready for review February 10, 2025 16:11
@iankhou iankhou requested a review from a team as a code owner February 10, 2025 16:11
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 10, 2025
@@ -35,7 +35,7 @@ export enum Command {
DOCTOR = 'doctor',
}

const BUNDLING_COMMANDS = [
export const BUNDLING_COMMANDS = [
Copy link
Contributor

@iliapolo iliapolo Feb 11, 2025

Choose a reason for hiding this comment

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

I like the idea but i'm not a fan of exporting just for the sake of a unit test. It makes the unit test somewhat brittle because they rely heavily on implementation, and not on behavior. A better option would be to enforce each command to specify whether it is bundling or not, during command creation. So for example:

export interface Command {
  bundling: boolean;
  name: string;
}

export const Commands: Command[] = [
  { name: 'ls', bundling: false },
  ....
]

const bundlingCommands = Commands.filter(c => c.bundling);

That way we don't really need a test for it, because its enforced by the compiler.

This also opens the door for additional command specific configuration we might need in the future.
I recognize this would be a larger change, and maybe its worth syncing with @mrgrain as part of toolkit refactoring. Let me know what you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to @iliapolo suggestion.

This will have to work very differently for the Toolkit, because bundling is something that controls CloudAssembly behavior. In the CLI we have a strict 1:1 mapping between CloudAssembly and CLI command. However in the toolkit, one can use the same CloudAssembly for different Toolkit actions. Not quite sure how to go about this yet. 🤔

@iankhou iankhou force-pushed the iankhou-bundling-commands-canary branch from cabbb70 to 7d7129c Compare February 12, 2025 22:09
@iankhou iankhou changed the title test(cli): ensure that all CLI commands are either set explicitly to bundle, or … test(cli): ensure that all commands have explicit bundling configurations Feb 12, 2025
@aws-cdk-automation
Copy link
Collaborator

➡️ PR build request submitted to test-main-pipeline ⬅️

A maintainer must now check the pipeline and add the pr-linter/cli-integ-tested label once the pipeline succeeds.

@iankhou iankhou force-pushed the iankhou-bundling-commands-canary branch from cfe73bb to e7004e7 Compare February 12, 2025 22:35
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: e7004e7
  • Result: FAILED
  • Build Logs (available for 30 days)

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

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. p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants