Skip to content

Commit 33d613b

Browse files
authored
chore(examples): integrate in CI flow with lint and build (#446)
1 parent 7ed72cb commit 33d613b

25 files changed

+7150
-17292
lines changed

Diff for: .github/workflows/run-e2e-tests.yml

+6
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ jobs:
2828
aws-region: eu-west-1
2929
- name: Run integration tests
3030
run: npm run lerna-test:e2e
31+
- name: Test packaging
32+
run: |
33+
npm run lerna-package
34+
cd examples/cdk
35+
npm install ../../packages/**/dist/aws-lambda-powertools-*
36+
npm run test

Diff for: CONTRIBUTING.md

+24
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,30 @@ You can run the end-to-end tests automatically on your forked project by followi
147147
4. In the run-e2e-tests workflow page, select "Run workflow" and run it on the desired branch.
148148

149149
> :warning: **Don't automatically run end-to-end tests on branch push or PRs**. A malicious attacker can submit a pull request to attack your AWS account. Ideally, use a blank account without any important workload/data, and limit `AWS_ROLE_ARN_TO_ASSUME` permission to least minimum privilege.
150+
151+
152+
### Examples
153+
154+
As part of the repo you will find an examples folder at the root. This folder contains examples (written with CDK for now) of deployable AWS Lambda functions using Powertools.
155+
156+
To test your updates with these examples you just have to:
157+
158+
1. Build your local version of *aws-lambda-powertools-typescript* npm packages with `npm run lerna-package`
159+
1. Update their references in examples
160+
```
161+
cd examples/cdk
162+
npm install ../../packages/**/dist/aws-lambda-powertools-*
163+
```
164+
1. Run cdk tests
165+
```
166+
npm run test
167+
```
168+
1. Deploy
169+
```
170+
npm run cdk deploy
171+
```
172+
173+
Previous command will deploy AWS resources therefore you will need an AWS account and it might incur in some costs which should be covered by the [AWS Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all). If you don't have an AWS Account follow [these instructions to create one](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/).
150174
### Conventions
151175
152176
Category | Convention

Diff for: examples/cdk/README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ This is a deployable CDK app that deploys AWS Lambda functions as part of a Clou
44

55
You will need to have a valid AWS Account in order to deploy these resources. These resources may incur costs to your AWS Account. The cost from **some services** are covered by the [AWS Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all) but not all of them. If you don't have an AWS Account follow [these instructions to create one](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/).
66

7-
The example functions, located in the `lib` folder, are invoked automatically, twice, when deployed using the CDK construct defined in `lib/example-function.ts`. The first invocation demonstrates the effect on logs/metrics/annotations when the Lambda function has a cold start, and the latter without a cold start.
7+
The example functions, located in the `src` folder, are invoked automatically, twice, when deployed using the CDK construct defined in `src/example-function.ts`. The first invocation demonstrates the effect on logs/metrics/annotations when the Lambda function has a cold start, and the latter without a cold start.
88

99
## Deploying the stack
1010

11-
* Ensure that CDK v2 is installed globally on your machine (if not, run `npm install -g aws-cdk`)
1211
* Navigate to this location of the repo in your terminal (`examples/cdk`)
1312
* `npm install`
14-
* `cdk deploy --all --profile <YOUR_AWS_PROFILE>`
13+
* `npm run cdk deploy --all --profile <YOUR_AWS_PROFILE>`
1514

1615
Note: Prior to deploying you may need to run `cdk bootstrap aws://<YOU_AWS_ACCOUNT_ID>/<AWS_REGION> --profile <YOUR_AWS_PROFILE>` if you have not already bootstrapped your account for CDK.
1716

Diff for: examples/cdk/bin/cdk-app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
import 'source-map-support/register';
33
import * as cdk from 'aws-cdk-lib';
4-
import { CdkAppStack } from '../lib/example-stack';
4+
import { CdkAppStack } from '../src/example-stack';
55

66
const app = new cdk.App();
77
new CdkAppStack(app, 'LambdaPowertoolsTypeScript-ExamplesCdkStack', {});

Diff for: examples/cdk/jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
testEnvironment: 'node',
3-
roots: ['<rootDir>/test'],
3+
roots: ['<rootDir>/tests'],
44
testMatch: ['**/*.test.ts'],
55
transform: {
66
'^.+\\.tsx?$': 'ts-jest'

0 commit comments

Comments
 (0)