๐ ๏ธ Development Guide (Hatch-based)
This guide covers how to set up a local development environment, run tests, and manage code quality for Azure Functions Doctor, using Hatch and a Makefile for workflow automation.
๐ฆ Prerequisites
- Python 3.9+ installed on your system
- Git for version control
- Hatch as the build and environment manager (installed via
pip install hatch
) - Make (for running the provided Makefile targets)
- (Optional) uv for fast dependency installation (
pip install uv
)
๐ ๏ธ Project Structure Overview
azure-functions-doctor-for-python/
โโโ Makefile
โโโ pyproject.toml
โโโ hatch.toml
โโโ src/
โ โโโ azure_functions_doctor/
โ โโโ __init__.py
โ โโโ cli.py
โ โโโ doctor.py
โ โโโ handlers.py
โ โโโ utils.py
โ โโโ assets/
โ โ โโโ rules.json
โ โโโ checks/
โโโ tests/
โ โโโ test_cli.py
โ โโโ test_handler.py
โ โโโ test_*.py
โโโ docs/
โ โโโ index.md
โ โโโ usage.md
โ โโโ rules.md
โ โโโ diagnostics.md
โ โโโ development.md
โโโ examples/
โ โโโ basic-hello/
โ โโโ diagnose-output.md
โโโ ...
Makefile
: Defines common commands for creating the environment, running tests, linting, formatting, and publishing.pyproject.toml
andhatch.toml
: Configuration for Hatch environments and project metadata.src/azure_functions_doctor/
: Core application code, including CLI entrypoint, diagnostic logic, and rule assets.tests/
: Unit and integration tests for the project.docs/
: Documentation files used by MkDocs (if enabled) or GitHub pages.examples/
: Contains sample Azure Functions projects and expected outputs.
๐ Initial Setup
-
Clone the repository:
bash git clone https://github.com/yeongseon/azure-functions-doctor-for-python.git cd azure-functions-doctor-for-python
-
Create and activate a virtual environment using the Makefile:
bash make venv source .venv/bin/activate # On Windows (PowerShell): .venv\Scripts\Activate.ps1
-
Install project dependencies via Hatch (or using
uv
if preferred):bash make install # or, if using uv: uv install
-
Install pre-commit hooks for code formatting and linting:
bash make precommit-install
Note: The Makefile ensures Hatch commands run inside the appropriate environment. If you bypass Makefile, you can manually do:
bash hatch env create default hatch run pip install -r requirements-dev.txt hatch run pre-commit install
๐งช Running Tests and Quality Checks
1. Format Code
Use Black and Ruff via Makefile to enforce consistent styling:
make format
2. Lint Code
Run Ruff and Mypy for linting and type checks:
make lint
3. Type Checking
Perform static type analysis with Mypy:
make typecheck
4. Run Unit Tests
Execute all tests using pytest:
make test
5. Combined Quality Checks
Run formatting, linting, type checking, and tests in one command:
make check
6. Generate Coverage Report
Produce a coverage report (HTML + XML):
make cov
- Opens
htmlcov/index.html
for browser viewing - Generates
coverage.xml
for CI integrations (e.g., Codecov)
๐ฏ Development Workflow
-
Create a feature branch:
bash git checkout -b feature/your-description
-
Implement changes in
src/azure_functions_doctor/
and/or updaterules.json
undersrc/azure_functions_doctor/assets/
. -
Add new tests in the
tests/
directory to cover your changes. -
Run quality checks locally:
bash make check
-
Commit changes with Conventional Commits format:
git commit -m "feat: add new check for custom config file"
-
Push and open a Pull Request to
main
.
๐ Makefile Targets Reference
Target | Description |
---|---|
make venv |
Create a Python virtual environment at .venv/ |
make install |
Install runtime and dev dependencies via Hatch (hatch install ) |
make precommit-install |
Install pre-commit hooks (Black, Ruff, etc.) |
make format |
Format code with Black and apply Ruff fixes |
make lint |
Run Ruff and Mypy checks |
make typecheck |
Perform static type checking with Mypy |
make test |
Run pytest |
make check |
Run formatting, linting, typechecking, and tests in sequence |
make cov |
Generate coverage report and open HTML index |
make docs |
Serve MkDocs locally (if MkDocs configured) |
make release-patch |
Bump patch version, update changelog |
make release-minor |
Bump minor version, update changelog |
make release-major |
Bump major version, update changelog |
make publish |
Publish package to PyPI (requires credentials in environment) |
For detailed release workflow, refer to
release_process.md
.
๐ค Contributing
We welcome contributions! Please follow these steps:
- Fork the repository and create a new branch.
- Follow the Development Workflow above.
- Ensure tests pass and code quality checks succeed.
- Submit a Pull Request with a clear description of your changes.
Thank you for helping improve Azure Functions Doctor!
๐ License
This project is licensed under the MIT License.