-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (109 loc) · 4.26 KB
/
Makefile
File metadata and controls
134 lines (109 loc) · 4.26 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Detect container runtime (Docker or Podman)
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null)
ifdef CONTAINER_RUNTIME
COMPOSE_CMD = podman-compose
RUNTIME_NAME = Podman
else
CONTAINER_RUNTIME := $(shell command -v docker 2> /dev/null)
ifdef CONTAINER_RUNTIME
COMPOSE_CMD = docker-compose
RUNTIME_NAME = Docker
else
$(error Neither Docker nor Podman found. Please install one of them.)
endif
endif
# Test configuration
TEST_TYPE ?= all
TEST_SCRIPT = ./bin/run-tests.sh
.PHONY: help up down build logs clean restart ps test info
.PHONY: test-unit test-integration test-performance test-contract test-coverage test-fast
.PHONY: install-dev lint format quality clean-test
help: ## Display this help message
@echo "Available commands:"
@echo ""
@echo "🐳 Container Management:"
@grep -E '^[a-zA-Z_-]+:.*?## .*Container.*$$|^[a-zA-Z_-]+:.*?## .*service.*$$|^[a-zA-Z_-]+:.*?## .*image.*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "🧪 Testing:"
@grep -E '^test.*:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "🔧 Development:"
@grep -E '^[a-zA-Z_-]+:.*?## .*dev.*$$|^[a-zA-Z_-]+:.*?## .*lint.*$$|^[a-zA-Z_-]+:.*?## .*format.*$$|^[a-zA-Z_-]+:.*?## .*quality.*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "ℹ️ Other:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v -E 'Container|service|image|test|dev|lint|format|quality' | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
info: ## Show detected container runtime
@echo "Using: $(RUNTIME_NAME)"
@echo "Command: $(COMPOSE_CMD)"
@$(CONTAINER_RUNTIME) --version
up: ## Start all Container services
$(COMPOSE_CMD) up -d
down: ## Stop all Container services
$(COMPOSE_CMD) down
build: ## Build the agent API Container image
$(COMPOSE_CMD) build
logs: ## View logs from all Container services
$(COMPOSE_CMD) logs -f
logs-api: ## View logs from agent API Container only
$(COMPOSE_CMD) logs -f agent-api
logs-ui: ## View logs from Open Web UI Container only
$(COMPOSE_CMD) logs -f open-webui
clean: ## Remove all Container containers, volumes, and images
$(COMPOSE_CMD) down -v
$(COMPOSE_CMD) rm -f
restart: ## Restart all Container services
$(COMPOSE_CMD) restart
ps: ## Show running Container containers
$(COMPOSE_CMD) ps
# Testing targets
test: ## Run tests (TEST_TYPE=all|unit|integration|coverage)
@$(TEST_SCRIPT) $(TEST_TYPE)
test-unit: ## Run unit tests only
@$(TEST_SCRIPT) unit
test-integration: ## Run integration tests only
@$(TEST_SCRIPT) integration
test-coverage: ## Run tests with coverage report
@$(TEST_SCRIPT) coverage
# Development targets
install-dev: ## Install development dependencies
pip install -r requirements.dev.txt
lint: ## Run code linting
@if command -v flake8 >/dev/null 2>&1; then \
flake8 src tests; \
else \
echo "⚠️ flake8 not found. Run 'make install-dev' first"; \
fi
@if command -v mypy >/dev/null 2>&1; then \
mypy src; \
else \
echo "⚠️ mypy not found. Run 'make install-dev' first"; \
fi
format: ## Format code with black and isort
@if command -v black >/dev/null 2>&1; then \
black src tests; \
else \
echo "⚠️ black not found. Run 'make install-dev' first"; \
fi
@if command -v isort >/dev/null 2>&1; then \
isort src tests; \
else \
echo "⚠️ isort not found. Run 'make install-dev' first"; \
fi
quality: ## Run format, lint, and unit tests
@$(MAKE) format
@$(MAKE) lint
@$(MAKE) test-unit
clean-test: ## Clean test artifacts
rm -rf .pytest_cache htmlcov .coverage coverage.xml test-report.html
find . -name "*.pyc" -delete
find . -name "__pycache__" -delete
# API testing (for running services)
test-api: ## Test the running API endpoint
@echo "Testing API health..."
@curl -s http://localhost:8000/health | python3 -m json.tool
@echo "\nTesting models endpoint..."
@curl -s http://localhost:8000/v1/models | python3 -m json.tool
shell-api: ## Open shell in agent API Container
$(COMPOSE_CMD) exec agent-api /bin/bash
shell-db: ## Open PostgreSQL shell in Container
$(COMPOSE_CMD) exec postgres psql -U postgres -d openwebui