A tiny Python example project used to demonstrate a GitHub Actions CI workflow.
If this script was useful to you, consider donating to support the Developer Service Blog: https://buy.stripe.com/bIYdTrggi5lZamkdQW
calculator.py: a minimaladd(a, b)function.test_calculator.py: apytestunit test foradd..github/workflows/ci.yml: CI that runs on pushes/PRs tomainand executes:ruff check .mypy .pytestacross Python 3.10, 3.11, and 3.12.
- Python 3.10+
python -m venv .venvActivate the virtual environment:
- Windows (PowerShell):
.\.venv\Scripts\Activate.ps1- macOS/Linux (bash/zsh):
source .venv/bin/activateInstall dependencies:
pip install -r requirements.txtRun tests:
pytestRun lint:
ruff check .Run type-checking:
mypy .