|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Contributions are welcome, and they are greatly appreciated! |
| 4 | +Every little bit helps, and credit will always be given. |
| 5 | + |
| 6 | +## Environment setup |
| 7 | + |
| 8 | +Nothing easier! |
| 9 | +Follow the instructions below. |
| 10 | + |
| 11 | +!!! note |
| 12 | + We **STRONGLY** recommend using a Linux distribution for Python development (Windows sometimes leads to obscure compatibility errors...) |
| 13 | + |
| 14 | + |
| 15 | +1. Install [`Git`](https://git-scm.com/) to version and track our software changes. |
| 16 | + |
| 17 | + - On _Windows_, use the official installer: [`Git-for-Windows`](https://git-scm.com/download/win). |
| 18 | + |
| 19 | + - On _Linux_, simply use your package manager. |
| 20 | + |
| 21 | + !!! note |
| 22 | + `Git-for-Windows` doesn't provide the command `make`. In following step, use `pdm` instead. |
| 23 | + |
| 24 | + |
| 25 | +1. Install [`Python`](https://www.python.org/) as programming language for this projet. |
| 26 | + |
| 27 | + - On _Windows_, use the official installer: [Python Releases for Windows](https://www.python.org/downloads/windows/). |
| 28 | + |
| 29 | + - On _Linux_, simply use your package manager. |
| 30 | + |
| 31 | + !!! note |
| 32 | + You can also use use [`pyenv`](https://github.com/pyenv/pyenv). |
| 33 | + |
| 34 | + ```bash |
| 35 | + # install pyenv |
| 36 | + git clone https://github.com/pyenv/pyenv ~/.pyenv |
| 37 | + |
| 38 | + # setup pyenv (you should also put these three lines in .bashrc or similar) |
| 39 | + export PATH="${HOME}/.pyenv/bin:${PATH}" |
| 40 | + export PYENV_ROOT="${HOME}/.pyenv" |
| 41 | + eval "$(pyenv init -)" |
| 42 | + |
| 43 | + # install Python 3.8 |
| 44 | + pyenv install 3.8 |
| 45 | + |
| 46 | + # make it available globally |
| 47 | + pyenv global system 3.8 |
| 48 | + ``` |
| 49 | + |
| 50 | + |
| 51 | +1. Fork and clone the repository: |
| 52 | + |
| 53 | + ```bash |
| 54 | + git clone https://github.com/cognitivefactory/features-maximization-metric/ |
| 55 | + cd features-maximization-metric |
| 56 | + ``` |
| 57 | + |
| 58 | + |
| 59 | +1. Install the dependencies of the projet with: |
| 60 | + |
| 61 | + ```bash |
| 62 | + cd interactive-clustering |
| 63 | + make setup # on Linux |
| 64 | + pdm install # on Windows |
| 65 | + ``` |
| 66 | + |
| 67 | + !!! note |
| 68 | + If it fails for some reason (especially on Windows), you'll need to install [`pipx`](https://github.com/pypa/pipx) and [`pdm`](https://github.com/pdm-project/pdm) manually. |
| 69 | +
|
| 70 | + You can install them with: |
| 71 | +
|
| 72 | + ```bash |
| 73 | + python3 -m pip install --user pipx |
| 74 | + pipx install pdm |
| 75 | + ``` |
| 76 | +
|
| 77 | + Now you can try running `make setup` again, or simply `pdm install`. |
| 78 | +
|
| 79 | +Your project is now ready and dependencies are installed. |
| 80 | +
|
| 81 | +
|
| 82 | +## Available template tasks |
| 83 | +
|
| 84 | +This project uses [duty](https://github.com/pawamoy/duty) to run tasks. |
| 85 | +A Makefile is also provided. |
| 86 | +To run a task, use `make TASK` on _Linux_ and `pdm run duty TASK` _on Windows_. |
| 87 | +
|
| 88 | +To show the available template task: |
| 89 | +
|
| 90 | +```bash |
| 91 | +make help # on Linux |
| 92 | +pdm run duty --list # on Windows |
| 93 | +``` |
| 94 | +
|
| 95 | +The Makefile will try to run certain tasks on multiple Python versions. |
| 96 | +If for some reason you don't want to run the task on multiple Python versions, you can do one of the following: |
| 97 | + |
| 98 | +1. `export PYTHON_VERSIONS= `: this will run the task |
| 99 | + with only the current Python version |
| 100 | +2. run the task directly with `pdm run duty TASK` |
| 101 | + |
| 102 | +The Makefile detects if a virtual environment is activated, so `make`/`pdm` will work the same with the virtualenv activated or not. |
| 103 | + |
| 104 | +## Development journey |
| 105 | + |
| 106 | +As usual: |
| 107 | + |
| 108 | +1. create a new branch: `git checkout -b feature-or-bugfix-name` |
| 109 | +1. edit the code and/or the documentation |
| 110 | + |
| 111 | +If you updated the documentation or the project dependencies: |
| 112 | + |
| 113 | +1. run `make docs-regen` |
| 114 | +1. run `make docs-serve`, go to http://localhost:8000 and check that everything looks good |
| 115 | + |
| 116 | +**Before committing:** |
| 117 | + |
| 118 | +1. run `make format` to auto-format the code |
| 119 | +1. run `make check` to check everything (fix any warning) |
| 120 | +1. run `make test` to run the tests (fix any issue) |
| 121 | +1. follow our [commit message convention](#commit-message-convention) |
| 122 | + |
| 123 | +If you are unsure about how to fix or ignore a warning, just let the continuous integration fail, and we will help you during review. |
| 124 | + |
| 125 | +Don't bother updating the changelog, we will take care of this. |
| 126 | +
|
| 127 | +## Commit message convention |
| 128 | +
|
| 129 | +Commits messages must follow the [Angular style](https://gist.github.com/stephenparish/9941e89d80e2bc58a153#format-of-the-commit-message): |
| 130 | +
|
| 131 | +``` |
| 132 | +<type>[(scope)]: Subject |
| 133 | +
|
| 134 | +[Body] |
| 135 | +``` |
| 136 | +
|
| 137 | +Scope and body are optional. Type can be: |
| 138 | +
|
| 139 | +- `build`: About packaging, building wheels, etc. |
| 140 | +- `chore`: About packaging or repo/files management. |
| 141 | +- `ci`: About Continuous Integration. |
| 142 | +- `docs`: About documentation. |
| 143 | +- `feat`: New feature. |
| 144 | +- `fix`: Bug fix. |
| 145 | +- `perf`: About performance. |
| 146 | +- `refactor`: Changes which are not features nor bug fixes. |
| 147 | +- `style`: A change in code style/format. |
| 148 | +- `tests`: About tests. |
| 149 | +
|
| 150 | +**Subject (and body) must be valid Markdown.** |
| 151 | +If you write a body, please add issues references at the end: |
| 152 | +
|
| 153 | +``` |
| 154 | +Body. |
| 155 | +
|
| 156 | +References: #10, #11. |
| 157 | +Fixes #15. |
| 158 | +``` |
| 159 | +
|
| 160 | +## Pull requests guidelines |
| 161 | +
|
| 162 | +Link to any related issue in the Pull Request message. |
| 163 | +
|
| 164 | +During review, we recommend using fixups: |
| 165 | +
|
| 166 | +```bash |
| 167 | +# SHA is the SHA of the commit you want to fix |
| 168 | +git commit --fixup=SHA |
| 169 | +``` |
| 170 | +
|
| 171 | +Once all the changes are approved, you can squash your commits: |
| 172 | +
|
| 173 | +```bash |
| 174 | +git rebase -i --autosquash master |
| 175 | +``` |
| 176 | +
|
| 177 | +And force-push: |
| 178 | +
|
| 179 | +```bash |
| 180 | +git push -f |
| 181 | +``` |
| 182 | +
|
| 183 | +If this seems all too complicated, you can push or force-push each new commit, and we will squash them ourselves if needed, before merging. |
0 commit comments