Skip to content

feat(codepipeline): branches and files support in git push filter L2 construct #33872

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

Merged
merged 3 commits into from
Mar 26, 2025

Conversation

hwum
Copy link
Contributor

@hwum hwum commented Mar 22, 2025

branches and files in git push filter in codepipeline L2 construct

Refer to the README content of reverted pr:(https://github.com/aws/aws-cdk/pull/30462/files). Credit to @go-to-k

Issue # 31009(#31009)

Reason for this change

Branches and files in git push filter under codepipeline trigger has been supported last year, and cdk library didn't support this feature yet.

Description of changes

Support ranches and files in git push filter under codepipeline trigger.

Describe any new or updated permissions being added

No

Description of how you validated changes

Unit test/Integ test/ local deployment

Checklist


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

@github-actions github-actions bot added the p2 label Mar 22, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 22, 2025 02:22
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Mar 22, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@hwum hwum changed the title feat(aws-codepipeline)branches and files in git push filter in codepipeline L2 construct feat(aws-codepipeline):branches and files in git push filter in codepipeline L2 construct Mar 22, 2025
Copy link

codecov bot commented Mar 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.35%. Comparing base (b855978) to head (f3f11e3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33872   +/-   ##
=======================================
  Coverage   82.35%   82.35%           
=======================================
  Files         120      120           
  Lines        6941     6941           
  Branches     1172     1172           
=======================================
  Hits         5716     5716           
  Misses       1120     1120           
  Partials      105      105           
Flag Coverage Δ
suite.unit 82.35% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 82.35% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hwum hwum changed the title feat(aws-codepipeline):branches and files in git push filter in codepipeline L2 construct feat(codepipeline): branches and files support in git push filter L2 construct Mar 24, 2025
@hwum hwum requested a review from aws-cdk-automation March 24, 2025 02:25
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 24, 2025 02:27

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Mar 24, 2025
@SimonCMoore SimonCMoore added p1 and removed p2 labels Mar 24, 2025
@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Mar 24, 2025
@QuantumNeuralCoder QuantumNeuralCoder self-assigned this Mar 24, 2025
Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, mostly minor comments.

@@ -36,7 +36,21 @@ export interface GitPushFilter {
/**
* Git pull request filter for trigger.
*/
export interface GitPullRequestFilter {
export interface GitPullRequestFilter extends GitFilter{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export interface GitPullRequestFilter extends GitFilter{
export interface GitPullRequestFilter extends GitFilter {

}
}

function ValidateGitPushFilter(pushFilter: GitPushFilter[], actionName: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function ValidateGitPushFilter(pushFilter: GitPushFilter[], actionName: string) {
function validateGitPushFilter(pushFilter: GitPushFilter[], actionName: string) {

if (!pushFilter?.length && !pullRequestFilter?.length) {
throw new UnscopedValidationError(`must specify either GitPushFilter or GitPullRequestFilter for the trigger with sourceAction with name '${sourceAction.actionProperties.actionName}'`);
}
if (pushFilter!== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (pushFilter!== undefined) {
if (pushFilter !== undefined) {

if (pushFilter!== undefined) {
ValidateGitPushFilter(pushFilter, sourceAction.actionProperties.actionName);
}
if (pullRequestFilter!== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (pullRequestFilter!== undefined) {
if (pullRequestFilter !== undefined) {

});
}

function validateGitPullRequestFilter(pullRequestFilter: GitPullRequestFilter[], actionName: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not specific to this line but all the new lines added in this file.

It's really hard to review the validation logics to make sure we don't accidentally introduce breaking change. I appreciate the fact that we're doing synthesis validation to early error out. Curious if there is a way that we can simplify some of the validations and leave it to CFN deployment time?

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 doing this since I found some ambiguous error msg from codepipeline backend during running integ tests, I believe it will make customer confused. I didn't add any validation check with clear error msg from cp backend.
For the avoiding breaking change, I think the current integ test was working will cover that part.
I'll aslo work on some improvement in our backend part as well

}

private getTagsFilterProperty(filter: GitPushFilter) : CfnPipeline.GitTagFilterCriteriaProperty | undefined {
return filter.tagsExcludes?.length || filter.tagsIncludes?.length ?{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return filter.tagsExcludes?.length || filter.tagsIncludes?.length ?{
return filter.tagsExcludes?.length || filter.tagsIncludes?.length ? {

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 25, 2025
@mergify mergify bot dismissed GavinZZ’s stale review March 25, 2025 19:52

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 25, 2025
GavinZZ
GavinZZ previously approved these changes Mar 25, 2025

/**
* Git push filter for trigger.
*/
export interface GitPushFilter {
export interface GitPushFilter extends GitFilter{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export interface GitPushFilter extends GitFilter{
export interface GitPushFilter extends GitFilter {

@mergify mergify bot dismissed GavinZZ’s stale review March 25, 2025 23:16

Pull request has been modified.

Copy link
Contributor

mergify bot commented Mar 25, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: f3f11e3
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented Mar 26, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 45623d6 into aws:main Mar 26, 2025
20 checks passed
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2025
@hwum hwum deleted the dev branch March 26, 2025 01:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p1 pr/needs-maintainer-review This PR needs a review from a Core Team Member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants