Skip to content

[feat] Import examples from aws-samples/aws-lambda-powertools-examples - #1051

Merged
msailes merged 31 commits into
aws-powertools:masterfrom
scottgerring:import-examples
Feb 22, 2023
Merged

[feat] Import examples from aws-samples/aws-lambda-powertools-examples#1051
msailes merged 31 commits into
aws-powertools:masterfrom
scottgerring:import-examples

Conversation

@scottgerring

@scottgerring scottgerring commented Feb 15, 2023

Copy link
Copy Markdown
Contributor

Issue #, if available:
#1050

Description of changes:

Moving the samples from https://github.com/aws-samples/aws-lambda-powertools-examples into the repository. This will help make the samples more discoverable, allow us to keep them up-to-date with the powertools themselves, and follow the pattern established by the python powertools.

Checklist

Detailed Description

The code is lifted verbatim from the old repository. I've tied it all together into one big maven build tree, and introduced an intermediate pom in the examples project. This has included some effort to restructure the examples themselves so they match the general maven project structure.

Breaking change checklist

RFC issue #:

  • Migration process documented
  • Implement 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.

Comment thread README.md Outdated
Comment thread examples/pom.xml
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Introducing an intermediate parent pom to aggregate the samples together

@@ -0,0 +1,138 @@
# CoreUtilities

@scottgerring scottgerring Feb 15, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These and the rest of the concrete samples have simply been lifted from main from the linked samples repository.

https://github.com/aws-samples/aws-lambda-powertools-examples

Comment thread .github/workflows/build.yml
Comment thread pom.xml
<module>powertools-cloudformation</module>
<module>powertools-idempotency</module>
<module>powertools-idempotency</module>
<module>examples</module>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Discussion point: do we want the samples to be build as part of the main project reactor here?
It makes the build easier, and we can simply choose not to release the examples project.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the build time? Does it have any side effects?
If there are no issues with mentioned above questions, I believe that it's good to have it built as a part of build process to have quick feedback when some changes are done in the project (version of PowerTools used in examples might be an issue here...)

@scottgerring scottgerring Feb 15, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Build time: +approx 45s, 3:30 up from 2:44

The only other side-effect I can see is that changes to the powertools that break the examples will have to fix the examples, but I'd say that is desirable!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, that would be desirable, we'd have a mechanism to keep the samples up to date.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

Comment thread spotbugs-exclude.xml
<Class name="software.amazon.lambda.powertools.logging.internal.LambdaLoggingAspect"/>
<Method name="setLogLevelBasedOnSamplingRate"/>
</Match>
<Match>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Spotbugs wasn't run on the examples previously. This lint comes from the original projects and I have not yet corrected it.

Comment thread examples/powertools-examples-sqs/src/main/java/org/demo/sqs/SqsMessageSender.java Outdated
Comment thread examples/powertools-examples-sqs/src/main/java/org/demo/sqs/SqsPoller.java Outdated
Comment thread pom.xml
<id>build-with-spotbugs</id>
<activation>
<activeByDefault>true</activeByDefault>
<activeByDefault>false</activeByDefault>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've turned this off by default, as it 1/ helps with the SAM tooling for the examples and 2/ speeds up local builds that haven't opted into it.

The github workflows explicitly activate and de-activate these using the profiles, so it has no impact on CI.

Comment thread .github/workflows/build.yml Outdated
Comment thread .github/workflows/build.yml Outdated
Comment thread .github/workflows/build.yml Outdated
Comment thread pom.xml Outdated

@jeromevdl jeromevdl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the example poms have the examples/pom.xml as parent or the lambda-powertools root pom?

(See my other comments)

@scottgerring

Copy link
Copy Markdown
Contributor Author

Should the example poms have the examples/pom.xml as parent or the lambda-powertools root pom?

(See my other comments)

yes - silly mistake - some were, some weren't. fixed.

@kozub

kozub commented Feb 21, 2023

Copy link
Copy Markdown
Contributor

Looks good to me.

One minor suggestion:

I think that we might change names of 2 examples packages in theirs pom.xml to have it more consistent.

Right now when we run all tests it produces logs (please ignore info about failing test):

