Skip to content

Commit e5691bb

Browse files
authored
docs: improve dev setup & contributing info (#492)
* chore: added .nvmrc * docs: expanded contributing doc
1 parent 1b8d963 commit e5691bb

File tree

2 files changed

+129
-43
lines changed

2 files changed

+129
-43
lines changed

Diff for: .nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/fermium

Diff for: CONTRIBUTING.md

+128-43
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ information to effectively respond to your bug report or contribution.
1010

1111
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.
1212

13+
## Code of Conduct
14+
15+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
16+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
17+
[email protected] with any additional questions or comments.
18+
1319
## Reporting Bugs/Feature Requests
1420

1521
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
@@ -24,40 +30,119 @@ reported the issue. Please try to include as much information as you can. Detail
2430

2531
## Contributing via Pull Requests
2632

27-
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
33+
Contributions via pull requests are much appreciated.
2834

29-
1. You are working against the latest source on the **main** branch.
30-
2. You check existing open, and recently merged pull requests to make sure someone else hasn't addressed the problem already.
31-
3. You open an [RFC issue](https://github.com/awslabs/aws-lambda-powertools-typescript/issues/new?assignees=&labels=RFC%2C+triage&template=rfc.md&title=RFC%3A+) to discuss any significant work - we would hate for your time to be wasted.
32-
4. You lint and test the code. When you've setup the repository with `npm run init-environment`, pre-commit and push-hooks will automatically lint and test the code. Pull request builds will run the same checks as well.
35+
### Step 1: Find something to work on
3336

34-
### Dev setup
37+
If you want to contribute a specific feature or fix you have in mind, look at active [pull
38+
requests](https://github.com/awslabs/aws-lambda-powertools-typescript/pulls) to see if someone else is already working on it. If not, you can start designing your changes.
3539

36-
To send us a pull request, please follow these steps:
40+
On the other hand, if you are here looking for an issue to work on, check out our [backlog of
41+
issues](https://github.com/awslabs/aws-lambda-powertools-typescript/issues) and find something that piques your interest. Our project, by default, uses the default GitHub issue labels (enhancement/bug/help wanted/invalid/question/documentation), looking at any issue labeled as 'help wanted' or 'good-first-issue' is a great place to start.
3742

38-
1. Fork the repository.
39-
2. Install dependencies: `npm ci; npm run lerna-ci`
40-
3. Prepare utilities like commit hooks: `npm run init-environment`
41-
4. Create a new branch to focus on the specific change you are contributing e.g. `git checkout -b improv/logger-debug-sampling`
42-
5. Run all tests, and code baseline checks: `npm run test`
43-
6. Commit to your fork using clear commit messages.
44-
7. Send us a pull request with a [conventional semantic title](https://github.com/awslabs/aws-lambda-powertools-typescript/blob/main/.github/semantic.yml), and answering any default questions in the pull request interface. [Here's an example](https://github.com/awslabs/aws-lambda-powertools-python/pull/67).
45-
8. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
43+
It's a good idea to keep the priority of issues in mind when deciding what to
44+
work on. If we have labelled an issue as `priority:medium` or `priority:low`, it means it's something we won't
45+
get to soon while `priority:high` issues have a bigger impact, so we are much more likely to give a PR for those issues prompt attention.
4646

47-
GitHub provides an additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
48-
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
47+
### Step 2: Design
4948

50-
#### Local documentation
49+
You can start by checking the project's tenets [here](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/#tenets).
5150

52-
You might find useful to run both the documentation website and the API reference locally while contributing:
51+
We ask you to seek feedback and consensus on your proposed change by iterating on a design document. This is especially useful when you plan a big change or feature, or you want advice on what would be the best path forward.
5352

54-
* **API reference**: :construction:
55-
* **Docs website**:
53+
If you're picking up an existing issue, you can simply post your comment and discuss your proposed changes. If instead you're proposing a new feature, you can start by creating a new [RFC issue](https://github.com/awslabs/aws-lambda-powertools-typescript/issues/new?assignees=&labels=RFC%2C+triage&template=rfc.md&title=RFC%3A+) and discuss your proposed change with the maintainers.
5654

57-
You can build and start a local docs website by running these two commands.
55+
This is a great way to get feedback on your proposed change, and make sure that it is in line with the project's direction and community needs. You can start working on the change when you've gotten approved by at least one maintainer - we would hate for your time to be wasted.
5856

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`
57+
### Step 3: Work your Magic
58+
59+
Work your magic. Before starting make sure to check the [Getting Started](#Getting-Started) section to setup your dev environment and familiarize yourself with the project's structure and design. Here are some additional guidelines:
60+
61+
* Working against the latest source on the **main** branch.
62+
* Try to maintain a single feature/bugfix per pull request. It's okay to introduce a little bit of housekeeping
63+
changes along the way, but try to avoid conflating multiple features. Eventually, all these are going to go into a
64+
single commit, so you can use that to frame your scope.
65+
* Try to add [unit tests](#Tests) that test your changes when applicable. This is especially important for new features and bug fixes as it helps you to make sure that your changes are working as intended.
66+
* Lint and test the the code. When you've setup the repository with `npm run init-environment`, pre-commit and push-hooks will automatically lint and test the code. Pull request builds will run the same checks as well.
67+
68+
### Step 4: Pull Request
69+
70+
* Create a commit with your changes and push them to a
71+
[fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
72+
> Note: Core members can push directly to a branch on the AWS Lambda Powertools (Typescript) repo (following the same conventions detailed below).
73+
* Create a [pull request on Github](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).
74+
75+
* Pull request title and message (and PR title and description) must adhere to
76+
[conventionalcommits](https://www.conventionalcommits.org).
77+
* The title must begin with `feat(module): title`, `fix(module): title`, `refactor(module): title` or
78+
`chore(module): title`, etc.
79+
* Title should be lowercase.
80+
* No period at the end of the title.
81+
82+
* Pull request message should describe _motivation_ and follow the template provided as closely as possible. Think about your code reviewers and what information they need in order to understand what you did. If it's a big commit (hopefully not), try to provide some good entry points so it will be easier to follow.
83+
84+
* Pull request message should indicate which issue or RFC it relates to in the "Related issues, RFCs" section.
85+
86+
* Shout out to collaborators.
87+
88+
* If not obvious (i.e. from unit tests), describe how you verified that your change works.
89+
90+
* If this PR includes breaking changes, they must be listed at the end in the "Breaking change checklist" section.
91+
92+
* Once the pull request is submitted, a reviewer will be assigned by the maintainers.
93+
94+
* Discuss review comments and iterate until you get at least one "Approve". When iterating, push new commits to the
95+
same branch. Usually all these are going to be squashed when you merge to master. The commit messages should be hints
96+
for you when you finalize your merge commit message.
97+
98+
* Make sure to update the PR title/description if things change. The PR title/description are going to be used as the
99+
commit title/message and will appear in the CHANGELOG and Release Notes, so maintain them all the way throughout the process.
100+
101+
* Do not remove the legal notice at the end of the PR message. This is a requirement for any pull request to be
102+
reviewed & accepted.
103+
104+
### Step 5: Merge
105+
106+
* Once approved and tested, one of the maintainers will squash-merge to `main` and will use your PR title/description will be used as the commit message. Your name will be also added to the Release Notes of the next release.
107+
108+
## Getting Started
109+
110+
The following steps describe how to set up the AWS Lambda Powertools (Typescript) repository on your local machine.
111+
<!-- The alternative is to use a Cloud IDE like [Gitpod](https://www.gitpod.io/) or [Codespaces](https://github.com/features/codespaces) for your development. -->
112+
113+
### Setup
114+
115+
The following tools need to be installed on your system prior to starting working on a pull request:
116+
117+
- [Node.js >= 14.18.1](https://nodejs.org/download/release/latest-v14.x/)
118+
- We recommend using a version in [Active LTS](https://nodejs.org/en/about/releases/)
119+
- If you use [nvm](https://github.com/nvm-sh/nvm#nvmrc) or [fnm](https://github.com/Schniz/fnm) you can install the latest LTS version with `nvm use` or `fnm use` respectively. Both will use the `.nvmrc` file in the project's root.
120+
- [npm 8.x](https://www.npmjs.com/)
121+
- After installing Node.js, you can install `npm` with `npm install -g npm@next-8`
122+
- [Docker](https://docs.docker.com/get-docker/)
123+
- If you are not planning on making changes to the documentation, you can skip this step.
124+
125+
First [fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) the repository, and then run the following commands to clone and initialize the repository locally.
126+
127+
```console
128+
git clone https://github.com/{your-account}/aws-lambda-powertools-typescript.git
129+
cd aws-lambda-powertools-typescript
130+
npm ci; npm run lerna-ci
131+
npm run init-environment
132+
```
133+
134+
We recommend that you use [Visual Studio Code](https://code.visualstudio.com/) to work on the repo.
135+
We use `eslint` to keep our code consistent in terms of style and reducing defects. We recommend installing
136+
the [eslint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) as well.
137+
138+
### Repo Layout
139+
140+
The AWS Lambda Powertools is a npm project written in [typescript](https://www.typescriptlang.org/).
141+
More specifically, it is a [monorepo managed using lerna](https://github.com/lerna/lerna#about).
142+
If you're unfamiliar with any of these technologies, it is useful to learn about them and will make understanding the codebase easier but strictly not necessary for simple contributions.
143+
144+
The repo contains `packages/` directory that contains the Powertools utilities modules. For instance, the source code for the Logger utility can be found at the location `packages/logger` and so on.
145+
The repo also contains a `packages/commons` directory that holds code and logic shared between one or more utilities and that is published as separate npm package.
61146

62147
### Tests
63148

@@ -175,33 +260,33 @@ To test your updates with these examples you just have to:
175260
176261
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/).
177262
178-
### Conventions
263+
### Local documentation
179264
180-
Category | Convention
181-
------------------------------------------------- | ---------------------------------------------------------------------------------
182-
**Docstring** | We use a slight variation of numpy convention with markdown to help generate more readable API references.
183-
**Style guide** | We use black as well as flake8 extensions to enforce beyond good practices [PEP8](https://pep8.org/). We strive to make use of type annotation as much as possible, but don't overdo in creating custom types.
184-
**Core utilities** | Core utilities use a Class, always accept `service` as a constructor parameter, can work in isolation, and are also available in other languages implementation.
185-
**Utilities** | Utilities are not as strict as core and focus on solving a developer experience problem while following the project [Tenets](https://awslabs.github.io/aws-lambda-powertools-typescript/#tenets).
186-
**Exceptions** | Specific exceptions live within utilities themselves and use `Error` suffix e.g. `MetricUnitError`.
187-
**Git commits** | We follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). These are not enforced as we squash and merge PRs, but PR titles are enforced during CI.
188-
**Documentation** | API reference docs are generated from docstrings which should have Examples section to allow developers to have what they need within their own IDE. Documentation website covers the wider usage, tips, and strive to be concise.
265+
You might find useful to run both the documentation website and the API reference locally while contributing:
189266
190-
## Finding contributions to work on
267+
#### API reference
191268
192-
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/help wanted/invalid/question/documentation), looking at any 'help wanted' issues is a great place to start.
269+
You can build and start the API reference website by running these two commands in the project's root:
193270
194-
## Code of Conduct
271+
* `npm run docs-generateApiDoc` OR `typedoc .`
272+
* `npm run docs-runLocalApiDoc` OR `npx live-server api`
195273
196-
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
197-
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
198-
[email protected] with any additional questions or comments.
274+
#### Docs website
199275
200-
## Troubleshooting
276+
You can build and start a local docs website by running these two commands:
201277
202-
### API reference documentation
278+
* `npm run docs-buildDockerImage` OR `docker build -t squidfunk/mkdocs-material ./docs/`
279+
* `npm run docs-runLocalDocker` OR `docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material`
280+
281+
### Conventions
203282
204-
TODO
283+
Category | Convention
284+
------------------------------------------------- | ---------------------------------------------------------------------------------
285+
**Docstring** | We use [JSDoc](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html) annotations to provide type information and create API references.
286+
**Style guide** | We use black as well as flake8 extensions to enforce beyond good practices [PEP8](https://pep8.org/).
287+
**Test coverage** | We use [Jest](https://jestjs.io/) to test our code and [Codecov](https://codecov.io/) to report test coverage. We aim to have 100% test coverage in our unit tests.
288+
**Git commits** | We follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). These are not enforced as we squash and merge PRs, but PR titles are enforced during CI.
289+
**Documentation** | API reference docs are generated from docstrings which should have Examples section to allow developers to have what they need within their own IDE. Documentation website covers the wider usage, tips, and strives to be concise.
205290
206291
## Licensing
207292

0 commit comments

Comments
 (0)