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

test(all): move e2e tests to cdk v2 #676

Merged
merged 2 commits into from Mar 23, 2022
Merged

test(all): move e2e tests to cdk v2 #676

merged 2 commits into from Mar 23, 2022

Conversation

flochaz
Copy link
Contributor

@flochaz flochaz commented Mar 21, 2022

Description of your changes

Move all end to end test to cdk v2.

Details

  1. bump cdk deps to 2.17.0
  2. replace all @aws-cdk deps to aws-cdk-lib
  3. Use @Tanemahuta implementation suggested here feat(cli): bundle dependencies aws/aws-cdk#18667 (comment) which simply rebuild the stackArtifact with the proper type.

[OUTDATED] Details

Thanks to @3p3r work and especially this line https://github.com/3p3r/cdk-web/blob/main/cdk-web.webpack.config.js#L132 I've been able to isolate the needed work around to aws/aws-cdk#18211 issue by duplicating CloudFormationDeployments class and rewrite isAssetManifestArtifact function to

function isAssetManifestArtifact(art: cxapi.CloudArtifact): art is cxapi.AssetManifestArtifact {
  return Object.keys(art).includes('file');
}

How to verify this change

https://github.com/awslabs/aws-lambda-powertools-typescript/actions/runs/2026670475

Related issues, RFCs

aws/aws-cdk#18211

PR status

Is this ready for review?: NO
Is it a breaking change?: NO

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding changes to the examples
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published in downstream module
  • The PR title follows the conventional commit semantics

Breaking change checklist

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions github-actions bot added the internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) label Mar 21, 2022
@flochaz flochaz force-pushed the chazalf/e2eTestCDKV2 branch 2 times, most recently from 9ad3353 to 8e71980 Compare March 22, 2022 06:21
@flochaz flochaz changed the title chore(all): move e2e tests to cdk v2 test(all): move e2e tests to cdk v2 Mar 22, 2022
@dreamorosi dreamorosi self-requested a review March 22, 2022 14:04
@dreamorosi dreamorosi added this to Pull Requests - Work in progress in Pull Requests via automation Mar 22, 2022
@dreamorosi dreamorosi added this to the production-ready-release milestone Mar 22, 2022
dreamorosi
dreamorosi previously approved these changes Mar 22, 2022
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

This is great @flochaz, super excited about this PR. It has been a long time coming :)

Copy link
Contributor

@saragerion saragerion left a comment

Choose a reason for hiding this comment

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

Thanks Florian for the PR!

Comment on lines 4 to 10
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/member-ordering */
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
/* eslint-disable @typescript-eslint/member-delimiter-style */
/* eslint-disable newline-before-return */
/* eslint-disable func-style */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: rather than adding this list of linting exceptions what about addressing opportunities for improving our linting rules in a separated space/issue?

Interesting article:
https://stackoverflow.blog/2020/07/20/linters-arent-in-your-way-theyre-on-your-side/

Copy link
Contributor

Choose a reason for hiding this comment

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

I went through these rules and I think they are fine as it is for global level.

This file is only exceptional since it's duplicated from an other project. I prefer to just disable lint in this file and keep it exactly as it is for ease of maintenance.

@@ -0,0 +1,223 @@
// This file is duplicating CloudFormationDeployments define in https://github.com/aws/aws-cdk/blob/master/packages/aws-cdk/lib/api/cloudformation-deployments.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: since a branch version's may mutate, referring to a commit rather than a branch will make sure the link will work in the future

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume that there is no change here? Do we do this to expose a private class?

@@ -0,0 +1,223 @@
// This file is duplicating CloudFormationDeployments define in https://github.com/aws/aws-cdk/blob/master/packages/aws-cdk/lib/api/cloudformation-deployments.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
// This file is duplicating CloudFormationDeployments define in https://github.com/aws/aws-cdk/blob/master/packages/aws-cdk/lib/api/cloudformation-deployments.ts
// This file is duplicating CloudFormationDeployments defined in https://github.com/aws/aws-cdk/blob/master/packages/aws-cdk/lib/api/cloudformation-deployments.ts

@@ -12,6 +12,7 @@
"inlineSourceMap": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"useUnknownInCatchVariables": false,
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the documentation:

This pattern ensures that error handling code becomes more comprehensive because you cannot guarantee that the object being thrown is a Error subclass ahead of time.

What is the benefit of this approach instead of explicitly checking the types of the Errors? Example:

    try {
      // something
    } catch (e: unknown) {
      if (err instanceof Error) {
          // something
      }
    }

Copy link
Contributor

@ijemmy ijemmy left a comment

Choose a reason for hiding this comment

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

Apart from Sara's comment, I'm ok with this change.

Duplicating a class to make it public concerns me on the maintenance effort.

But I think that this is a better option than calling subprocess.run('cdk'). We need to keep an eye on this and see how often it breaks. (vs. the effort to implement a robust call to cdk)

@@ -0,0 +1,223 @@
// This file is duplicating CloudFormationDeployments define in https://github.com/aws/aws-cdk/blob/master/packages/aws-cdk/lib/api/cloudformation-deployments.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume that there is no change here? Do we do this to expose a private class?

Comment on lines 4 to 10
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/member-ordering */
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
/* eslint-disable @typescript-eslint/member-delimiter-style */
/* eslint-disable newline-before-return */
/* eslint-disable func-style */
Copy link
Contributor

Choose a reason for hiding this comment

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

I went through these rules and I think they are fine as it is for global level.

This file is only exceptional since it's duplicated from an other project. I prefer to just disable lint in this file and keep it exactly as it is for ease of maintenance.

@flochaz
Copy link
Contributor Author

flochaz commented Mar 22, 2022

Moving to @Tanemahuta implementation suggested here aws/aws-cdk#18667 (comment) ... so much easier

Pull Requests automation moved this from Pull Requests - Work in progress to Pull Requests - Review needed Mar 22, 2022
@dreamorosi dreamorosi self-requested a review March 23, 2022 09:12
Copy link
Contributor

@ijemmy ijemmy left a comment

Choose a reason for hiding this comment

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

This is much nicer than the other version. The abstraction is very beautiful.

From what I see, the only risk is that the cx-api is changed (for synthesizing the stack artifact).
I doubt if they’ll change CloudFormationDeployments , SdkProvider , and DeployStackResult soon.

@@ -59,9 +59,9 @@
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"archiver": "^5.3.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still needed? I think it's used by cdk to create the asset archives but just checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed might not be needed. will merge that one to let @ijemmy work and give it a try through another PR

Pull Requests automation moved this from Pull Requests - Review needed to Pull Requests - Approved and ready to be merged Mar 23, 2022
@flochaz flochaz merged commit e2a9132 into main Mar 23, 2022
@flochaz flochaz deleted the chazalf/e2eTestCDKV2 branch March 23, 2022 09:41
Pull Requests automation moved this from Pull Requests - Approved and ready to be merged to Pull Requests - Merged or Closed Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)
Projects
No open projects
Pull Requests
Pull Requests - Merged or Closed
Development

Successfully merging this pull request may close these issues.

None yet

4 participants