177 lines
4.9 KiB
Makefile
177 lines
4.9 KiB
Makefile
# Comprehensive Makefile for LetzShop API (Windows Compatible)
|
|
.PHONY: install install-test install-dev install-all dev test test-unit test-integration test-coverage test-fast test-slow test-auth test-products test-stock lint format check docker-build docker-up docker-down migrate clean check-tools setup setup-test
|
|
|
|
# Check if required tools are installed (Windows compatible)
|
|
check-tools:
|
|
@where black >nul 2>&1 || (echo black is required but not installed. Run 'make install-dev' first. && exit 1)
|
|
@where isort >nul 2>&1 || (echo isort is required but not installed. Run 'make install-dev' first. && exit 1)
|
|
@where flake8 >nul 2>&1 || (echo flake8 is required but not installed. Run 'make install-dev' first. && exit 1)
|
|
@where mypy >nul 2>&1 || (echo mypy is required but not installed. Run 'make install-dev' first. && exit 1)
|
|
|
|
# Development setup
|
|
install:
|
|
pip install -r requirements.txt
|
|
|
|
install-test:
|
|
pip install -r tests/requirements-test.txt
|
|
|
|
install-dev:
|
|
pip install -r requirements.txt
|
|
pip install -r tests/requirements-test.txt
|
|
pip install black isort flake8 mypy flake8-docstrings
|
|
|
|
install-all: install install-test install-dev
|
|
|
|
# Development server
|
|
dev:
|
|
uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
|
|
|
# Testing commands
|
|
test:
|
|
pytest tests/ -v
|
|
|
|
test-unit:
|
|
pytest tests/ -v -m unit
|
|
|
|
test-integration:
|
|
pytest tests/ -v -m integration
|
|
|
|
test-coverage:
|
|
pytest tests/ --cov=app --cov=models --cov=utils --cov=middleware --cov-report=html --cov-report=term-missing
|
|
|
|
test-fast:
|
|
pytest tests/ -v -m "not slow"
|
|
|
|
test-slow:
|
|
pytest tests/ -v -m slow
|
|
|
|
# Specific test files
|
|
test-auth:
|
|
pytest tests/test_auth.py -v
|
|
|
|
test-products:
|
|
pytest tests/test_products.py -v
|
|
|
|
test-stock:
|
|
pytest tests/test_stock.py -v
|
|
|
|
test-marketplace:
|
|
pytest tests/test_marketplace.py -v
|
|
|
|
test-admin:
|
|
pytest tests/test_admin.py -v
|
|
|
|
# Code quality (skip check-tools for now)
|
|
lint:
|
|
@echo Running flake8...
|
|
flake8 . --max-line-length=120 --extend-ignore=E203,W503,I201,I100 --exclude=venv,__pycache__,.git
|
|
@echo Running mypy...
|
|
mypy . --ignore-missing-imports --exclude venv
|
|
|
|
format:
|
|
@echo Running black...
|
|
black . --exclude venv
|
|
@echo Running isort...
|
|
isort . --skip venv
|
|
|
|
# Combined format and lint
|
|
check: format lint
|
|
|
|
# Combined test with coverage and linting
|
|
ci: format lint test-coverage
|
|
|
|
# Database migrations
|
|
migrate-create:
|
|
alembic revision --autogenerate -m "$(message)"
|
|
|
|
migrate-up:
|
|
alembic upgrade head
|
|
|
|
migrate-down:
|
|
alembic downgrade -1
|
|
|
|
migrate-reset:
|
|
alembic downgrade base
|
|
alembic upgrade head
|
|
|
|
# Docker commands
|
|
docker-build:
|
|
docker-compose build
|
|
|
|
docker-up:
|
|
docker-compose up -d
|
|
|
|
docker-down:
|
|
docker-compose down
|
|
|
|
docker-logs:
|
|
docker-compose logs -f api
|
|
|
|
docker-restart: docker-down docker-up
|
|
|
|
# Production deployment
|
|
deploy-staging:
|
|
docker-compose -f docker-compose.staging.yml up -d
|
|
|
|
deploy-prod:
|
|
docker-compose -f docker-compose.prod.yml up -d
|
|
|
|
# Clean up (Windows compatible)
|
|
clean:
|
|
@if exist htmlcov rmdir /s /q htmlcov
|
|
@if exist .pytest_cache rmdir /s /q .pytest_cache
|
|
@if exist .coverage del .coverage
|
|
@if exist .mypy_cache rmdir /s /q .mypy_cache
|
|
@for /d /r . %%d in (__pycache__) do @if exist "%%d" rmdir /s /q "%%d"
|
|
@del /s /q *.pyc 2>nul || echo No .pyc files found
|
|
|
|
# Development workflow shortcuts
|
|
setup: install-dev migrate-up
|
|
@echo Development environment setup complete!
|
|
|
|
setup-test: install-test
|
|
@echo Test environment setup complete!
|
|
|
|
full-test: format lint test-coverage
|
|
@echo Full test suite completed!
|
|
|
|
# Help command
|
|
help:
|
|
@echo Available commands:
|
|
@echo install - Install production dependencies
|
|
@echo install-test - Install test dependencies only
|
|
@echo install-dev - Install all development dependencies
|
|
@echo install-all - Install everything
|
|
@echo setup - Complete development setup
|
|
@echo setup-test - Setup test environment only
|
|
@echo dev - Start development server
|
|
@echo.
|
|
@echo Testing:
|
|
@echo test - Run all tests
|
|
@echo test-unit - Run unit tests only
|
|
@echo test-integration - Run integration tests only
|
|
@echo test-coverage - Run tests with coverage report
|
|
@echo test-fast - Run fast tests (exclude slow ones)
|
|
@echo test-slow - Run slow tests only
|
|
@echo full-test - Format, lint, and test with coverage
|
|
@echo.
|
|
@echo Code Quality:
|
|
@echo format - Format code with black and isort
|
|
@echo lint - Run linting with flake8 and mypy
|
|
@echo check - Format and lint code
|
|
@echo ci - Full CI pipeline (format, lint, test)
|
|
@echo.
|
|
@echo Database:
|
|
@echo migrate-up - Run database migrations
|
|
@echo migrate-down - Rollback last migration
|
|
@echo migrate-reset - Reset and rerun all migrations
|
|
@echo.
|
|
@echo Docker:
|
|
@echo docker-build - Build Docker containers
|
|
@echo docker-up - Start Docker containers
|
|
@echo docker-down - Stop Docker containers
|
|
@echo docker-restart - Restart Docker containers
|
|
@echo.
|
|
@echo Cleanup:
|
|
@echo clean - Remove test artifacts and cache files
|