Skip to content

Commit 524c268

Browse files
docs(all): Fix docs and examples (aws-powertools#472)
* 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
1 parent cf6af25 commit 524c268

File tree

11 files changed

+194
-202
lines changed

11 files changed

+194
-202
lines changed

Diff for: CONTRIBUTING.md

+20-16
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Please read through this document before submitting any issues or pull requests
77
information to effectively respond to your bug report or contribution.
88

99
## Security issue notifications
10+
1011
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.
1112

1213
## Reporting Bugs/Feature Requests
@@ -35,7 +36,7 @@ Contributions via pull requests are much appreciated. Before sending us a pull r
3536
To send us a pull request, please follow these steps:
3637

3738
1. Fork the repository.
38-
2. Install dependencies: `npm install`
39+
2. Install dependencies: `npm ci; npm run lerna-ci`
3940
3. Prepare utilities like commit hooks: `npm run init-environment`
4041
4. Create a new branch to focus on the specific change you are contributing e.g. `git checkout -b improv/logger-debug-sampling`
4142
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
5455
* **Docs website**:
5556

5657
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`
5961

6062
### Tests
6163

@@ -67,12 +69,10 @@ Unit tests, under `tests/unit` folder are standard [Jest](https://jestjs.io) tes
6769

6870
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.
6971

70-
7172
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/).
7273

7374
When contributing to this repository, these end-to-end tests are run by the maintainers before merging a PR.
7475

75-
7676
**Unit tests**
7777

7878
**Write**
@@ -89,7 +89,8 @@ As mentioned before, tests are split into groups thanks to [jest-runner-groups](
8989

9090
**Run**
9191

92-
To run unit tests you can either use
92+
To run unit tests you can either use
93+
9394
* npm task `lerna-test:unit` (`npm run lerna-test:unit`) in root folder to run them all
9495
* npm task `test:e2e` (`npm run test:unit`) in module folder (for example: `packages/metrics`) to run the module specific one
9596
* 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
110111

111112
See `metrics/tests/e2e/decorator.test.ts` as an example.
112113

113-
114114
**Run**
115115

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
118119
* npm task `test:e2e` (`npm run test:e2e`) in module folder (for example: `packages/metrics`) to run the module specific one
119120
* 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`)
120121

121122
Two important env variable can be used:
123+
122124
* `AWS_PROFILE` to use the right AWS credentials
123125
* `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).
124126

@@ -127,6 +129,7 @@ Example: `DISABLE_TEARDOWN=true AWS_PROFILE=dev-account npx jest --group=e2e/met
127129
**Automate**
128130

129131
You can run the end-to-end tests automatically on your forked project by following these steps:
132+
130133
1. Create an IAM role in your target AWS account, with the least amount of privilege.
131134

132135
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
140143

141144
More information about:
142145

143-
- [Github OpenID Connect](https://github.blog/changelog/2021-10-27-github-actions-secure-cloud-deployments-with-openid-connect/
144-
- ["Configure AWS Credentials" Action For GitHub Actions](https://github.com/aws-actions/configure-aws-credentials/)
146+
* [Github OpenID Connect](https://github.blog/changelog/2021-10-27-github-actions-secure-cloud-deployments-with-openid-connect/)
147+
* ["Configure AWS Credentials" Action For GitHub Actions](https://github.com/aws-actions/configure-aws-credentials/)
148+
145149
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`.
146150
3. In your forked repository, go to the "Actions" tabs, select the `run-e2e-tests` workflow.
147151
4. In the run-e2e-tests workflow page, select "Run workflow" and run it on the desired branch.
148152

149153
> :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.
150154
151-
152155
### Examples
153156

154157
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.
155158

156159
To test your updates with these examples you just have to:
157160

158161
1. Build your local version of *aws-lambda-powertools-typescript* npm packages with `npm run lerna-package`
159-
1. Update their references in examples
162+
2. Update their references in examples
160163
```
161164
cd examples/cdk
162165
npm install ../../packages/**/dist/aws-lambda-powertools-*
163166
```
164-
1. Run cdk tests
167+
3. Run cdk tests
165168
```
166169
npm run test
167170
```
168-
1. Deploy
171+
4. Deploy
169172
```
170173
npm run cdk deploy
171174
```
172175
173176
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+
174178
### Conventions
175179
176180
Category | Convention
@@ -203,4 +207,4 @@ TODO
203207
204208
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
205209
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

Comments
 (0)