Skip to content

Conversation

@mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Feb 13, 2025

Reason for this change

Unused code path that was previously deprecated needs to be removed in preparation of refactoring.

Description of changes

Removing previously deprecated and unused methods on Deployments class and transitively unused code.
Removed options for asset building/publishing that are unused.

Describe any new or updated permissions being added

n/a

Description of how you validated changes

existing tests

Checklist


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

@mrgrain mrgrain requested a review from a team as a code owner February 13, 2025 14:40
@aws-cdk-automation aws-cdk-automation requested a review from a team February 13, 2025 14:41
@github-actions github-actions bot added the p2 label Feb 13, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 13, 2025
/**
* Options to pass on to `buildAssets()` function
*/
readonly buildOptions?: BuildAssetsOptions;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only used by buildSingleAsset. None of the call sites specify buildOptions. Not used in buildSingleAsset at all.

/**
* Options to pass on to `publishAsests()` function
*/
readonly publishOptions?: Omit<PublishAssetsOptions, 'buildAssets'>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only used by publishSingleAsset. None of the call sites specify publishOptions . Not used in publishSingleAsset at all.

return stack.exists;
}

private async prepareAndValidateAssets(asset: cxapi.AssetManifestArtifact, options: AssetOptions) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only used by the removed methods

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)

Comment on lines -82 to -129
export interface BuildAssetsOptions {
/**
* Print progress at 'debug' level
*/
readonly quiet?: boolean;

/**
* Build assets in parallel
*
* @default true
*/
readonly parallel?: boolean;
}

/**
* Use cdk-assets to build all assets in the given manifest.
*/
export async function buildAssets(
manifest: AssetManifest,
sdk: SdkProvider,
targetEnv: Environment,
options: BuildAssetsOptions = {},
) {
// This shouldn't really happen (it's a programming error), but we don't have
// the types here to guide us. Do an runtime validation to be super super sure.
if (
targetEnv.account === undefined ||
targetEnv.account === UNKNOWN_ACCOUNT ||
targetEnv.region === undefined ||
targetEnv.account === UNKNOWN_REGION
) {
throw new ToolkitError(`Asset building requires resolved account and region, got ${JSON.stringify(targetEnv)}`);
}

const publisher = new AssetPublishing(manifest, {
aws: new PublishingAws(sdk, targetEnv),
progressListener: new PublishingProgressListener(options.quiet ?? false),
throwOnError: false,
publishInParallel: options.parallel ?? true,
buildAssets: true,
publishAssets: false,
});
await publisher.publish();
if (publisher.hasFailures) {
throw new ToolkitError('Failed to build one or more assets. See the error messages above for more information.');
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not used anymore

Comment on lines -21 to -33
export interface PublishAssetsOptions {
/**
* Print progress at 'debug' level
*/
readonly quiet?: boolean;

/**
* Whether to build assets before publishing.
*
* @default true To remain backward compatible.
*/
readonly buildAssets?: boolean;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only a single internal call-site of publishAssets is left and it is not specifying these options.

Comment on lines 57 to +64
const publisher = new AssetPublishing(manifest, {
aws: new PublishingAws(sdk, targetEnv),
progressListener: new PublishingProgressListener(options.quiet ?? false),
progressListener: new PublishingProgressListener(),
throwOnError: false,
publishInParallel: options.parallel ?? true,
buildAssets: options.buildAssets ?? true,
buildAssets: true,
publishAssets: true,
quiet: options.quiet,
quiet: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only a single internal call-site of publishAssets is left and it is not specifying quiet or buildAssets. So we just use the default value.


class PublishingProgressListener implements IPublishProgressListener {
constructor(private readonly quiet: boolean) {}
constructor() {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed unused quiet option upstream in favor of it always being the default (false).


public onPublishEvent(type: EventType, event: IPublishProgress): void {
const handler = this.quiet && type !== 'fail' ? debug : EVENT_TO_LOGGER[type];
const handler = EVENT_TO_LOGGER[type];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed unused quiet option upstream in favor of it always being the default (false) => we just use the default part of the conditional.

@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.

@codecov
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 81.00%. Comparing base (91765e2) to head (c25b930).

❌ Your patch check has failed because the patch coverage (50.00%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #33432      +/-   ##
==========================================
+ Coverage   80.90%   81.00%   +0.09%     
==========================================
  Files         238      238              
  Lines       14287    14269      -18     
  Branches     2495     2492       -3     
==========================================
- Hits        11559    11558       -1     
+ Misses       2442     2425      -17     
  Partials      286      286              
Flag Coverage Δ
suite.unit 81.00% <50.00%> (+0.09%) ⬆️

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

Components Coverage Δ
packages/aws-cdk 79.92% <50.00%> (+0.18%) ⬆️
packages/aws-cdk-lib/core 82.16% <ø> (ø)

@mrgrain mrgrain added pr-linter/exempt-codecov The PR linter will not require codecov checks to pass pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested labels Feb 13, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review February 13, 2025 17:11

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

@mergify
Copy link
Contributor

mergify bot commented Feb 13, 2025

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: c25b930
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Feb 13, 2025

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).

@mergify mergify bot merged commit 331d7a5 into main Feb 13, 2025
17 of 20 checks passed
@mergify mergify bot deleted the mrgrain/chore/cli/remove-unused-code-and-options branch February 13, 2025 17:43
@github-actions
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p2 pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested pr-linter/exempt-codecov The PR linter will not require codecov checks to pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants