Skip to content

Commit

Permalink
fix(pipelines): CodeBuild projects are hard to tell apart (aws#18492)
Browse files Browse the repository at this point in the history
CDK Pipelines generates a number of CodeBuild projects, and they
are hard to tell apart some times.

Add `Description` fields to each of them.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored Jan 21, 2022
1 parent 525ac07 commit f6dab8d
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export class CodeBuildFactory implements ICodePipelineActionFactory {

const project = new codebuild.PipelineProject(projectScope, this.constructId, {
projectName: this.props.projectName,
description: `Pipeline step ${options.pipeline.pipeline.pipelineName}/${stage.stageName}/${actionName}`,
environment,
vpc: projectOptions.vpc,
subnetSelection: projectOptions.subnetSelection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ test('additionalinputs creates the right commands', () => {
});
});

test('CodeBuild projects have a description', () => {
new cdkp.CodePipeline(pipelineStack, 'Pipeline', {
synth: new cdkp.CodeBuildStep('Synth', {
commands: ['/bin/true'],
input: cdkp.CodePipelineSource.gitHub('test/test', 'main'),
}),
});

// THEN
Template.fromStack(pipelineStack).hasResourceProperties(
'AWS::CodeBuild::Project',
{
Description: {
'Fn::Join': [
'',
['Pipeline step ', { Ref: 'Pipeline9850B417' }, '/Build/Synth'],
],
},
},
);
});

test('long duration steps are supported', () => {
// WHEN
new cdkp.CodePipeline(pipelineStack, 'Pipeline', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,18 @@
"Cache": {
"Type": "NO_CACHE"
},
"Description": {
"Fn::Join": [
"",
[
"Pipeline step ",
{
"Ref": "Pipeline9850B417"
},
"/Build/Synth"
]
]
},
"EncryptionKey": "alias/aws/s3",
"VpcConfig": {
"SecurityGroupIds": [
Expand Down Expand Up @@ -1942,6 +1954,18 @@
"Cache": {
"Type": "NO_CACHE"
},
"Description": {
"Fn::Join": [
"",
[
"Pipeline step ",
{
"Ref": "Pipeline9850B417"
},
"/UpdatePipeline/SelfMutate"
]
]
},
"EncryptionKey": "alias/aws/s3",
"VpcConfig": {
"SecurityGroupIds": [
Expand Down Expand Up @@ -2284,6 +2308,18 @@
"Cache": {
"Type": "NO_CACHE"
},
"Description": {
"Fn::Join": [
"",
[
"Pipeline step ",
{
"Ref": "Pipeline9850B417"
},
"/Assets/FileAsset1"
]
]
},
"EncryptionKey": "alias/aws/s3",
"VpcConfig": {
"SecurityGroupIds": [
Expand Down Expand Up @@ -2385,6 +2421,18 @@
"Cache": {
"Type": "NO_CACHE"
},
"Description": {
"Fn::Join": [
"",
[
"Pipeline step ",
{
"Ref": "Pipeline9850B417"
},
"/Assets/FileAsset2"
]
]
},
"EncryptionKey": "alias/aws/s3",
"VpcConfig": {
"SecurityGroupIds": [
Expand Down
24 changes: 24 additions & 0 deletions packages/@aws-cdk/pipelines/test/integ.newpipeline.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,18 @@
"Cache": {
"Type": "NO_CACHE"
},
"Description": {
"Fn::Join": [
"",
[
"Pipeline step ",
{
"Ref": "Pipeline9850B417"
},
"/Build/Synth"
]
]
},
"EncryptionKey": "alias/aws/s3"
}
},
Expand Down Expand Up @@ -2335,6 +2347,18 @@
"Cache": {
"Type": "NO_CACHE"
},
"Description": {
"Fn::Join": [
"",
[
"Pipeline step ",
{
"Ref": "Pipeline9850B417"
},
"/UpdatePipeline/SelfMutate"
]
]
},
"EncryptionKey": "alias/aws/s3"
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/pipelines/test/testhelpers/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StringLike extends Matcher {

public test(actual: any): MatchResult {
if (typeof(actual) !== 'string') {
throw new Error(`Expected string but found ${typeof(actual)}`);
throw new Error(`Expected string but found ${typeof(actual)} ${JSON.stringify(actual)}`);
}
const re = new RegExp(`^${this.pattern.split('*').map(escapeRegex).join('.*')}$`);

Expand Down

0 comments on commit f6dab8d

Please sign in to comment.