| 1 |
# ๐ ๏ธ Apprise Development Guide |
| 2 |
|
| 3 |
Welcome! This guide helps you contribute to Apprise with confidence. It outlines |
| 4 |
how to set up your local environment, run tests, lint your code, and build |
| 5 |
packages โ all using modern tools like [Tox](https://tox.readthedocs.io/) and |
| 6 |
[Ruff](https://docs.astral.sh/ruff/). |
| 7 |
|
| 8 |
--- |
| 9 |
|
| 10 |
## ๐ Getting Started |
| 11 |
|
| 12 |
Set up your local development environment using Tox: |
| 13 |
|
| 14 |
```bash |
| 15 |
# Install Tox |
| 16 |
python -m pip install tox |
| 17 |
``` |
| 18 |
|
| 19 |
Tox manages dependencies, linting, testing, and builds โ no need to manually |
| 20 |
install `requirements-dev.txt`. |
| 21 |
|
| 22 |
--- |
| 23 |
|
| 24 |
## ๐งช Running Tests |
| 25 |
|
| 26 |
Use the `qa` environment for full testing and plugin coverage: |
| 27 |
|
| 28 |
```bash |
| 29 |
tox -e qa |
| 30 |
``` |
| 31 |
|
| 32 |
To focus on specific tests (e.g., email-related): |
| 33 |
|
| 34 |
```bash |
| 35 |
tox -e qa -- -k email |
| 36 |
``` |
| 37 |
|
| 38 |
To run a minimal dependency test set: |
| 39 |
|
| 40 |
```bash |
| 41 |
tox -e minimal |
| 42 |
``` |
| 43 |
|
| 44 |
--- |
| 45 |
|
| 46 |
## ๐งน Linting and Formatting |
| 47 |
|
| 48 |
Apprise uses [Ruff](https://docs.astral.sh/ruff/) for linting and formatting. |
| 49 |
This is configured via `pyproject.toml`. |
| 50 |
|
| 51 |
Run linting: |
| 52 |
|
| 53 |
```bash |
| 54 |
tox -e lint |
| 55 |
``` |
| 56 |
|
| 57 |
Fix formatting automatically (where possible): |
| 58 |
|
| 59 |
```bash |
| 60 |
tox -e format |
| 61 |
``` |
| 62 |
|
| 63 |
> Linting runs automatically on all PRs that touch Python files via GitHub |
| 64 |
> Actions and will fail builds on violation. |
| 65 |
|
| 66 |
--- |
| 67 |
|
| 68 |
## โ
Pre-Commit Check (Recommended) |
| 69 |
|
| 70 |
Before pushing or creating a PR, validate your work with: |
| 71 |
|
| 72 |
```bash |
| 73 |
tox -e lint,qa |
| 74 |
``` |
| 75 |
|
| 76 |
Or use a combined check shortcut (if defined): |
| 77 |
|
| 78 |
```bash |
| 79 |
tox -e checkdone |
| 80 |
``` |
| 81 |
|
| 82 |
This ensures your changes are linted, tested, and PR-ready. |
| 83 |
|
| 84 |
--- |
| 85 |
|
| 86 |
## ๐จ CLI Testing |
| 87 |
|
| 88 |
You can run the `apprise` CLI using your local code without installation or run within docker containers: |
| 89 |
|
| 90 |
```bash |
| 91 |
# From the root of the repo |
| 92 |
./bin/apprise -t "Title" -b "Body" mailto://user:[email protected] |
| 93 |
``` |
| 94 |
|
| 95 |
Alternatively you can continue to use the `tox` environment: |
| 96 |
|
| 97 |
|
| 98 |
```bash |
| 99 |
# syntax tox -e apprise -- [options], e.g.: |
| 100 |
tox -e apprise -- -vv -b "test body" -t "test title" mailto://credentials |
| 101 |
``` |
| 102 |
|
| 103 |
Optionally, add the `bin/apprise` to tests your changes |
| 104 |
|
| 105 |
```bash |
| 106 |
bin/apprise -vv -b "test body" -t "test title" <schema> |
| 107 |
``` |
| 108 |
|
| 109 |
--- |
| 110 |
|
| 111 |
## ๐ฆ RPM Build & Verification |
| 112 |
|
| 113 |
Apprise supports RPM packaging for Fedora and RHEL-based systems. Use Docker |
| 114 |
to safely test builds: |
| 115 |
|
| 116 |
```bash |
| 117 |
# Build RPM for EL9 |
| 118 |
docker-compose run --rm rpmbuild.el9 /apprise/bin/build-rpm.sh |
| 119 |
|
| 120 |
# Build RPM for EL10 |
| 121 |
docker-compose run --rm rpmbuild.el10 /apprise/bin/build-rpm.sh |
| 122 |
|
| 123 |
# Build RPM for Fedora 44 |
| 124 |
docker-compose run --rm rpmbuild.f44 /apprise/bin/build-rpm.sh |
| 125 |
``` |
| 126 |
|
| 127 |
## ๐ฆ Specific Environment Emulation |
| 128 |
|
| 129 |
You can also emulate your own docker environment and just test/build inside that |
| 130 |
```bash |
| 131 |
# Python v3.9 Testing |
| 132 |
docker-compose run --rm test.py39 bash |
| 133 |
|
| 134 |
# Python v3.10 Testing |
| 135 |
docker-compose run --rm test.py310 bash |
| 136 |
|
| 137 |
# Python v3.11 Testing |
| 138 |
docker-compose run --rm test.py311 bash |
| 139 |
|
| 140 |
# Python v3.12 Testing |
| 141 |
docker-compose run --rm test.py312 bash |
| 142 |
``` |
| 143 |
Once you've entered one of these environments, you can leverage the following command to work with: |
| 144 |
|
| 145 |
1. `bin/test.sh`: runs the full test suite (same as `tox -e qa`) but without coveage |
| 146 |
1. `bin/checkdone.sh`: runs the full test suite (same as `tox -e qa`) |
| 147 |
1. `bin/apprise`: launches the Apprise CLI using the local build (same as `tox -e apprise`) |
| 148 |
1. `ruff check . --fix`: auto-formats the codebase (same as `tox -e format`) |
| 149 |
1. `ruff check .`: performs lint-only validation (same as `tox -e lint`) |
| 150 |
1. `coverage run --source=apprise -m pytest tests`: manual test execution with coverage |
| 151 |
|
| 152 |
The only advantage of this route is the overhead associated with each `tox` call is gone (faster responses). Otherwise just utilizing the `tox` commands can sometimes be easier. |
| 153 |
|
| 154 |
## ๐งช GitHub Actions |
| 155 |
|
| 156 |
GitHub Actions runs: |
| 157 |
- โ
Full test suite with coverage |
| 158 |
- โ
Linting (using Ruff) |
| 159 |
- โ
Packaging and validation |
| 160 |
|
| 161 |
Linting **must pass** before PRs can be merged. |
| 162 |
|
| 163 |
--- |
| 164 |
|
| 165 |
## ๐ง Developer Tips |
| 166 |
|
| 167 |
- Add new plugins by following the samples in the [Plugin guide](https://appriseit.com/library/plugin/). |
| 168 |
- Multi-target plugins must record each success with `mark_delivered()` so |
| 169 |
retries do not notify the same target twice. |
| 170 |
- Write unit tests under `tests/` using the `AppriseURLTester` pattern. |
| 171 |
- All new plugins must include test coverage and pass linting. |