|
| 1 | +# Contribute |
| 2 | + |
| 3 | +## Setup package for development |
| 4 | + |
| 5 | +- Create a Python virtualenv and activate it |
| 6 | +- Install "pip-tools" with `pip install -U pip-tools` |
| 7 | +- Compile the requirements with `pip-compile --extra dev, -o requirements.txt pyproject.toml --resolver=backtracking` |
| 8 | +- Sync the dependencies with your virtualenv with `pip-sync` |
| 9 | + |
| 10 | +## Add functionality |
| 11 | + |
| 12 | +- Create a new branch for your feature |
| 13 | +- Change the dependency in your requirements.txt to a local (editable) one that points to your local file system: |
| 14 | + `-e /Users/workspace/django-pony-express` or via pip `pip install -e /Users/workspace/django-pony-express` |
| 15 | +- Ensure the code passes the tests |
| 16 | +- Create a pull request |
| 17 | + |
| 18 | +## Run tests |
| 19 | + |
| 20 | +- Run tests |
| 21 | + ```` |
| 22 | + pytest --ds settings tests |
| 23 | + ```` |
| 24 | + |
| 25 | +- Check coverage |
| 26 | + ```` |
| 27 | + coverage run -m pytest --ds settings tests |
| 28 | + coverage report -m |
| 29 | + ```` |
| 30 | + |
| 31 | +## Git hooks (via pre-commit) |
| 32 | + |
| 33 | +We use pre-push hooks to ensure that only linted code reaches our remote repository and pipelines aren't triggered in |
| 34 | +vain. |
| 35 | + |
| 36 | +To enable the configured pre-push hooks, you need to [install](https://pre-commit.com/) pre-commit and run once: |
| 37 | + |
| 38 | + pre-commit install -t pre-push -t pre-commit --install-hooks |
| 39 | + |
| 40 | +This will permanently install the git hooks for both, frontend and backend, in your local |
| 41 | +[`.git/hooks`](./.git/hooks) folder. |
| 42 | +The hooks are configured in the [`.pre-commit-config.yaml`](templates/.pre-commit-config.yaml.tpl). |
| 43 | + |
| 44 | +You can check whether hooks work as intended using the [run](https://pre-commit.com/#pre-commit-run) command: |
| 45 | + |
| 46 | + pre-commit run [hook-id] [options] |
| 47 | + |
| 48 | +Example: run single hook |
| 49 | + |
| 50 | + pre-commit run ruff --all-files |
| 51 | + |
| 52 | +Example: run all hooks of pre-push stage |
| 53 | + |
| 54 | + pre-commit run --all-files --hook-stage push |
| 55 | + |
| 56 | +## Update documentation |
| 57 | + |
| 58 | +- To build the documentation, run: `sphinx-build docs/ docs/_build/html/`. |
| 59 | +- Open `docs/_build/html/index.html` to see the documentation. |
| 60 | + |
| 61 | + |
| 62 | +### Translation files |
| 63 | + |
| 64 | +If you have added custom text, make sure to wrap it in `_()` where `_` is |
| 65 | +gettext_lazy (`from django.utils.translation import gettext_lazy as _`). |
| 66 | + |
| 67 | +How to create translation file: |
| 68 | + |
| 69 | +* Navigate to `django-pony-express` |
| 70 | +* `python manage.py makemessages -l de` |
| 71 | +* Have a look at the new/changed files within `django_pony_express/locale` |
| 72 | + |
| 73 | +How to compile translation files: |
| 74 | + |
| 75 | +* Navigate to `django-pony-express` |
| 76 | +* `python manage.py compilemessages` |
| 77 | +* Have a look at the new/changed files within `django_pony_express/locale` |
| 78 | + |
0 commit comments