-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(codebuild): add filter groups feature for GitHub, GitHubEnterpri… #2319
Conversation
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.
A few questions for me to better understand how this functionality works.
/** | ||
* A list of lists of WebhookFilter objects used to determine which webhook events are triggered. | ||
*/ | ||
readonly filterGroups?: WebhookFilter[][]; |
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.
Why a list of lists? What are the semantics here?
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.
It's an OR operation between different lists and an AND operation inside the list.
For example, if I have filter groups [[A,B],[C,D]]
, build will only be triggered if (A&B)|(C&D)
], | ||
}) | ||
}); | ||
}, Error, "filterGroups property could only be set when webhook property is true"); |
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 would actually change this behavior. I think if filterGroups
was specified, and webhook
was not, I think webhook
should default to true
. Only specifying filterGroups
and webhook: false
should result in an exception.
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.
I'm thinking it in a different way. If customers want to remove filter groups but keep webhook enabled, they don't need to add webhook: true
which is a cognitive load for customers.
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.
Right. So when a dilemma like this happens, I like to compare the number of customers in each case. Here, you have every single person who wants to use filter groups, vs. a group that first uses filter groups, and then stops using them. It's pretty clear that the first group is larger (as the second group is a subset of the first one), so I think it makes more sense to optimize the experience for the larger group.
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 think we should follow the principle of least astonishment here. Customers won't be surprised to see an error if they specify filterGroups but don't specify webhook. However, they will feel surprised and confused when removing filterGroups causes their webhook being deleted. Could you please give me an example of somewhere else doing this kind of override behavior to help me better understand this case? I couldn't think of any at this moment.
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.
Could you please give me an example of somewhere else doing this kind of override behavior to help me better understand this case? I couldn't think of any at this moment.
Sure. As an example, in CodeDeploy's ServerDeploymentGroup
, we change the value of the rollback alarm configuration depending on whether the customer has provided any alarms (see here and here).
* Filter types for webhook filters | ||
*/ | ||
export enum WebhookFilterType { | ||
Event = 'EVENT', |
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.
What does Event
exactly mean? Are there some limits to what can pattern
be when type
is Event
? If so, I think we might be missing a modeling opportunity here...
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.
Different from other types, pattern for Event
could only be one or more actions concatenated with ,
. I couldn't think of a good model to model this behavior. Please let me know if you have some idea in mind.
Hey @Kaixiang-AWS , I've uploaded my proposal on how I see this API. The usage looks like as follows: new codebuild.Project(stack, 'Project', {
source: new codebuild.BitBucketSource({
// ...
filterGroups: [
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PUSH).andBranchIs('master'),
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PULL_REQUEST_CREATED).andBaseBranchIs('master'),
],
})
}); I'm curious what you think of doing it this way. Let me know! Thanks, |
a729a89
to
5a67cb0
Compare
Updated with the proposed final version, let me know what you think @Kaixiang-AWS ! |
…se and BitBucket Fixes aws#1842
Rebased on top of |
LGTM. |
…se and BitBucket
Fixes #1842
Pull Request Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.