You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs(all): Fix docs and examples
Changes:
- fix markdown lint errors
- fix code examples to work
- upgrade contributing guide to use npm ci
- use simplified checks
* chore: fix comments
* fix(metrics): correct typedoc examples
* chore: remove until fully understood
* fix: allow for value to be Error or LogAttributes
* chore: include lerna-ci step in docs
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+20-16
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ Please read through this document before submitting any issues or pull requests
7
7
information to effectively respond to your bug report or contribution.
8
8
9
9
## Security issue notifications
10
+
10
11
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public GitHub issue.
11
12
12
13
## Reporting Bugs/Feature Requests
@@ -35,7 +36,7 @@ Contributions via pull requests are much appreciated. Before sending us a pull r
35
36
To send us a pull request, please follow these steps:
36
37
37
38
1. Fork the repository.
38
-
2. Install dependencies: `npm install`
39
+
2. Install dependencies: `npm ci; npm run lerna-ci`
39
40
3. Prepare utilities like commit hooks: `npm run init-environment`
40
41
4. Create a new branch to focus on the specific change you are contributing e.g. `git checkout -b improv/logger-debug-sampling`
41
42
5. Run all tests, and code baseline checks: `npm run test`
@@ -54,8 +55,9 @@ You might find useful to run both the documentation website and the API referenc
54
55
***Docs website**:
55
56
56
57
You can build and start a local docs website by running these two commands.
57
-
-`npm run docs-buildDockerImage` OR `docker build -t squidfunk/mkdocs-material ./docs/`
58
-
-`npm run docs-runLocalDocker` OR `docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material`
58
+
59
+
*`npm run docs-buildDockerImage` OR `docker build -t squidfunk/mkdocs-material ./docs/`
60
+
*`npm run docs-runLocalDocker` OR `docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material`
59
61
60
62
### Tests
61
63
@@ -67,12 +69,10 @@ Unit tests, under `tests/unit` folder are standard [Jest](https://jestjs.io) tes
67
69
68
70
End-to-end tests, under `tests/e2e` folder, will test the module features by deploying AWS Lambda functions into your AWS Account. We use [aws-cdk](https://docs.aws.amazon.com/cdk/v1/guide/getting_started.html) v1 library (not v2 due to [this cdk issue](https://github.com/aws/aws-cdk/issues/18211)) for Typescript for creating infrastructure, and [aws-sdk-js v2](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/) for invoking the functions and assert on the expected behaviors. All steps are also executed by Jest.
69
71
70
-
71
72
Running end-to-end tests will deploy AWS resources. You will need an AWS account and the tests might incur costs. 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/).
72
73
73
74
When contributing to this repository, these end-to-end tests are run by the maintainers before merging a PR.
74
75
75
-
76
76
**Unit tests**
77
77
78
78
**Write**
@@ -89,7 +89,8 @@ As mentioned before, tests are split into groups thanks to [jest-runner-groups](
89
89
90
90
**Run**
91
91
92
-
To run unit tests you can either use
92
+
To run unit tests you can either use
93
+
93
94
* npm task `lerna-test:unit` (`npm run lerna-test:unit`) in root folder to run them all
94
95
* npm task `test:e2e` (`npm run test:unit`) in module folder (for example: `packages/metrics`) to run the module specific one
95
96
* jest directly `npx jest --group=unit` in module folder to run the module specific one (You can run selective tests by restricting the group to the one you want. For instance `npx jest --group=unit/metrics/class`)
@@ -110,15 +111,16 @@ As mentioned in the previous section, tests are split into groups thanks to [jes
110
111
111
112
See `metrics/tests/e2e/decorator.test.ts` as an example.
112
113
113
-
114
114
**Run**
115
115
116
-
To run e2e tests you can either use
117
-
* npm task `lerna-test:e2e` (`npm run lerna-test:e2e`) in root folder
116
+
To run e2e tests you can either use
117
+
118
+
* npm task `lerna-test:e2e` (`npm run lerna-test:e2e`) in root folder
118
119
* npm task `test:e2e` (`npm run test:e2e`) in module folder (for example: `packages/metrics`) to run the module specific one
119
120
* jest directly `npx jest --group=e2e` in module folder. (You can run selective tests by restricting the group to the one you want. For instance `npx jest --group=e2e/metrics/decorator`)
120
121
121
122
Two important env variable can be used:
123
+
122
124
*`AWS_PROFILE` to use the right AWS credentials
123
125
*`DISABLE_TEARDOWN` if you don't want your stack to be destroyed at the end of the test (useful in dev mode when iterating over your code).
124
126
@@ -127,6 +129,7 @@ Example: `DISABLE_TEARDOWN=true AWS_PROFILE=dev-account npx jest --group=e2e/met
127
129
**Automate**
128
130
129
131
You can run the end-to-end tests automatically on your forked project by following these steps:
132
+
130
133
1. Create an IAM role in your target AWS account, with the least amount of privilege.
131
134
132
135
As mentioned above in this page, we are leveraging CDK to deploy and consequently clean-up resources on AWS. Therefore to run those tests through Github actions you will need to grant specific permissions to your workflow.
@@ -140,37 +143,38 @@ You can run the end-to-end tests automatically on your forked project by followi
*["Configure AWS Credentials" Action For GitHub Actions](https://github.com/aws-actions/configure-aws-credentials/)
148
+
145
149
2. Add your new role into your [Github fork secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) with name `AWS_ROLE_ARN_TO_ASSUME`.
146
150
3. In your forked repository, go to the "Actions" tabs, select the `run-e2e-tests` workflow.
147
151
4. In the run-e2e-tests workflow page, select "Run workflow" and run it on the desired branch.
148
152
149
153
> :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
154
151
-
152
155
### Examples
153
156
154
157
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
158
156
159
To test your updates with these examples you just have to:
157
160
158
161
1. Build your local version of *aws-lambda-powertools-typescript* npm packages with `npm run lerna-package`
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/).
177
+
174
178
### Conventions
175
179
176
180
Category | Convention
@@ -203,4 +207,4 @@ TODO
203
207
204
208
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
205
209
206
-
We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
210
+
We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
0 commit comments