-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
115 lines (95 loc) · 3.44 KB
/
Makefile
File metadata and controls
115 lines (95 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Makefile - Comandos simplificados para desarrollo
.PHONY: help build up down restart logs shell test clean seed test-cov test-unit test-integration test-mark coverage-report test-clean
# Mostrar ayuda
help:
@echo "Comandos disponibles:"
@echo " make build - Construir imágenes Docker"
@echo " make up - Levantar servicios"
@echo " make down - Detener servicios"
@echo " make restart - Reiniciar servicios"
@echo " make logs - Ver logs en tiempo real"
@echo " make shell - Abrir shell en el contenedor backend"
@echo " make test - Ejecutar tests"
@echo " make test-cov - Tests con coverage report HTML"
@echo " make test-unit - Tests solo unitarios"
@echo " make test-integration - Tests solo de integración"
@echo " make test-e2e - Tests E2E (requiere MongoDB)"
@echo " make test-mark - Tests con marcador específico (ej: make test-mark MARK=slow)"
@echo " make coverage-report - Ver reporte de coverage"
@echo " make seed - Inicializar base de datos con datos de prueba"
@echo " make clean - Limpiar contenedores y volúmenes"
@echo " make test-clean - Limpiar archivos de test"
# Construir imágenes
build:
cd deployments && docker compose build
# Levantar servicios
up:
cd deployments && docker compose up -d
@echo "✅ Servicios levantados"
@echo "📍 API: http://localhost:8000"
@echo "📍 Docs: http://localhost:8000/docs"
@echo "📍 MongoDB: localhost:27017"
# Detener servicios
down:
cd deployments && docker compose down
# Reiniciar servicios
restart: down up
# Ver logs en tiempo real
logs:
cd deployments && docker compose logs -f
# Logs solo del backend
logs-backend:
cd deployments && docker compose logs -f backend
# Logs solo de MongoDB
logs-mongodb:
cd deployments && docker compose logs -f mongodb
# Abrir shell en el contenedor backend
shell:
cd deployments && docker compose exec backend bash
# Inicializar base de datos con datos de prueba
seed:
cd deployments && docker compose exec backend python scripts/seed_data.py
# Tests
# Ejecutar tests dentro del contenedor (comando por defecto)
test:
cd deployments && docker compose exec backend pytest
# Tests con coverage
test-cov:
cd deployments && docker compose exec backend pytest --cov=app --cov-report=html
# Tests solo unitarios
test-unit:
cd deployments && docker compose exec backend pytest tests/unit -v
# Tests solo de integración
test-integration:
cd deployments && docker compose exec backend pytest tests/integration -v
# Tests solo E2E (requiere MongoDB)
test-e2e:
cd deployments && docker compose exec backend pytest tests/e2e -v
# Tests con marcador específico
test-mark:
ifndef MARK
@echo "❌ Error: Debes especificar un marcador. Uso: make test-mark MARK=nombre_marcador"
@exit 1
endif
cd deployments && docker compose exec backend pytest -m $(MARK)
# Ver reporte de coverage
coverage-report:
@echo "Abriendo reporte de coverage..."
@if command -v open > /dev/null 2>&1; then \
open htmlcov/index.html; \
elif command -v xdg-open > /dev/null 2>&1; then \
xdg-open htmlcov/index.html; \
else \
echo "Reporte disponible en: htmlcov/index.html"; \
fi
# Limpiar contenedores, imágenes y volúmenes
clean:
cd deployments && docker compose down -v
@echo "✅ Contenedores y volúmenes eliminados"
# Limpiar archivos de test
test-clean:
rm -rf .pytest_cache
rm -rf htmlcov
rm -f .coverage
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
@echo "✅ Archivos de test limpiados"