Skip to content

Conversation

@Tietew
Copy link
Contributor

@Tietew Tietew commented Apr 4, 2025

Issue # (if applicable)

Closes #34042.

Reason for this change

The action name in Assets stage has been changed from FileAssetN to the display name of the asset in #33844.

When pipeline's publishAssetsInParallel is false, the action name is also changed to the display name of the first asset in stages instead of FileAsset.
The action uploads all assets, therefore, its name should indicate "all assets" rather than the first asset.

Description of changes

Use a specific (stable) display name when singlePublisher is true (pipeline's publishAssetsInParallel is false), instead of stackAsset.displayName.

Describe any new or updated permissions being added

N/A

Description of how you validated changes

Added a unit test and a integ test.

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 April 4, 2025 14:09
@github-actions github-actions bot added bug This issue is a bug. p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK labels Apr 4, 2025
@codecov
Copy link

codecov bot commented Apr 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.98%. Comparing base (994e952) to head (92c7ee5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #34049   +/-   ##
=======================================
  Coverage   83.98%   83.98%           
=======================================
  Files         120      120           
  Lines        6976     6976           
  Branches     1178     1178           
=======================================
  Hits         5859     5859           
  Misses       1005     1005           
  Partials      112      112           
Flag Coverage Δ
suite.unit 83.98% <ø> (ø)

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

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 83.98% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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 Apr 4, 2025
@gasolima gasolima assigned gasolima and matboros and unassigned gasolima May 22, 2025
const id = stackAsset.assetType === AssetType.FILE
? (this.singlePublisher ? 'FileAsset' : `FileAsset${++this._fileAssetCtr}`)
: (this.singlePublisher ? 'DockerAsset' : `DockerAsset${++this._dockerAssetCtr}`);
const displayName = this.singlePublisher ? id : stackAsset.displayName;
Copy link
Contributor

@matboros matboros May 23, 2025

Choose a reason for hiding this comment

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

I am not too fond of depending on the id for displayname, as a maintainer assumption would be that that is an implementation detail. What about:

Suggested change
const displayName = this.singlePublisher ? id : stackAsset.displayName;
const getDisplayNameForSinglePublishStep: (type: AssetType) => string = (type) => {
switch(type) {
case AssetType.FILE: return 'FileAsset(s)';
case AssetType.DOCKER_IMAGE: return 'DockerAsset(s)';
};
}
const displayName = this.singlePublisher ? getDisplayNameForSinglePublishStep(stackAsset.assetType) : stackAsset.displayName;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out. But switch-case seems a bit long since id uses ?:...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, FileAsset(s) was replaced by FileAsset_s_ :(

  CHANGED    pipelines/test/integ.newpipeline-single-publisher 3.847s
      Resources
[~] AWS::CodePipeline::Pipeline Pipeline9850B417
 └─ [~] Stages
     └─ @@ -121,7 +121,7 @@
        [ ]     "Name": "Synth_Output"
        [ ]   }
        [ ] ],
        [-] "Name": "FileAsset",
        [+] "Name": "FileAsset_s_",
        [ ] "RoleArn": {
        [ ]   "Fn::GetAtt": [
        [ ]     "PipelineCodeBuildActionRole226DB0CB",

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for pointing out. But switch-case seems a bit long since id uses ?:...

That might be, but it improves maintainability, since if you add a 3rd asset type, the switch code will stop compiling, while the other will happily assume that the new assets are just DockerAsset, and likely be a bug, unless someone finds all such places.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, FileAsset(s) was replaced by FileAsset_s_ :(

  CHANGED    pipelines/test/integ.newpipeline-single-publisher 3.847s
      Resources
[~] AWS::CodePipeline::Pipeline Pipeline9850B417
 └─ [~] Stages
     └─ @@ -121,7 +121,7 @@
        [ ]     "Name": "Synth_Output"
        [ ]   }
        [ ] ],
        [-] "Name": "FileAsset",
        [+] "Name": "FileAsset_s_",
        [ ] "RoleArn": {
        [ ]   "Fn::GetAtt": [
        [ ]     "PipelineCodeBuildActionRole226DB0CB",

Noooooooo, that is so disappointing. So what do you think we should do? Use FileAsset or say FileAssets (plural)? Which one is less confusing for a user?
An alternative is to make it dependent on the number of assets (e.g FileAsset when only one asset is present, and FileAssets when multiple)? I assume the last one is the least confusing, but needs 2 extra tests.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use FileAsset or say FileAssets (plural)?
Which one is less confusing for a user?

I'm unsure because I'm a Japanese speaker... (Japanese has no plurals forms)

Before #33844, the name of action is the id -- FileAsset or DeployAsset (singular).
(That's the reason I originally used id.)

If it keeps as singular form, users won't experience any unintended changes around pipelines when upgrading cdk from 2.186.0 or earlier.

Copy link
Contributor

@matboros matboros Jun 13, 2025

Choose a reason for hiding this comment

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

OK, lets just use plural, that is much more likely to be true.

PS. sorry for the slow answer, I was out for a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Fixed.

@Abogical
Copy link
Member

To add to my review, PR title should be renamed to state what the fix is, it shouldn't just be a copy of the bug title.

@Abogical Abogical changed the title fix(pipelines): action name FileAsset changed when publishAssetsInParallel is false fix(pipelines): use display name for Asset actions when publishAssetsInParallel is false May 28, 2025
@Tietew Tietew requested a review from matboros May 29, 2025 03:44
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 13, 2025
@mergify mergify bot dismissed matboros’s stale review June 13, 2025 09:58

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 0e7d62e
  • 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 Jun 13, 2025
Copy link
Contributor

@matboros matboros left a comment

Choose a reason for hiding this comment

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

lgtm

@mergify
Copy link
Contributor

mergify bot commented Jun 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 754ad50 into aws:main Jun 13, 2025
22 checks passed
@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 Jun 13, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 13, 2025
@Tietew Tietew deleted the pipelines-single-asset-action-name branch June 13, 2025 11:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug This issue is a bug. p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pipelines: action name FileAsset changed when publishAssetsInParallel is false

5 participants