aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

feat(codepipeline-actions): support commands action

Open go-to-k opened this issue 1 year ago • 3 comments

My TODO

  • Implementation
    • Errors in commands
      • zip: not a valid zip file for primary source
    • validation for multi-line formats
      • Verify the actual operation in console or CFn first
    • other validations
      • arrays etc...
        • outputVariables
        • files in OutputArtifact
  • unit tests
    • CommandsAction
      • can define with full props
        • with an output artifact with files
      • calling variable method
      • error tests
        • outputVariables in variable method
        • multi-line formats
    • tests in aws-codepipeline
      • artifacts.test.ts, etc...
  • integ tests and snapshots
  • README
    • how to use CommandsAction
    • how to use outputVariables
    • how to attach policies
      • new integ test?

Issue # (if applicable)

Closes #31666.

Reason for this change

AWS CodePipeline introduces new general purpose compute action: Commands action.

  • https://aws.amazon.com/about-aws/whats-new/2024/10/aws-codepipeline-general-purpose-compute-action/
  • https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-Commands.html#action-reference-Commands-type

This action can be used for both V1 and V2 pipeline types.

CFn docs:

  • https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-actiontypeid.html
  • https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-outputartifact.html
  • https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-actiondeclaration.html

Description of changes

Added CommandsAction class and changed other files.

The ActionCategory for this action is a new category Compute, so added ActionCategory.COMPUTE.

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

go-to-k avatar Oct 05 '24 17:10 go-to-k

The CodeBuild run under the CommandsAction. But I don't automatically add the permissions for source services with CODEBUILD_CLONE_REF (codeBuildCloneOutput=true).

https://github.com/aws/aws-cdk/blob/v2.161.0/packages/aws-cdk-lib/aws-codepipeline-actions/lib/codebuild/build-action.ts#L189-L211

https://github.com/aws/aws-cdk/blob/v2.161.0/packages/aws-cdk-lib/aws-codepipeline-actions/lib/codestar-connections/source-action.ts#L158-L159

Because an error occurred in the CommandsAction with CODEBUILD_CLONE_REF.

clone-ref

go-to-k avatar Oct 05 '24 17:10 go-to-k

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 80.83%. Comparing base (873233b) to head (bfaa773).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #31667   +/-   ##
=======================================
  Coverage   80.83%   80.83%           
=======================================
  Files         236      236           
  Lines       14251    14251           
  Branches     2490     2490           
=======================================
  Hits        11520    11520           
  Misses       2446     2446           
  Partials      285      285           
Flag Coverage Δ
suite.unit 80.83% <ø> (ø)

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

Components Coverage Δ
packages/aws-cdk 79.56% <ø> (ø)
packages/aws-cdk-lib/core 82.20% <ø> (ø)

codecov[bot] avatar Feb 07 '25 04:02 codecov[bot]

@GavinZZ

I am not sure if the document has changed since I saw it or if I was mistaken, but I have changed the policies to match the document.

https://github.com/aws/aws-cdk/pull/31667/commits/8b8c5d7c17bf7864819309ee7be7f64580024071

ref-1: https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-Commands.html#action-reference-Commands-policy

ref-2: https://docs.aws.amazon.com/codepipeline/latest/userguide/security-iam-permissions-console-logs.html

Also, the integ test was slightly modified.

go-to-k avatar Feb 07 '25 07:02 go-to-k

~~I'm investigating the CI failure because it creates differences in snapshots.~~

It seems to have been fixed after full build with the latest commit in main branch, soI will run CI again.

go-to-k avatar Feb 07 '25 09:02 go-to-k

@GavinZZ CI has succeeded. Could you please check it again?

go-to-k avatar Feb 07 '25 12:02 go-to-k

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[bot] avatar Feb 07 '25 19:02 mergify[bot]

AWS CodeBuild CI Report

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

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

aws-cdk-automation avatar Feb 07 '25 20:02 aws-cdk-automation

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[bot] avatar Feb 07 '25 20:02 mergify[bot]

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[bot] avatar Feb 07 '25 20:02 github-actions[bot]