Skip to content
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

fix(codebuild): fails on using PR Events together with FILE_PATH filters in a FilterGroup #9725

Merged
merged 8 commits into from
Aug 17, 2020
3 changes: 0 additions & 3 deletions packages/@aws-cdk/aws-codebuild/lib/source.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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