Skip to content

Commit

Permalink
fix(codebuild): fails on using PR Events together with FILE_PATH filt…
Browse files Browse the repository at this point in the history
…ers in a FilterGroup (#9725)

Remove blocking validation on GitHub webhook file path filter when `event` is `PUSH` only.

Fixes #8867

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
JaseKirby committed Aug 17, 2020
1 parent 84a3ef6 commit fdaf6bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 0 additions & 3 deletions packages/@aws-cdk/aws-codebuild/lib/source.ts
Expand Up @@ -407,9 +407,6 @@ export class FilterGroup {
}

private addFilePathFilter(pattern: string, include: boolean): FilterGroup {
if (this.actions.size !== 1 || !this.actions.has(EventAction.PUSH)) {
throw new Error('A file path condition cannot be added if a Group contains any event action other than PUSH');
}
return this.addFilter(FILE_PATH_WEBHOOK_COND, pattern, include);
}

Expand Down
12 changes: 5 additions & 7 deletions packages/@aws-cdk/aws-codebuild/test/test.codebuild.ts
Expand Up @@ -1631,13 +1631,11 @@ export = {
test.done();
},

'cannot have file path conditions if the Group contains any action other than PUSH'(test: Test) {
const filterGroup = codebuild.FilterGroup.inEventOf(codebuild.EventAction.PULL_REQUEST_CREATED,
codebuild.EventAction.PUSH);

test.throws(() => {
filterGroup.andFilePathIsNot('.*\\.java');
}, /A file path condition cannot be added if a Group contains any event action other than PUSH/);
'can have FILE_PATH filters if the Group contains PUSH and PR_CREATED events'(test: Test) {
codebuild.FilterGroup.inEventOf(
codebuild.EventAction.PULL_REQUEST_CREATED,
codebuild.EventAction.PUSH)
.andFilePathIsNot('.*\\.java');

test.done();
},
Expand Down

0 comments on commit fdaf6bc

Please sign in to comment.