Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 138 additions & 28 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,168 @@

All contributions are welcome! Besides code contributions, this includes things like documentation improvements, bug reports, and feature requests.

You should first check if there is a [GitHub issue](https://github.com/joshuadavidthomas/django-bird/issues) already open or related to what you would like to contribute. If there is, please comment on that issue to let others know you are working on it. If there is not, please open a new issue to discuss your contribution.
You should first check if there is a [GitHub issue](https://github.com/joshuadavidthomas/django-github-app/issues) already open or related to what you would like to contribute. If there is, please comment on that issue to let others know you are working on it. If there is not, please open a new issue to discuss your contribution.

Not all contributions need to start with an issue, such as typo fixes in documentation or version bumps to Python or Django that require no internal code changes, but generally, it is a good idea to open an issue first.

We adhere to Django's Code of Conduct in all interactions and expect all contributors to do the same. Please read the [Code of Conduct](https://www.djangoproject.com/conduct/) before contributing.

## Requirements

- [uv](https://github.com/astral-sh/uv) - Modern Python toolchain that handles:
- Python version management and installation
- Virtual environment creation and management
- Fast, reliable dependency resolution and installation
- Reproducible builds via lockfile
- [direnv](https://github.com/direnv/direnv) (Optional) - Automatic environment variable loading
- [just](https://github.com/casey/just) (Optional) - Command runner for development tasks

### `Justfile`

The repository includes a `Justfile` that provides all common development tasks with a consistent interface. Running `just` without arguments shows all available commands and their descriptions:

<!-- [[[cog
import subprocess
import cog

output_raw = subprocess.run(["just", "--list", "--list-submodules"], stdout=subprocess.PIPE)
output_list = output_raw.stdout.decode("utf-8").split("\n")

cog.outl("""\
```bash
$ just
$ # just --list --list-submodules
""")

for i, line in enumerate(output_list):
if not line:
continue
cog.out(line)
if i < len(output_list):
cog.out("\n")

cog.out("```")
]]] -->
```bash
$ just
$ # just --list --list-submodules

Available recipes:
bootstrap
coverage
lint
lock *ARGS
test *ARGS
testall *ARGS
types *ARGS
docs:
build LOCATION="docs/_build/html" # Build documentation using Sphinx
serve PORT="8000" # Serve documentation locally
```
<!-- [[[end]]] -->

All commands below will contain the full command as well as its `just` counterpart.

## Setup

The following setup steps assume you are using a Unix-like operating system, such as Linux or macOS, and that you have a [supported](https://django-bird.readthedocs.io/#requirements) version of Python installed. If you are using Windows, you will need to adjust the commands accordingly. If you do not have Python installed, you can visit [python.org](https://www.python.org/) for instructions on how to install it for your operating system.
The following instructions will use `uv` and assume a Unix-like operating system (Linux or macOS).

Windows users will need to adjust commands accordingly, though the core workflow remains the same.

Alternatively, any Python package manager that supports installing from `pyproject.toml` ([PEP 621](https://peps.python.org/pep-0621/)) can be used. If not using `uv`, ensure you have Python installed from [python.org](https://www.python.org/).

1. Fork the repository and clone it locally.
2. Create a virtual environment and activate it. You can use whatever tool you prefer for this. Below is an example using the Python standard library's `venv` module:
2. Use `uv` too bootstrap your development environment:

```shell
python -m venv venv
source venv/bin/activate
```bash
uv python install
uv sync --locked
# just bootstrap
```

3. Install `django-bird` and the `dev` dependencies in editable mode:
This will install the correct Python version, create and configure a virtual environment, and install all dependencies.

## Tests

```shell
python -m pip install --editable '.[dev]'
# or using [just](#just)
just bootstrap
The project uses [`pytest`](https://docs.pytest.org/) for testing and [`nox`](https://nox.thea.codes/) to run the tests in multiple environments.

To run the test suite against the default versions of Python (lower bound of supported versions) and Django (lower bound of LTS versions):

```bash
uv run nox --session test
# just test
```

## Testing
To run the test suite against the entire matrix of supported versions of Python and Django:

We use [`pytest`](https://docs.pytest.org/) for testing and [`nox`](https://nox.thea.codes/) to run the tests in multiple environments.
```bash
uv run nox --session tests
# just testall
```

To run the test suite against the default versions of Python (lower bound of supported versions) and Django (lower bound of LTS versions), run:
Both can be passed additional arguments that will be provided to `pytest`:

```shell
python -m nox --session "test"
# or using [just](#just)
just test
```bash
uv run nox --session test -- -v --last-failed
uv run nox --session tests -- --failed-first --maxfail=1
# just test -v --last-failed
# just testall --failed-first --maxfail=1
```

To run the test suite against all supported versions of Python and Django, run:
### Coverage

```shell
python -m nox --session "tests"
# or using [just](#just)
just testall
The project uses [`coverage.py`](https://github.com/nedbat/coverage.py) to measure code coverage and aims to maintain 100% coverage across the codebase.

To run the test suite and measure code coverage:

```bash
uv run nox --session coverage
# just coverage
```

## `just`
All pull requests must include tests to maintain 100% coverage. Coverage configuration can be found in the `[tools.coverage.*]` sections of [`pyproject.toml`](pyproject.toml).

## Linting and Formatting

[`just`](https://github.com/casey/just) is a command runner that is used to run common commands, similar to `make` or `invoke`. A `Justfile` is provided at the base of the repository, which contains commands for common development tasks, such as running the test suite or linting.
This project enforces code quality standards using [`pre-commit`](https://github.com/pre-commit/pre-commit).

To see a list of all available commands, ensure `just` is installed and run the following command at the base of the repository:
To run all formatters and linters:

```shell
just
```bash
uv run nox --session lint
# just lint
```

The following checks are run:

- [ruff](https://github.com/astral-sh/ruff) - Fast Python linter and formatter
- Code formatting for Python files in documentation ([blacken-docs](https://github.com/adamchainz/blacken-docs))
- Django compatibility checks ([django-upgrade](https://github.com/adamchainz/django-upgrade))
- TOML and YAML validation
- Basic file hygiene (trailing whitespace, file endings)

To enable pre-commit hooks after cloning:

```bash
uv run --with pre-commit pre-commit install
```

Configuration for these tools can be found in:

- [`.pre-commit-config.yaml`](.pre-commit-config.yaml) - Pre-commit hook configuration
- [`pyproject.toml`](pyproject.toml) - Ruff and other tool settings

## Continuous Integration

This project uses GitHub Actions for CI/CD. The workflows can be found in [`.github/workflows/`](.github/workflows/):

- [`test.yml`](.github/workflows/test.yml) - Runs on pushes to the `main` branch and on all PRs
- Tests across Python/Django version matrix
- Static type checking
- Coverage reporting
- [`release.yml`](.github/workflows/release.yml) - Runs on GitHub release creation
- Runs the [`test.yml`](.github/workflows/test.yml) workflow
- Builds package
- Publishes to PyPI

PRs must pass all CI checks before being merged.
6 changes: 5 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ mod docs ".just/documentation.just"

[private]
default:
@just --list
@just --list --list-submodules

[private]
cog:
uv run --with cogapp cog -r CONTRIBUTING.md

[private]
fmt:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@ GITHUB_APP = {

Secret used to verify webhook payloads from GitHub.

## Development

For detailed instructions on setting up a development environment and contributing to this project, see [CONTRIBUTING.md](CONTRIBUTING.md).

For release procedures, see [RELEASING.md](RELEASING.md).

## License

django-github-app is licensed under the MIT license. See the [`LICENSE`](LICENSE) file for more information.