-
Notifications
You must be signed in to change notification settings - Fork 4k
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(codepipeline): allow creation of pipelines without source trigger #2332
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { expect, haveResource, haveResourceLike, SynthUtils } from '@aws-cdk/assert'; | ||
import { expect, haveResource, haveResourceLike, not, SynthUtils } from '@aws-cdk/assert'; | ||
import codebuild = require('@aws-cdk/aws-codebuild'); | ||
import codecommit = require('@aws-cdk/aws-codecommit'); | ||
import codepipeline = require('@aws-cdk/aws-codepipeline'); | ||
|
@@ -67,6 +67,124 @@ export = { | |
test.done(); | ||
}, | ||
|
||
'pipeline with GitHub source with poll trigger'(test: Test) { | ||
const stack = new Stack(); | ||
|
||
const secret = new CfnParameter(stack, 'GitHubToken', { type: 'String', default: 'my-token' }); | ||
|
||
const p = new codepipeline.Pipeline(stack, 'P'); | ||
|
||
p.addStage({ | ||
name: 'Source', | ||
actions: [ | ||
new cpactions.GitHubSourceAction({ | ||
actionName: 'GH', | ||
runOrder: 8, | ||
output: new codepipeline.Artifact('A'), | ||
branch: 'branch', | ||
oauthToken: SecretValue.plainText(secret.stringValue), | ||
owner: 'foo', | ||
repo: 'bar', | ||
trigger: cpactions.GitHubTrigger.Poll | ||
}), | ||
], | ||
}); | ||
|
||
p.addStage({ | ||
name: 'Two', | ||
actions: [ | ||
new cpactions.ManualApprovalAction({ actionName: 'Boo' }), | ||
], | ||
}); | ||
|
||
expect(stack).to(not(haveResourceLike('AWS::CodePipeline::Webhook'))); | ||
|
||
expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { | ||
"Stages": [ | ||
{ | ||
"Actions": [ | ||
{ | ||
"Configuration": { | ||
"PollForSourceChanges": true | ||
}, | ||
"Name": "GH" | ||
} | ||
], | ||
"Name": "Source" | ||
}, | ||
{ | ||
"Actions": [ | ||
{ | ||
"Name": "Boo", | ||
} | ||
], | ||
"Name": "Two" | ||
} | ||
] | ||
})); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you're using expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', {
"Stages": [
{
"Actions": [
{
"Name": "GH",
"Configuration": {
"PollForSourceChanges": true
},
}
],
"Name": "Source"
},
{
"Actions": [
{
"Name": "Boo"
}
],
"Name": "Two"
}
]
})); |
||
|
||
test.done(); | ||
}, | ||
|
||
'pipeline with GitHub source without triggers'(test: Test) { | ||
const stack = new Stack(); | ||
|
||
const secret = new CfnParameter(stack, 'GitHubToken', { type: 'String', default: 'my-token' }); | ||
|
||
const p = new codepipeline.Pipeline(stack, 'P'); | ||
|
||
p.addStage({ | ||
name: 'Source', | ||
actions: [ | ||
new cpactions.GitHubSourceAction({ | ||
actionName: 'GH', | ||
runOrder: 8, | ||
output: new codepipeline.Artifact('A'), | ||
branch: 'branch', | ||
oauthToken: SecretValue.plainText(secret.stringValue), | ||
owner: 'foo', | ||
repo: 'bar', | ||
trigger: cpactions.GitHubTrigger.None | ||
}), | ||
], | ||
}); | ||
|
||
p.addStage({ | ||
name: 'Two', | ||
actions: [ | ||
new cpactions.ManualApprovalAction({ actionName: 'Boo' }), | ||
], | ||
}); | ||
|
||
expect(stack).to(not(haveResourceLike('AWS::CodePipeline::Webhook'))); | ||
|
||
expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { | ||
"Stages": [ | ||
{ | ||
"Actions": [ | ||
{ | ||
"Configuration": { | ||
"PollForSourceChanges": false | ||
}, | ||
"Name": "GH" | ||
} | ||
], | ||
"Name": "Source" | ||
}, | ||
{ | ||
"Actions": [ | ||
{ | ||
"Name": "Boo", | ||
} | ||
], | ||
"Name": "Two" | ||
} | ||
] | ||
})); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here as above. |
||
|
||
test.done(); | ||
}, | ||
|
||
'github action uses ThirdParty owner'(test: Test) { | ||
const stack = new Stack(); | ||
|
||
|
@@ -96,6 +214,8 @@ export = { | |
], | ||
}); | ||
|
||
expect(stack).to(haveResourceLike('AWS::CodePipeline::Webhook')); | ||
|
||
expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { | ||
"ArtifactStore": { | ||
"Location": { | ||
|
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.
Leave the webhook comment (of course, adjust it to the current situation).