|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | +- Source: `src/` (core modules like `amazon_dash.py`, `action.py`, `google_*`, `ifttt.py`, `openhab.py`, `models.py`). |
| 5 | +- Tests: `tests/` (`test_*.py`, uses pytest; doctests enabled via `pytest.ini`). |
| 6 | +- Docs: `docs/` + `mkdocs.yml` (API docs built from docstrings via `scripts/build-docs.sh`). |
| 7 | +- Scripts: `scripts/` (versioning, docs, requirements, local run helper). |
| 8 | +- Private config: `amazon-dash-private/` (not committed; holds `settings.json`, `buttons.json`, credentials). |
| 9 | + |
| 10 | +## Build, Test, and Development Commands |
| 11 | +- `./activate.sh`: Create/activate local venv (Python 3.12) and install dev deps. |
| 12 | +- `make help`: List available Make targets. |
| 13 | +- `make check`: Run static checks (pre-commit/ruff/mypy via `sniff_check.py`). |
| 14 | +- `python -m pytest -vv --cov=src tests/`: Run tests with coverage (CI mirrors this). |
| 15 | +- `make docs` or `scripts/build-docs.sh`: Generate docs to `site/` and `docs/docstrings/`. |
| 16 | +- Docker (Linux): `docker run --net host -v $PWD/../amazon-dash-private:/amazon-dash-private:ro andgineer/amazon-dash-button-hack`. |
| 17 | +- Local run (Mac/Windows): `. ./activate.sh && sudo python src/amazon_dash.py`. |
| 18 | + |
| 19 | +## Coding Style & Naming Conventions |
| 20 | +- Python ≥ 3.10 (CI targets 3.10–3.12). |
| 21 | +- Linting/formatting: `ruff` (line length ~100, double-quoted docstrings), run via pre-commit. |
| 22 | +- Types: `mypy` (ignore_missing_imports; prefer precise annotations in `src/`). |
| 23 | +- Naming: modules and functions `snake_case`, classes `PascalCase`, constants `UPPER_SNAKE_CASE`. |
| 24 | + |
| 25 | +## Testing Guidelines |
| 26 | +- Frameworks: `pytest`, `pytest-mock`, `freezegun`; doctests enabled. |
| 27 | +- Naming: `tests/test_*.py`; keep tests deterministic and isolated. |
| 28 | +- Coverage: Aim ≥85% (CI enforces green threshold). Run `pytest --cov=src` locally. |
| 29 | + |
| 30 | +## Commit & Pull Request Guidelines |
| 31 | +- Commits: short imperative descriptions (project history favors concise lowercase lines). |
| 32 | +- Before PR: run `pre-commit run --all-files`, `pytest -vv --cov=src`, and `make docs` if APIs changed. |
| 33 | +- PRs must include: clear description, linked issues, configuration notes (if touching `amazon-dash-private` formats), and screenshots/logs when relevant. |
| 34 | +- Keep PRs small and focused; update `README.md`/`docs/` when behavior or settings change. |
| 35 | + |
| 36 | +## Security & Configuration Tips |
| 37 | +- Never commit secrets. Place `settings.json`, `buttons.json`, Google credentials, and IFTTT key under `amazon-dash-private/` and mount read-only in Docker. |
| 38 | +- Validate settings with `src/models.py` schemas; use `bounce_delay` to avoid duplicate press events. |
0 commit comments