[INFO] Reactor Summary for AWS Lambda Powertools for Java library Parent 1.14.0:
[INFO]
[INFO] AWS Lambda Powertools for Java library Parent ...... SUCCESS [  0.311 s]
[INFO] AWS Lambda Powertools for Java library Core ........ SUCCESS [  2.522 s]
[INFO] AWS Lambda Powertools for Java library Serialization Utilities SUCCESS [  2.596 s]
[INFO] AWS Lambda Powertools for Java library Logging ..... SUCCESS [  3.538 s]
[INFO] AWS Lambda Powertools for Java library Tracing ..... SUCCESS [  2.695 s]
[INFO] AWS Lambda Powertools for Java library SQS ......... SUCCESS [  2.864 s]
[INFO] AWS Lambda Powertools for Java library Metrics ..... SUCCESS [  2.440 s]
[INFO] AWS Lambda Powertools for Java library Parameters .. SUCCESS [  3.165 s]
[INFO] AWS Lambda Powertools for Java validation library .. SUCCESS [  3.167 s]
[INFO] AWS Lambda Powertools for Java library Test Suite .. SUCCESS [  2.547 s]
[INFO] AWS Lambda Powertools for Java library Cloudformation SUCCESS [  2.086 s]
[INFO] AWS Lambda Powertools for Java library Idempotency . SUCCESS [  4.064 s]
[INFO] AWS Lambda Powertools for Java library Examples .... SUCCESS [  0.004 s]
[INFO] A sample Hello World created for SAM CLI using powertools core utilities SUCCESS [  3.381 s]
[INFO] A sample Hello World using powertools idempotency .. FAILURE [  8.181 s]
[INFO] Sample app demoing parameters utility of Powertools. SKIPPED
[INFO] Sample app demoing serialization utility of Powertools. SKIPPED
[INFO] Sample app demoing SQS Batch Processing utility of Powertools. SKIPPED
[INFO] Sample app demoing validation utility of Powertools. SKIPPED

@scottgerring

Copy link
Copy Markdown
Contributor Author

Looks good to me.

One minor suggestion:

I think that we might change names of 2 examples packages in theirs pom.xml to have it more consistent.

Right now when we run all tests it produces logs (please ignore info about failing test):

[INFO] Reactor Summary for AWS Lambda Powertools for Java library Parent 1.14.0:
[INFO]
[INFO] AWS Lambda Powertools for Java library Parent ...... SUCCESS [  0.311 s]
[INFO] AWS Lambda Powertools for Java library Core ........ SUCCESS [  2.522 s]
[INFO] AWS Lambda Powertools for Java library Serialization Utilities SUCCESS [  2.596 s]
[INFO] AWS Lambda Powertools for Java library Logging ..... SUCCESS [  3.538 s]
[INFO] AWS Lambda Powertools for Java library Tracing ..... SUCCESS [  2.695 s]
[INFO] AWS Lambda Powertools for Java library SQS ......... SUCCESS [  2.864 s]
[INFO] AWS Lambda Powertools for Java library Metrics ..... SUCCESS [  2.440 s]
[INFO] AWS Lambda Powertools for Java library Parameters .. SUCCESS [  3.165 s]
[INFO] AWS Lambda Powertools for Java validation library .. SUCCESS [  3.167 s]
[INFO] AWS Lambda Powertools for Java library Test Suite .. SUCCESS [  2.547 s]
[INFO] AWS Lambda Powertools for Java library Cloudformation SUCCESS [  2.086 s]
[INFO] AWS Lambda Powertools for Java library Idempotency . SUCCESS [  4.064 s]
[INFO] AWS Lambda Powertools for Java library Examples .... SUCCESS [  0.004 s]
[INFO] A sample Hello World created for SAM CLI using powertools core utilities SUCCESS [  3.381 s]
[INFO] A sample Hello World using powertools idempotency .. FAILURE [  8.181 s]
[INFO] Sample app demoing parameters utility of Powertools. SKIPPED
[INFO] Sample app demoing serialization utility of Powertools. SKIPPED
[INFO] Sample app demoing SQS Batch Processing utility of Powertools. SKIPPED
[INFO] Sample app demoing validation utility of Powertools. SKIPPED

I've changed the example project names to match the general format, and i've put a publish exclusion on them so they don't end up in maven central.

jeromevdl
jeromevdl previously approved these changes Feb 21, 2023
@scottgerring scottgerring changed the title [feat: In Progress] Import examples from aws-samples/aws-lambda-powertools-examples [feat] Import examples from aws-samples/aws-lambda-powertools-examples Feb 21, 2023
@scottgerring

Copy link
Copy Markdown
Contributor Author

Created change in aws-samples/aws-lambda-powertools-examples/pull/296 to forward viewers onto the samples here.

@jeromevdl jeromevdl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good for me

@msailes
msailes merged commit 33fe108 into aws-powertools:master Feb 22, 2023
@scottgerring
scottgerring deleted the import-examples branch February 27, 2023 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants