|
1 | | -.PHONY: help install install-dev test test-cov lint format clean run-server run-client build docker-build docker-run pre-commit docs docs-serve |
| 1 | +.PHONY: help test clean format check install |
2 | 2 |
|
3 | | -help: ## Show this help message |
4 | | - @echo "Usage: make [target]" |
5 | | - @echo "" |
6 | | - @echo "Available targets:" |
7 | | - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' |
8 | | - |
9 | | -install: ## Install production dependencies |
10 | | - pip install -r requirements.txt |
11 | | - |
12 | | -install-dev: ## Install development dependencies |
13 | | - pip install -r requirements-dev.txt |
14 | | - pip install -e . |
15 | | - pre-commit install |
16 | | - |
17 | | -test: ## Run tests |
18 | | - pytest tests/ -v |
19 | | - |
20 | | -test-cov: ## Run tests with coverage |
21 | | - pytest tests/ --cov=src --cov-report=term-missing --cov-report=html:coverage/htmlcov --cov-report=xml:coverage/coverage.xml |
| 3 | +PYTHON := $(if $(wildcard .venv/bin/python),.venv/bin/python,python3) |
| 4 | +PIP := $(if $(wildcard .venv/bin/pip),.venv/bin/pip,pip3) |
| 5 | +SOURCES := tests |
22 | 6 |
|
23 | | -test-watch: ## Run tests in watch mode |
24 | | - pytest-watch tests/ -v |
25 | | - |
26 | | -lint: ## Run linting checks |
27 | | - @echo "Running flake8..." |
28 | | - flake8 src/ tests/ |
29 | | - @echo "Running mypy..." |
30 | | - mypy src/ |
31 | | - @echo "Running ruff..." |
32 | | - ruff check src/ tests/ |
33 | | - |
34 | | -format: ## Format code with black and isort |
35 | | - black src/ tests/ |
36 | | - isort src/ tests/ |
37 | | - ruff check --fix src/ tests/ |
38 | | - |
39 | | -clean: ## Clean up generated files |
| 7 | +# Default target |
| 8 | +help: |
| 9 | + @echo "Available targets:" |
| 10 | + @echo " test Run tests" |
| 11 | + @echo " format Format code with black and isort" |
| 12 | + @echo " check Run format and tests" |
| 13 | + @echo " clean Clean up generated files" |
| 14 | + @echo " install Install dependencies" |
| 15 | + @echo " update Update dependencies" |
| 16 | + |
| 17 | +# Testing |
| 18 | +test: |
| 19 | + $(PYTHON) -m pytest tests/ -v --tb=short |
| 20 | + |
| 21 | +# Code formatting |
| 22 | +format: |
| 23 | + $(PYTHON) -m black $(SOURCES) tests/ |
| 24 | + $(PYTHON) -m isort $(SOURCES) tests/ |
| 25 | + |
| 26 | +# Combined check |
| 27 | +check: format test |
| 28 | + |
| 29 | +# Installation |
| 30 | +install: |
| 31 | + $(PIP) install -r requirements.txt |
| 32 | + $(PIP) install -r requirements-dev.txt |
| 33 | + |
| 34 | +# Updates |
| 35 | +update: |
| 36 | + $(PIP) install --upgrade pip |
| 37 | + $(PIP) install --upgrade -r requirements.txt |
| 38 | + $(PIP) install --upgrade -r requirements-dev.txt |
| 39 | + |
| 40 | +# Clean up |
| 41 | +clean: |
| 42 | + rm -rf build/ dist/ *.egg-info .pytest_cache/ .mypy_cache/ |
| 43 | + find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true |
40 | 44 | find . -type f -name "*.pyc" -delete |
41 | | - find . -type d -name "__pycache__" -delete |
42 | | - find . -type d -name ".pytest_cache" -exec rm -rf {} + |
43 | | - find . -type d -name ".mypy_cache" -exec rm -rf {} + |
44 | | - find . -type d -name ".ruff_cache" -exec rm -rf {} + |
45 | | - rm -rf coverage/ |
46 | | - rm -rf htmlcov/ |
47 | | - rm -f coverage.xml coverage.json .coverage |
48 | | - rm -rf dist/ build/ *.egg-info src/*.egg-info |
49 | | - |
50 | | -run-server: ## Run the WebSocket server |
51 | | - python src/pubsub_ws.py |
52 | | - |
53 | | -run-client: ## Run the client |
54 | | - python src/client.py |
55 | | - |
56 | | -build: ## Build the package |
57 | | - python -m build |
58 | | - |
59 | | -docker-build: ## Build Docker image |
60 | | - docker build -t python.publisher.subscriber:latest . |
61 | | - |
62 | | -docker-run: ## Run Docker container |
63 | | - docker run -p 5000:5000 python.publisher.subscriber:latest |
64 | | - |
65 | | -pre-commit: ## Run pre-commit hooks |
66 | | - pre-commit run --all-files |
67 | | - |
68 | | -docs: ## Generate documentation |
69 | | - cd docs && make html |
70 | | - |
71 | | -docs-serve: ## Serve documentation locally |
72 | | - cd docs && python -m http.server --directory _build/html 8000 |
0 commit comments