| 1 | # Contributing |
| 2 | |
| 3 | Contributions are welcome, and they are greatly appreciated! Every little helps, and credit will always be given. |
| 4 | |
| 5 | You can contribute in many ways: |
| 6 | |
| 7 | ## Types of Contributions |
| 8 | |
| 9 | ### Report Bugs |
| 10 | |
| 11 | Report bugs to [our issue page][gh-issues] for code issues or feature requests. If you are reporting a bug, please include: |
| 12 | |
| 13 | - Your operating system name and version. |
| 14 | - Any details about your local setup that might be helpful in troubleshooting. |
| 15 | - Detailed steps to reproduce the bug. |
| 16 | |
| 17 | Documentation issues of the website [bthome.io](https://bthome.io) can be reported at the [issue page of the website][doc-issues]. |
| 18 | |
| 19 | ### Fix Bugs |
| 20 | |
| 21 | Look through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement it. |
| 22 | |
| 23 | ### Implement Features |
| 24 | |
| 25 | Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it. |
| 26 | |
| 27 | ### Write Documentation |
| 28 | |
| 29 | BTHome BLE could always use more documentation, whether as part of the official BTHome BLE docs, in docstrings, or even on the web in blog posts, articles, and such. |
| 30 | The official website is located at [bthome.io](https://bthome.io). Changes to the website can be done on the [GitHub page of the site](https://github.com/home-assistant/bthome.io). |
| 31 | |
| 32 | ### Submit Feedback |
| 33 | |
| 34 | The best way to send feedback [our issue page][gh-issues] on GitHub. If you are proposing a feature: |
| 35 | |
| 36 | - Explain in detail how it would work. |
| 37 | - Keep the scope as narrow as possible, to make it easier to implement. |
| 38 | - Remember that this is a volunteer-driven project, and that contributions are welcome 😊 |
| 39 | |
| 40 | ## Get Started! |
| 41 | |
| 42 | Ready to contribute? Here's how to set yourself up for local development. |
| 43 | |
| 44 | 1. Fork the repo on GitHub. |
| 45 | |
| 46 | 2. Clone your fork locally: |
| 47 | |
| 48 | ```shell |
| 49 | $ git clone [email protected]:your_name_here/bthome-ble.git |
| 50 | ``` |
| 51 | |
| 52 | 3. Go to the cloned folder: |
| 53 | |
| 54 | ```shell |
| 55 | $ cd bthome-ble |
| 56 | ``` |
| 57 | |
| 58 | 4. Install the project dependencies with [Poetry](https://python-poetry.org): |
| 59 | |
| 60 | ```shell |
| 61 | $ poetry install |
| 62 | ``` |
| 63 | |
| 64 | 5. Create a branch for local development: |
| 65 | |
| 66 | ```shell |
| 67 | $ git checkout -b name-of-your-bugfix-or-feature |
| 68 | ``` |
| 69 | |
| 70 | Now you can make your changes locally. |
| 71 | |
| 72 | 6. When you're done making changes, check that your changes pass our tests: |
| 73 | |
| 74 | ```shell |
| 75 | $ poetry run pytest |
| 76 | ``` |
| 77 | |
| 78 | 7. Linting is done through [pre-commit](https://pre-commit.com). Provided you have the tool installed globally, you can run them all as one-off: |
| 79 | |
| 80 | ```shell |
| 81 | $ pre-commit run -a |
| 82 | ``` |
| 83 | |
| 84 | Or better, install the hooks once and have them run automatically each time you commit: |
| 85 | |
| 86 | ```shell |
| 87 | $ pre-commit install |
| 88 | ``` |
| 89 | |
| 90 | 8. Commit your changes and push your branch to GitHub: |
| 91 | |
| 92 | ```shell |
| 93 | $ git add . |
| 94 | $ git commit -m "feat(something): your detailed description of your changes" |
| 95 | $ git push origin name-of-your-bugfix-or-feature |
| 96 | ``` |
| 97 | |
| 98 | Note: the commit message should follow [the conventional commits](https://www.conventionalcommits.org). We run [`commitlint` on CI](https://github.com/marketplace/actions/commit-linter) to validate it, and if you've installed pre-commit hooks at the previous step, the message will be checked at commit time. |
| 99 | |
| 100 | 9. Submit a pull request through the GitHub website or using the GitHub CLI (if you have it installed): |
| 101 | |
| 102 | ```shell |
| 103 | $ gh pr create --fill |
| 104 | ``` |
| 105 | |
| 106 | ## Pull Request Guidelines |
| 107 | |
| 108 | We like to have the pull request open as soon as possible, that's a great place to discuss any piece of work, even unfinished. You can use draft pull request if it's still a work in progress. Here are a few guidelines to follow: |
| 109 | |
| 110 | 1. Include tests for feature or bug fixes. |
| 111 | 2. Update the documentation for significant features. |
| 112 | 3. Ensure tests are passing on CI. |
| 113 | |
| 114 | ## Tips |
| 115 | |
| 116 | To run a subset of tests: |
| 117 | |
| 118 | ```shell |
| 119 | $ pytest tests |
| 120 | ``` |
| 121 | |
| 122 | ## Making a new release |
| 123 | |
| 124 | The deployment should be automated and can be triggered from the Semantic Release workflow in GitHub. The next version will be based on [the commit logs](https://python-semantic-release.readthedocs.io/en/latest/commit-log-parsing.html#commit-log-parsing). This is done by [python-semantic-release](https://python-semantic-release.readthedocs.io/en/latest/index.html) via a GitHub action. |
| 125 | |
| 126 | [gh-issues]: https://github.com/bluetooth-devices/bthome-ble/issues |
| 127 | [doc-issues]: https://github.com/home-assistant/bthome.io/issues |