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(codepipeline): GitPullRequestFilter for pipeline trigger #29128

Merged
merged 22 commits into from
May 13, 2024

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Feb 16, 2024

Issue # (if applicable)

Closes #29126.

Related PR: #29127
Perhaps if one merges, the other will cause a conflict.

Reason for this change

We would be good to trigger pipelines by git pull request filters.

Description of changes

Add gitPullRequestFilter parameter with new interface into GitConfiguration interface.

Description of how you validated changes

Both unit and integ tests.

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team February 16, 2024 06:06
@github-actions github-actions bot added feature-request A feature should be added or improved. p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Feb 16, 2024
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.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

Comment on lines 102 to 118
/**
* Event for trigger with pull request filter.
*/
export enum GitPullRequestEvent {
/**
* OPEN
*/
OPEN = 'OPEN',
/**
* UPDATED
*/
UPDATED = 'UPDATED',
/**
* CLOSED
*/
CLOSED = 'CLOSED',
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@github-actions github-actions bot added the effort/medium Medium work item – several days of effort label Feb 17, 2024
@go-to-k go-to-k marked this pull request as ready for review February 22, 2024 16:43
@go-to-k go-to-k changed the title feat(codepipeline): GitPullRequestFilter for pipeline trigger feat(codepipeline): gitPullRequestFilter for pipeline trigger Feb 22, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review February 22, 2024 16:46

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

@go-to-k go-to-k changed the title feat(codepipeline): gitPullRequestFilter for pipeline trigger feat(codepipeline): GitPullRequestFilter for pipeline trigger Feb 22, 2024
@go-to-k go-to-k marked this pull request as draft February 22, 2024 16:50
Comment on lines +209 to +214
if (pushFilter?.length && pullRequestFilter?.length) {
throw new Error(`cannot specify both pushFilter and pullRequestFilter for the trigger with sourceAction with name '${sourceAction.actionProperties.actionName}'`);
}
if (!pushFilter?.length && !pullRequestFilter?.length) {
throw new Error(`must specify either pushFilter or pullRequestFilter for the trigger with sourceAction with name '${sourceAction.actionProperties.actionName}'`);
}
Copy link
Contributor Author

@go-to-k go-to-k Feb 25, 2024

Choose a reason for hiding this comment

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

If there is no this validation, the error occurred in CFn.

The trigger configuration for the source action is not valid. Make sure to choose one trigger configuration for each source action.

Comment on lines 287 to 292
// set to all events if empty array or undefined because CloudFormation does not accept empty array and undefined
const events: string[] = filter.events?.length ? Array.from(new Set(filter.events)) : [
GitPullRequestEvent.OPEN,
GitPullRequestEvent.UPDATED,
GitPullRequestEvent.CLOSED,
];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The CDK code and CFn with events as an empty array or undefined will occur.

The trigger configuration for the source action is not valid. Make sure to choose one trigger configuration for each source action.

In addition, You must select at least one pull request event. is displayed in AWS console.

GavinZZ
GavinZZ previously approved these changes May 13, 2024
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.

As mentioned, going to approve and merge this PR again. We can always have follow-up PR to improve it.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 13, 2024
Copy link
Contributor

mergify bot commented May 13, 2024

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 dismissed GavinZZ’s stale review May 13, 2024 21:10

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: bdb348b
  • 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 May 13, 2024

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 5ce1b64 into aws:main May 13, 2024
11 checks passed
@go-to-k go-to-k deleted the pipeline-trigger-pull-request branch May 13, 2024 23:58
mergify bot pushed a commit that referenced this pull request Jun 3, 2024
…trigger (#29127)

### Issue # (if applicable)

Closes #29124

Related PR: #29128
Perhaps if one merges, the other will cause a conflict.

### Reason for this change

We would be good to trigger pipelines by GitPushFilter with branches and file paths.

- CFn docs
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitpushfilter.html
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitbranchfiltercriteria.html
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitfilepathfiltercriteria.html

### Description of changes

Add props:

- branchesExcludes
- branchesIncludes
- filePathsExcludes
- filePathsIncludes

### Description of how you validated changes

Both unit and integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
gracelu0 added a commit that referenced this pull request Jun 6, 2024
vdahlberg pushed a commit to vdahlberg/aws-cdk that referenced this pull request Jun 10, 2024
…trigger (aws#29127)

### Issue # (if applicable)

Closes aws#29124

Related PR: aws#29128
Perhaps if one merges, the other will cause a conflict.

### Reason for this change

We would be good to trigger pipelines by GitPushFilter with branches and file paths.

- CFn docs
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitpushfilter.html
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitbranchfiltercriteria.html
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitfilepathfiltercriteria.html

### Description of changes

Add props:

- branchesExcludes
- branchesIncludes
- filePathsExcludes
- filePathsIncludes

### Description of how you validated changes

Both unit and integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Leo10Gama pushed a commit to Leo10Gama/aws-cdk that referenced this pull request Jun 11, 2024
…trigger (aws#29127)

### Issue # (if applicable)

Closes aws#29124

Related PR: aws#29128
Perhaps if one merges, the other will cause a conflict.

### Reason for this change

We would be good to trigger pipelines by GitPushFilter with branches and file paths.

- CFn docs
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitpushfilter.html
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitbranchfiltercriteria.html
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitfilepathfiltercriteria.html

### Description of changes

Add props:

- branchesExcludes
- branchesIncludes
- filePathsExcludes
- filePathsIncludes

### Description of how you validated changes

Both unit and integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
mazyu36 pushed a commit to mazyu36/aws-cdk that referenced this pull request Jun 22, 2024
…trigger (aws#29127)

### Issue # (if applicable)

Closes aws#29124

Related PR: aws#29128
Perhaps if one merges, the other will cause a conflict.

### Reason for this change

We would be good to trigger pipelines by GitPushFilter with branches and file paths.

- CFn docs
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitpushfilter.html
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitbranchfiltercriteria.html
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-gitfilepathfiltercriteria.html

### Description of changes

Add props:

- branchesExcludes
- branchesIncludes
- filePathsExcludes
- filePathsIncludes

### Description of how you validated changes

Both unit and integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr-linter/do-not-close The PR linter will not close this PR while this label is present
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-codepipeline: add GitPullRequestFilter for pipeline trigger
6 participants