cookiecutter-django/CONTRIBUTING.md

70 lines
2.9 KiB
Markdown
Raw Permalink Normal View History

# How to Contribute
Always happy to get issues identified and pull requests!
2023-04-15 15:41:51 +03:00
## General considerations
2023-04-15 15:41:51 +03:00
1. Keep it small. The smaller the change, the more likely we are to accept.
2. Changes that fix a current issue get priority for review.
3. Check out [GitHub guide][submit-a-pr] if you've never created a pull request before.
## Getting started
1. Fork the repo
2. Clone your fork
3. Create a branch for your changes
This last step is very important, don't start developing from master, it'll cause pain if you need to send another change later.
## Testing
2024-03-18 21:55:00 +03:00
You'll need to run the tests using Python 3.12. We recommend using [tox](https://tox.readthedocs.io/en/latest/) to run the tests. It will automatically create a fresh virtual environment and install our test dependencies, such as [pytest-cookies](https://pypi.python.org/pypi/pytest-cookies/) and [flake8](https://pypi.python.org/pypi/flake8/).
2023-04-15 15:41:51 +03:00
We'll also run the tests on GitHub actions when you send your pull request, but it's a good idea to run them locally before you send it.
### Installation
We use uv to manage our environment and manage our Python installation. You can install it following the instructions at https://docs.astral.sh/uv/getting-started/installation/
2023-04-15 15:41:51 +03:00
### Run the template's test suite
To run the tests of the template using the current Python version:
```bash
$ uv run tox run -e py
2023-04-15 15:41:51 +03:00
```
2023-04-15 15:41:51 +03:00
This uses `pytest `under the hood, and you can pass options to it after a `--`. So to run a particular test:
2023-04-15 15:41:51 +03:00
```bash
$ uv run tox run -e py -- -k test_default_configuration
2023-04-15 15:41:51 +03:00
```
2023-04-15 15:41:51 +03:00
For further information, please consult the [pytest usage docs](https://pytest.org/en/latest/how-to/usage.html#specifying-which-tests-to-run).
2023-04-15 15:41:51 +03:00
### Run the generated project tests
2023-04-15 15:41:51 +03:00
The template tests are checking that the generated project is fully rendered and that it passes `flake8`. We also have some test scripts which generate a specific project combination, install the dependencies, run the tests of the generated project, install FE dependencies and generate the docs. They will install the template dependencies, so make sure you create and activate a virtual environment first.
2023-04-15 15:41:51 +03:00
```bash
$ python -m venv venv
$ source venv/bin/activate
```
2023-04-15 15:41:51 +03:00
These tests are slower and can be run with or without Docker:
2024-04-16 21:21:45 +03:00
- Without Docker: `tests/test_bare.sh` (for bare metal)
- With Docker: `tests/test_docker.sh`
2023-04-15 15:41:51 +03:00
All arguments to these scripts will be passed to the `cookiecutter` CLI, letting you set options, for example:
2023-04-15 15:41:51 +03:00
```bash
2024-04-16 21:21:45 +03:00
$ tests/test_bare.sh use_celery=y
2023-04-15 15:41:51 +03:00
```
2023-04-15 15:41:51 +03:00
## Submitting a pull request
2023-04-15 15:41:51 +03:00
Once you're happy with your changes and they look ok locally, push and send send [a pull request][submit-a-pr] to the main repo, which will trigger the tests on GitHub actions. If they fail, try to fix them. A maintainer should take a look at your change and give you feedback or merge it.
2023-04-15 15:41:51 +03:00
[submit-a-pr]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request