Skip to content

Conversation

hwum
Copy link
Contributor

@hwum hwum commented Mar 18, 2025

Issue # (if applicable)

#33511

Reason for this change

Codepipeline launched this feature last years and still missed the update in cdk library.

Description of changes

Support this feature in L2 Construct:https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts-how-it-works-conditions.html

Describe any new or updated permissions being added

No

Description of how you validated changes

Unit test, integ test, and local cdk library deployment(linked to local cdkApp and successfully deploy it)

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 March 18, 2025 00:08
@github-actions github-actions bot added p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Mar 18, 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(codepipeline): L2 Construct for stage level condition feature feat(codepipeline): stage level condition feature L2 construct Mar 18, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 18, 2025 00:11

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

Copy link

codecov bot commented Mar 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.38%. Comparing base (6a5638a) to head (46745bb).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33809   +/-   ##
=======================================
  Coverage   82.38%   82.38%           
=======================================
  Files         120      120           
  Lines        6938     6938           
  Branches     1170     1170           
=======================================
  Hits         5716     5716           
  Misses       1119     1119           
  Partials      103      103           
Flag Coverage Δ
suite.unit 82.38% <ø> (ø)

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.38% <ø> (ø)
🚀 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.

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)

@aws-cdk-automation aws-cdk-automation dismissed their stale review March 18, 2025 21:17

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

@SimonCMoore SimonCMoore added p1 and removed p2 labels Mar 19, 2025
@hwum hwum force-pushed the dev branch 6 times, most recently from 5790787 to f85ce3b Compare March 19, 2025 21:52
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 19, 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.

Thank you, in general looks good to me. Left some minor feedbacks.

Comment on lines 27 to 29
public readonly beforeEntry?: Conditions;
public readonly onSuccess?: Conditions;
public readonly onFailure?: FailureConditions;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do they need to be public? Do you expect CDK users to be able to access these fields like

const pipeline = new CodePipeline(.....);

pipeline.beforeEntry

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Switch these to private

*
* @default - No configuration
*/
readonly configuration?: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to make the type more strict? I see that it's an json object, is there certain interface we can draft for the object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That Ideal one is a Map<any,any>, but it's kind of same as any. So I choose to match the CFN type

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO I think we should at least make this a Map/object since the CFN type is JSON.

*
* @default 'Rule'
*/
readonly category?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems that category only supports Rule for now. Do you expect that this will support more values in the future? I think we should make it a ENUM-like class type. https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md#enums

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. This one is fixed value applied for Rule

Comment on lines +143 to +140
ruleTypeId: {
provider: this._props.provider,
version: this._props.version,
category: 'Rule',
owner: 'AWS',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, I like how you flatten these in the props. Thanks!

ruleTypeId: {
provider: this._props.provider,
version: this._props.version,
category: 'Rule',
Copy link
Contributor

Choose a reason for hiding this comment

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

I see you're hardcoding Rule instead of using this.props.category. Should we not expose the property isntead then?

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 category in RuleProps should be deleted.

}));
// --

// eslint-disable-next-line no-console
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this plz


// eslint-disable-next-line no-console
console.log(Template.fromStack(stack).findResources('AWS::CodePipeline::Pipeline'));
// eslint-disable-next-line no-console
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

}));
// --

// eslint-disable-next-line no-console
Copy link
Contributor

Choose a reason for hiding this comment

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

same here


// eslint-disable-next-line no-console
console.log(Template.fromStack(stack).findResources('AWS::CodePipeline::Pipeline'));
// eslint-disable-next-line no-console
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Comment on lines +126 to +132
const awsApiCall1 = integrationTest.assertions.awsApiCall('CodePipeline', 'getPipeline', { name: 'my-pipeline-stage-test' });
awsApiCall1.assertAtPath('pipeline.name', ExpectedResult.stringLikeRegexp('my-pipeline-stage-test'));
awsApiCall1.assertAtPath('pipeline.stages.0.name', ExpectedResult.stringLikeRegexp('Source'));
awsApiCall1.assertAtPath('pipeline.stages.1.name', ExpectedResult.stringLikeRegexp('Lambda'));
awsApiCall1.assertAtPath('pipeline.stages.1.actions.0.name', ExpectedResult.stringLikeRegexp('Lambda'));
awsApiCall1.assertAtPath('pipeline.stages.1.onSuccess.conditions.0.result', ExpectedResult.stringLikeRegexp('FAIL'));
awsApiCall1.assertAtPath('pipeline.stages.1.onFailure.conditions.0.result', ExpectedResult.stringLikeRegexp('ROLLBACK'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, thanks for adding assertions to integ tests!

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

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 20, 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, just one more comment

*
* @default - No configuration
*/
readonly configuration?: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO I think we should at least make this a Map/object since the CFN type is JSON.

L2 Construct for stage level condition feature
@hwum
Copy link
Contributor Author

hwum commented Mar 21, 2025

LGTM, just one more comment
I'm following the same pattern here:https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-codepipeline/lib/action.ts#L143-L145
Since action config and rule config is same data structure in Codepipeline backend

@hwum hwum requested a review from GavinZZ March 21, 2025 18:04
@mergify mergify bot dismissed GavinZZ’s stale review March 21, 2025 18:05

Pull request has been modified.

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.

Thank you for the contribution and addressing the comments!

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 46745bb
  • 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 21, 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 8e4374f into aws:main Mar 21, 2025
21 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 21, 2025
@hwum hwum deleted the dev branch March 21, 2025 20:01
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.

4 participants