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

chore(aws-cdk-lib): fix so that the commandHook function is called only once during bundling. #32776

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

Conversation

ayame113
Copy link

@ayame113 ayame113 commented Jan 7, 2025

This is my first contribution to aws-cdk! So please let me know if I'm doing something wrong.

Issue # (if applicable)

Closes #31973.

Reason for this change

When using local bundling, the commandHook function was being called twice.
This PR fixes it so that it is only called once.

Description of changes

When the variable shouldBuildImage is true, a createBundlingCommand for the Docker build will be created as before.
When the variable shouldBuildImage is false, a createBundlingCommand for the local build will be created when bundler.local.tryBundle() is called. (Previously, both a createBundlingCommand for the Docker build and for the local build were created.)

After making this change, some tests failed because they were expecting the createBundlingCommand to be called immediately, so I added forcedDockerBundling: true to some of the tests.

Note: I was going to send a patch to aws-cdk-lib, but I found a similar code in aws-lambda-go-alpha, so I fixed it at the same time. Is that okay?

Description of how you validated changes

I've added a unit test.

Checklist


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

@ayame113 ayame113 changed the title chore(aws-cdk-lib): Fix so that the commandHook` function is called only once during bundling. chore(aws-cdk-lib): Fix so that the commandHook function is called only once during bundling. Jan 7, 2025
@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/medium Medium work item – several days of effort p2 labels Jan 7, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team January 7, 2025 11:07
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.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. 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.

@ayame113 ayame113 changed the title chore(aws-cdk-lib): Fix so that the commandHook function is called only once during bundling. chore(aws-cdk-lib): fix so that the commandHook function is called only once during bundling. Jan 7, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 7, 2025 11:14

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

@ayame113
Copy link
Author

ayame113 commented Jan 7, 2025

@Mergifyio update

Copy link
Contributor

mergify bot commented Jan 7, 2025

update

✅ Branch has been successfully updated

@ayame113 ayame113 changed the title chore(aws-cdk-lib): fix so that the commandHook function is called only once during bundling. fix(aws-cdk-lib): fix so that the commandHook function is called only once during bundling. Jan 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.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. 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.

@ayame113 ayame113 changed the title fix(aws-cdk-lib): fix so that the commandHook function is called only once during bundling. chore(aws-cdk-lib): fix so that the commandHook function is called only once during bundling. Jan 7, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 7, 2025 11:32

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jan 7, 2025
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

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

Thanks 👍
A couple of comments:

  1. I'd classify the PR as a fix(lambda) instead of a chore (that will require an integration test update as well to verify the change)
  2. Do we need to fix the behavior for Python runtimes as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/medium Medium work item – several days of effort p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-lambda-nodejs): commandHooks is called twice when local bundling
3 participants