|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Welcome to our community! Thank you for taking the time to read the following. |
| 4 | + |
| 5 | +## TL;DR |
| 6 | + |
| 7 | +* Be cool! For real, toxic people will be banned without warning. |
| 8 | +* All code should have tests. |
| 9 | +* All code should be documented. |
| 10 | +* No changes are ever committed without review and approval. |
| 11 | + |
| 12 | +## Project management |
| 13 | + |
| 14 | +* GitHub is used for the code base. |
| 15 | +* For a PR to be integrated, it must be approved at least by one core team member. |
| 16 | +* Development discussions happen on Discord but any request **must** be formalized in GitHub. This ensures a common history. |
| 17 | +* Continuous Integration is provided by *Github actions* and configuration is located at ``.github/workflows``. |
| 18 | + |
| 19 | +## Code |
| 20 | + |
| 21 | +### Local development |
| 22 | + |
| 23 | +After cloning the repository, use the Makefile! |
| 24 | + |
| 25 | +```bash |
| 26 | +$ make |
| 27 | +$ make prepare |
| 28 | +``` |
| 29 | + |
| 30 | +### Testing |
| 31 | + |
| 32 | +Testing your code is paramount. Without continuous integration, we **cannot** |
| 33 | +guaranty the quality of the code. Some minor modification on a function can |
| 34 | +have unexpected implications. With a single commit, everything can go south! |
| 35 | +The ``main`` branch is always on a passing state: CI is green, working code, |
| 36 | +and an installable Python package. |
| 37 | + |
| 38 | +The library [pytest](https://docs.pytest.org/en/latest/) is used with |
| 39 | +[coverage](https://coverage.readthedocs.io/) to ensure the added |
| 40 | +functionalities are covered by tests. |
| 41 | + |
| 42 | +All tests can be launched using: |
| 43 | + |
| 44 | +```bash |
| 45 | +uv run pytest --cov skstats --cov-report term-missing |
| 46 | +``` |
| 47 | + |
| 48 | +The output consists in tests results and coverage report. |
| 49 | + |
| 50 | +> Tests will be automatically launched when you will push your branch to |
| 51 | +> GitHub. Be mindful of this resource! |
| 52 | +
|
| 53 | +### Style |
| 54 | + |
| 55 | +For all python code, developers **must** follow guidelines from the Python Software Foundation. As a quick reference: |
| 56 | + |
| 57 | +* For code: [PEP 8](https://www.python.org/dev/peps/pep-0008/) |
| 58 | +* For documentation: [PEP 257](https://www.python.org/dev/peps/pep-0257/) |
| 59 | +* Use NumPyDoc formatting: [Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html) |
| 60 | + |
| 61 | +And for a more Pythonic code: [PEP 20](https://www.python.org/dev/peps/pep-0020/) |
| 62 | +Last but not least, avoid common pitfalls: [Anti-patterns](https://docs.quantifiedcode.com/python-anti-patterns/) |
| 63 | + |
| 64 | +### Linter |
| 65 | + |
| 66 | +Apart from normal unit and integration tests, you can perform a static |
| 67 | +analysis of the code using [ruff](https://github.com/astral-sh/ruff). This allows to spot naming errors for |
| 68 | +example as well as other style errors. |
| 69 | + |
| 70 | +Just use the pre-commit hooks to make your life easier. |
| 71 | + |
| 72 | +```bash |
| 73 | +pre-commit install |
| 74 | +``` |
| 75 | + |
| 76 | +Manually: |
| 77 | +```bash |
| 78 | +ruff check --fix |
| 79 | +``` |
| 80 | + |
| 81 | +## GIT |
| 82 | + |
| 83 | +### Workflow |
| 84 | + |
| 85 | +The development model is based on the Cactus Model also called |
| 86 | +[Trunk Based Development](https://trunkbaseddevelopment.com) model. |
| 87 | +More specifically, we use the Scaled Trunk-Based Development model. |
| 88 | + |
| 89 | +> Some additional ressources: |
| 90 | +> [gitflow](https://nvie.com/posts/a-successful-git-branching-model/), |
| 91 | +> [gitflow critique](https://barro.github.io/2016/02/a-succesful-git-branching-model-considered-harmful/), |
| 92 | +> [github PR](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-merges). |
| 93 | +
|
| 94 | +It means that **each** new feature has to go through a new branch. Why? |
| 95 | +For peer review. Pushing directly on the develop without review should be |
| 96 | +exceptional (hotfix)! |
| 97 | + |
| 98 | +When you try to commit your changes, it will launch the pre-commit hooks |
| 99 | +(``.pre-commit-config.yaml``) |
| 100 | +and modify the files if there are any changes to be made for the commit to be |
| 101 | +accepted. If you don't use this feature and your changes are not compliant |
| 102 | +(linter), CI will fail. |
| 103 | + |
| 104 | +### Recipe for new feature |
| 105 | + |
| 106 | +If you want to add a modification, create a new branch branching off ``main``. |
| 107 | +Then you can create a pull request on GitHub. From here, the fun begins. |
| 108 | + |
| 109 | +> For every commit you push, the linter and tests are launched. |
| 110 | +
|
| 111 | +Your request will only be considered for integration if in a **finished** state: |
| 112 | + |
| 113 | +0. Be nice, subject to own judgment :) |
| 114 | +1. Respect python coding rules, |
| 115 | +2. Have tests regarding the changes, |
| 116 | +3. The branch passes all tests (current and new ones), |
| 117 | +4. Maintain test coverage, |
| 118 | +5. Have the respective documentation. |
| 119 | + |
| 120 | +#### Writing the commit message |
| 121 | + |
| 122 | +Commit messages should be clear and follow a few basic rules. Example: |
| 123 | + |
| 124 | +```bash |
| 125 | + Add functionality X. |
| 126 | + |
| 127 | + Lines shouldn't be longer than 72 |
| 128 | + characters. If the commit is related to a ticket, you can indicate that |
| 129 | + with "See #3456", "See ticket 3456", "Closes #3456", or similar. |
| 130 | +``` |
| 131 | +
|
| 132 | +Describing the motivation for a change, the nature of a bug for bug fixes or |
| 133 | +some details on what an enhancement does are also good to include in a commit |
| 134 | +message. Messages should be understandable without looking at the code |
| 135 | +changes. A commit message like ``fixed another one`` is an example of |
| 136 | +what not to do; the reader has to go look for context elsewhere. |
| 137 | +
|
| 138 | +### Squash, rebase and merge |
| 139 | +
|
| 140 | +Squash-merge is systematically used to maintain a linear history. It's |
| 141 | +important to check the message on the squash commit to keep things tidy. |
| 142 | + |
| 143 | +## Making a release |
| 144 | + |
| 145 | +Following is the process that the development team follows in order to make |
| 146 | +a release: |
| 147 | + |
| 148 | +1. Update the version in the main `pyproject.toml` |
| 149 | +2. Build locally using `uv build`, and verify the content of the artifacts |
| 150 | +3. Submit PR, wait for tests to pass, and merge release into `main` |
| 151 | +4. On GitHub manually trigger the release workflow |
| 152 | +5. Check that a release has been deployed to PyPI and GitHub |
| 153 | +6. Check the documentation is built and deployed |
| 154 | +7. Check that auto-generated PR is auto-merged on the conda-forge feedstock repo |
0 commit comments