A modern Python project template featuring comprehensive test coverage, continuous integration with CircleCI, and dependency management using UV. This template includes configurations for static type checking, code formatting, and automated testing.
- Python 3.10 or higher
- UV for Python dependency management
-
Clone the repository:
git clone <repository-url> cd <repository-name>
-
Install UV:
curl -LsSf https://astral.sh/uv/install.sh | sh -
Create a virtual environment:
uv venv .venv
Activate the virtual environment:
- On Unix/Linux/macOS:
source .venv/bin/activate - On Windows:
.venv\Scripts\activate
- On Unix/Linux/macOS:
-
Install dependencies and pre-commit hooks:
uv pip install ".[dev]" pre-commit install
Run type checking and code linting:
mypy src tests
ruff check . --config pyproject.tomlThe project includes unit, integration, and end-to-end tests:
# Run calculator unit tests
nose2 -v -s src/calculator/test/
# Run logger unit tests
nose2 -v -s src/logger/test/
# Run notifier unit tests
nose2 -v -s src/notifier/test/# Running all unit tests with coverage
nose2 -v -s src/calculator/test/ --with-coverage --coverage=src.calculator
COVERAGE_FILE=.coverage.logger nose2 -v -s src/logger/test/ --with-coverage --coverage=src.logger
COVERAGE_FILE=.coverage.notifier nose2 -v -s src/notifier/test/ --with-coverage --coverage=src.notifier
coverage combine .coverage .coverage.logger .coverage.notifier
coverage report --fail-under=70
coverage xml -o unit-coverage.xml
coverage html -d unit-htmlcovNote: The above commands work in a bash environment. You might need to adjust commands for your specific terminal.
# Run integration tests
nose2 -v -s tests/integration
# Run end-to-end tests
nose2 -v -s tests/e2e
# Run all tests
nose2Test coverage reports are generated in HTML format. View them by opening htmlcov/index.html in your browser.
This project uses CircleCI for continuous integration, which:
- Runs static analysis (mypy and ruff)
- Executes all test suites
- Generates and stores test reports
- Enforces minimum test coverage requirements
-
Create a new branch for your feature:
git checkout -b feature-name
-
Install pre-commit hooks:
pip install pre-commit pre-commit install
-
Make your changes and commit them:
git add . git commit -m "Your descriptive commit message"
The pre-commit hooks will automatically:
- Format your code using ruff-format
- Check for linting issues with ruff
- Verify type annotations with mypy
- Run unit tests to ensure all tests pass
-
Push your changes and create a pull request:
git push origin feature-name
If pre-commit identifies any issues, it will prevent the commit and display what needs to be fixed. Address the issues and try committing again.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.