|
| 1 | +# Cachier Makefile |
| 2 | +# Development tasks and shortcuts |
| 3 | + |
| 4 | +.PHONY: help test test-all test-mongo-local test-mongo-docker test-mongo-inmemory \ |
| 5 | + test-mongo-also-local mongo-start mongo-stop mongo-logs lint type-check format clean \ |
| 6 | + install install-dev install-all |
| 7 | + |
| 8 | +# Default target |
| 9 | +help: |
| 10 | + @echo "Cachier Development Commands:" |
| 11 | + @echo "" |
| 12 | + @echo "Testing:" |
| 13 | + @echo " make test - Run all tests" |
| 14 | + @echo " make test-mongo-local - Run MongoDB tests with Docker" |
| 15 | + @echo " make test-mongo-also-local - Run MongoDB + memory, pickle, maxage tests with Docker" |
| 16 | + @echo " make test-mongo-inmemory - Run MongoDB tests with in-memory backend" |
| 17 | + @echo " make mongo-start - Start MongoDB container" |
| 18 | + @echo " make mongo-stop - Stop MongoDB container" |
| 19 | + @echo " make mongo-logs - View MongoDB container logs" |
| 20 | + @echo "" |
| 21 | + @echo "Code Quality:" |
| 22 | + @echo " make lint - Run ruff linter" |
| 23 | + @echo " make type-check - Run mypy type checker" |
| 24 | + @echo " make format - Format code with ruff" |
| 25 | + @echo "" |
| 26 | + @echo "Installation:" |
| 27 | + @echo " make install - Install package" |
| 28 | + @echo " make install-dev - Install with development dependencies" |
| 29 | + @echo " make install-all - Install with all optional dependencies" |
| 30 | + @echo "" |
| 31 | + @echo "Other:" |
| 32 | + @echo " make clean - Clean build artifacts" |
| 33 | + |
| 34 | +# Installation targets |
| 35 | +install: |
| 36 | + pip install -e . |
| 37 | + |
| 38 | +install-dev: |
| 39 | + pip install -e . |
| 40 | + pip install -r tests/requirements.txt |
| 41 | + |
| 42 | +install-all: |
| 43 | + pip install -e .[all] |
| 44 | + pip install -r tests/requirements.txt |
| 45 | + pip install -r tests/sql_requirements.txt |
| 46 | + pip install -r tests/redis_requirements.txt |
| 47 | + |
| 48 | +# Testing targets |
| 49 | +test: |
| 50 | + pytest |
| 51 | + |
| 52 | +test-all: test |
| 53 | + |
| 54 | +# MongoDB testing targets |
| 55 | +test-mongo-inmemory: |
| 56 | + @echo "Running MongoDB tests with in-memory backend..." |
| 57 | + pytest -m mongo --cov=cachier --cov-report=term |
| 58 | + |
| 59 | +test-mongo-docker: |
| 60 | + @echo "Running MongoDB tests against Docker MongoDB..." |
| 61 | + ./scripts/test-mongo-local.sh |
| 62 | + |
| 63 | +test-mongo-local: test-mongo-docker |
| 64 | + |
| 65 | +test-mongo-also-local: |
| 66 | + @echo "Running MongoDB tests with local core tests..." |
| 67 | + ./scripts/test-mongo-local.sh --mode also-local |
| 68 | + |
| 69 | +# MongoDB container management |
| 70 | +mongo-start: |
| 71 | + @echo "Starting MongoDB container..." |
| 72 | + @docker ps -q -f name=cachier-test-mongo | grep -q . && \ |
| 73 | + (echo "MongoDB container already running" && exit 0) || \ |
| 74 | + (docker run -d -p 27017:27017 --name cachier-test-mongo mongo:latest && \ |
| 75 | + echo "Waiting for MongoDB to start..." && sleep 5) |
| 76 | + |
| 77 | +mongo-stop: |
| 78 | + @echo "Stopping MongoDB container..." |
| 79 | + @docker ps -q -f name=cachier-test-mongo | grep -q . && \ |
| 80 | + (docker stop cachier-test-mongo && docker rm cachier-test-mongo) || \ |
| 81 | + echo "MongoDB container not running" |
| 82 | + |
| 83 | +mongo-logs: |
| 84 | + @docker logs cachier-test-mongo |
| 85 | + |
| 86 | +# Code quality targets |
| 87 | +lint: |
| 88 | + ruff check . |
| 89 | + |
| 90 | +type-check: |
| 91 | + mypy src/cachier/ |
| 92 | + |
| 93 | +format: |
| 94 | + ruff format . |
| 95 | + |
| 96 | +# Clean targets |
| 97 | +clean: |
| 98 | + rm -rf build/ |
| 99 | + rm -rf dist/ |
| 100 | + rm -rf *.egg-info |
| 101 | + rm -rf .coverage |
| 102 | + rm -rf htmlcov/ |
| 103 | + rm -rf .pytest_cache/ |
| 104 | + rm -rf .mypy_cache/ |
| 105 | + rm -rf .ruff_cache/ |
| 106 | + find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true |
| 107 | + find . -type f -name "*.pyc" -delete |
0 commit comments