Skip to content

Commit

Permalink
Add CONTRIBUTING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanPlasse committed Nov 3, 2022
1 parent 6fd2a21 commit 15a6c11
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Contributing

## Setting up an environment

Clone the `asyncio-mqtt`.

Inside the repository, create a virtual environment.

```bash
python3 -m venv env
```

Activate the virtual environment.

```bash
source ./env/bin/activate
```

Upgrade `pip`.

```bash
pip install --upgrade pip
```

Install the development dependencies.

```bash
pip install -e .[tests,lint,format]
```

Install [pre-commit](https://pre-commit.com/) so that your code is formatted and checked when you are doing a commit.

```bash
pip install pre-commit
pre-commit install
```

### Visual Studio Code

If you are using VSCode, here are the settings to activate on save,

- `black` and `isort` to format.
- `flake8` and `mypy` to lint.

```json
{
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"python.formatting.provider": "black",
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true
}
```

## Testing

To test the code use [pytest](https://docs.pytest.org/en/7.1.x/).

```bash
pytest
```

To do the full coverage of `asyncio-mqtt`, run the following command.

```bash
pytest --cov=src --cov=tests --cov-report=html
```

To view the coverage open `htmlcov/index.html`.

## Committing

After doing `git commit`, `pre-commit` will check the committed code.
The check can be passed, skipped or failed.
If the check failed, it is possible it auto-fixed the code, so you will only need to stage and commit again for it to pass.
If it did not auto-fixed the code, you will need to do it manually.
`pre-commit` will only check the code that is staged, the unstaged code will be stashed during the checks.

0 comments on commit 15a6c11

Please sign in to comment.