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

feat(cli): option to ignore no stacks #28387

Merged
merged 10 commits into from
Jan 10, 2024
Merged

feat(cli): option to ignore no stacks #28387

merged 10 commits into from
Jan 10, 2024

Conversation

msambol
Copy link
Contributor

@msambol msambol commented Dec 15, 2023

I'm new to development on this package—any feedback regarding testing is appreciated.

Closes #28371.


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

@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 labels Dec 15, 2023
@msambol
Copy link
Contributor Author

msambol commented Dec 15, 2023

Still working through this, need to add tests.

@aws-cdk-automation aws-cdk-automation requested a review from a team December 15, 2023 17:03
@github-actions github-actions bot added the star-contributor [Pilot] contributed between 25-49 PRs to the CDK label Dec 15, 2023
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.

});
}
}));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should the integ tests go in this file?

@msambol msambol marked this pull request as ready for review December 20, 2023 22:31
@msambol
Copy link
Contributor Author

msambol commented Dec 20, 2023

Exemption Request: I added a CLI integ test instead of framework-integ, because this is a change of CLI.

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Dec 20, 2023
@msambol
Copy link
Contributor Author

msambol commented Dec 20, 2023

@lpizzinidev When you have time could mind reviewing?

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.

The implementation looks good.
I left some comments for improvements 👍

@@ -172,7 +172,8 @@ async function parseCommandLineArguments(args: string[]) {
})
.option('concurrency', { type: 'number', desc: 'Maximum number of simultaneous deployments (dependency permitting) to execute.', default: 1, requiresArg: true })
.option('asset-parallelism', { type: 'boolean', desc: 'Whether to build/publish assets in parallel' })
.option('asset-prebuild', { type: 'boolean', desc: 'Whether to build all assets before deploying the first stack (useful for failing Docker builds)', default: true }),
.option('asset-prebuild', { type: 'boolean', desc: 'Whether to build all assets before deploying the first stack (useful for failing Docker builds)', default: true })
.option('ignore-no-stacks', { type: 'boolean', desc: 'Ignore the error message if the app contains no stacks', default: false }),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.option('ignore-no-stacks', { type: 'boolean', desc: 'Ignore the error message if the app contains no stacks', default: false }),
.option('ignore-no-stacks', { type: 'boolean', desc: 'Whether to deploy if the app contains no stacks', default: false }),

@@ -175,7 +175,8 @@ export class CdkToolkit {
}

const startSynthTime = new Date().getTime();
const stackCollection = await this.selectStacksForDeploy(options.selector, options.exclusively, options.cacheCloudAssembly);
// eslint-disable-next-line max-len
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// eslint-disable-next-line max-len

We should just take linter's advice and split the next line into multiple lines (same below).

} else {
throw new Error('This app contains no stacks');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
} else {
throw new Error('This app contains no stacks');
}
throw new Error('This app contains no stacks');

No need for an else

@@ -47,6 +47,28 @@ integTest('cli-lib deploy', withCliLibFixture(async (fixture) => {
}
}));

integTest('cli-lib deploy no stack', withCliLibFixture(async (fixture) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also add the throwing case for coverage.

/**
* Higher order function to execute a block with a CliLib Integration CDK app fixture
*/
export function withCliLibIntegrationCdkApp<A extends TestContext & AwsContext>(block: (context: CliLibIntegrationTestFixture) => Promise<void>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use a different name than with-cli-lib

@@ -780,6 +780,19 @@ integTest('deploy stack without resource', withDefaultFixture(async (fixture) =>
.rejects.toThrow('conditional-resource does not exist');
}));

integTest('deploy --ignore-no-stacks', withDefaultFixture(async (fixture) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about this.
We should verify that the app deploys when there are no stacks in it.

@aws-cdk-automation aws-cdk-automation removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Dec 21, 2023
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.

Can you please add back the integration tests in cli-lib.integtest.ts? (both happy and failure cases)
Then this will be good imo.

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.

On second thought, the integration tests in cli.integtest.ts should provide enough coverage here.
Thanks for the changes 👍

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Dec 24, 2023
@kaizencc kaizencc added pr-linter/exempt-integ-test The PR linter will not require integ test changes and removed pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-cli-test-run This PR needs CLI tests run against it. labels Jan 9, 2024
@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.

@aws-cdk-automation aws-cdk-automation added pr/needs-cli-test-run This PR needs CLI tests run against it. and removed pr/needs-maintainer-review This PR needs a review from a Core Team Member labels Jan 9, 2024
@kaizencc kaizencc changed the title feat(cli): add option to ignore no stacks feat(cli): option to ignore no stacks Jan 9, 2024
@aws-cdk-automation
Copy link
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@kaizencc kaizencc added pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested and removed pr/needs-cli-test-run This PR needs CLI tests run against it. labels Jan 10, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 10, 2024 16:38

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

Copy link
Contributor

mergify bot commented Jan 10, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit 37c79b9 into aws:main Jan 10, 2024
9 of 10 checks passed
Copy link
Contributor

mergify bot commented Jan 10, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@blimmer
Copy link
Contributor

blimmer commented Jan 10, 2024

Thank you @msambol !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested pr-linter/exempt-integ-test The PR linter will not require integ test changes star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(cli): Provide a way to ignore "This app contains no stacks"
5 participants