-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(pipelines): use display name for Asset actions when publishAssetsInParallel is false
#34049
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| 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; |
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.
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:
| 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; |
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.
Thanks for pointing out. But switch-case seems a bit long since id uses ?:...
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.
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",
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.
Thanks for pointing out. But
switch-caseseems a bit long sinceiduses?:...
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.
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.
Unfortunately,
FileAsset(s)was replaced byFileAsset_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?
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.
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.
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.
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.
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.
Ok. Fixed.
...s/@aws-cdk-testing/framework-integ/test/pipelines/test/integ.newpipeline-single-publisher.ts
Outdated
Show resolved
Hide resolved
|
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. |
FileAsset changed when publishAssetsInParallel is falseAsset actions when publishAssetsInParallel is false
packages/aws-cdk-lib/pipelines/lib/helpers-internal/pipeline-graph.ts
Outdated
Show resolved
Hide resolved
packages/aws-cdk-lib/pipelines/lib/helpers-internal/pipeline-graph.ts
Outdated
Show resolved
Hide resolved
packages/aws-cdk-lib/pipelines/test/codepipeline/codepipeline.test.ts
Outdated
Show resolved
Hide resolved
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
matboros
left 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.
lgtm
|
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). |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #34042.
Reason for this change
The action name in
Assetsstage has been changed fromFileAssetNto the display name of the asset in #33844.When pipeline's
publishAssetsInParallelis false, the action name is also changed to the display name of the first asset in stages instead ofFileAsset.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
singlePublisheris true (pipeline'spublishAssetsInParallelis false), instead ofstackAsset.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