-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
Still working through this, need to add tests. |
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.
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.
}); | ||
} | ||
})); | ||
|
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.
should the integ tests go in this file?
packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts
Show resolved
Hide resolved
Exemption Request: I added a CLI integ test instead of framework-integ, because this is a change of CLI. |
@lpizzinidev When you have time could mind reviewing? |
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.
The implementation looks good.
I left some comments for improvements 👍
packages/aws-cdk/lib/cli.ts
Outdated
@@ -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 }), |
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.
.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 }), |
packages/aws-cdk/lib/cdk-toolkit.ts
Outdated
@@ -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 |
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.
// 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'); | ||
} |
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.
} 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) => { |
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.
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>) { |
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.
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) => { |
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.
Not sure about this.
We should verify that the app deploys when there are no stacks in it.
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 you please add back the integration tests in cli-lib.integtest.ts? (both happy and failure cases)
Then this will be good imo.
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.
On second thought, the integration tests in cli.integtest.ts
should provide enough coverage here.
Thanks for the changes 👍
➡️ PR build request submitted to A maintainer must now check the pipeline and add the |
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. |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
Thank you @msambol !!! |
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