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

feat(codebuild): add filter groups feature for GitHub, GitHubEnterpri… #2319

Merged
merged 2 commits into from
May 2, 2019

Conversation

Kaixiang-AWS
Copy link
Contributor

@Kaixiang-AWS Kaixiang-AWS commented Apr 18, 2019

…se and BitBucket

Fixes #1842


Pull Request Checklist

  • Testing
    • Unit test added (prefer not to modify an existing test, otherwise, it's probably a breaking change)
    • CLI change?: coordinate update of integration tests with team
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
  • Title and Description
    • Change type: title prefixed with fix, feat will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

Copy link
Contributor

@skinny85 skinny85 left a 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[][];
Copy link
Contributor

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?

Copy link
Contributor Author

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");
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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',
Copy link
Contributor

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...

Copy link
Contributor Author

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.

Refs:
filterGroups API ref
filterGroups user guide

@skinny85
Copy link
Contributor

skinny85 commented May 1, 2019

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,
Adam

@skinny85 skinny85 force-pushed the filter-groups branch 2 times, most recently from a729a89 to 5a67cb0 Compare May 2, 2019 00:22
@skinny85
Copy link
Contributor

skinny85 commented May 2, 2019

Updated with the proposed final version, let me know what you think @Kaixiang-AWS !

@skinny85
Copy link
Contributor

skinny85 commented May 2, 2019

Rebased on top of 0.30.0.

@Kaixiang-AWS
Copy link
Contributor Author

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to set FilterGroups for Build Triggers in CodeBuild Project
2 participants