-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
212 lines (172 loc) · 7.45 KB
/
Makefile
File metadata and controls
212 lines (172 loc) · 7.45 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# CodeFlow Engine - Development Makefile
# =====================================
# Usage: make [target]
# Run 'make help' for available commands
.PHONY: help install install-dev install-full clean clean-all test test-cov test-fast \
lint lint-fix format check run server worker \
docker-build docker-up docker-down docker-logs docker-shell docker-restart docker-clean \
setup-action setup-venv setup-poetry env deps-update docs quickstart
# Default target
.DEFAULT_GOAL := help
# Variables
PYTHON := python3
PIP := pip3
DOCKER_COMPOSE := docker compose
# Colors
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m
#------------------------------------------------------------------------------
# HELP
#------------------------------------------------------------------------------
help: ## Show this help message
@echo ""
@echo "CodeFlow Engine - Development Commands"
@echo "====================================="
@echo ""
@echo "$(BLUE)Installation:$(NC)"
@grep -E '^(install|setup)[a-zA-Z_-]*:.*?## ' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
@echo ""
@echo "$(BLUE)Development:$(NC)"
@grep -E '^(test|lint|format|check|run|server|worker)[a-zA-Z_-]*:.*?## ' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
@echo ""
@echo "$(BLUE)Docker:$(NC)"
@grep -E '^docker[a-zA-Z_-]*:.*?## ' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
@echo ""
@echo "$(BLUE)Utilities:$(NC)"
@grep -E '^(clean|env)[a-zA-Z_-]*:.*?## ' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
@echo ""
#------------------------------------------------------------------------------
# INSTALLATION
#------------------------------------------------------------------------------
install: ## Install CodeFlow Engine (standard)
@echo "$(BLUE)Installing CodeFlow Engine...$(NC)"
$(PIP) install -e .
@echo "$(GREEN)Installation complete!$(NC)"
install-dev: ## Install with development dependencies
@echo "$(BLUE)Installing CodeFlow Engine (development mode)...$(NC)"
$(PIP) install -e ".[dev]"
pre-commit install
@echo "$(GREEN)Development installation complete!$(NC)"
install-full: ## Install with all features
@echo "$(BLUE)Installing CodeFlow Engine (full)...$(NC)"
$(PIP) install -e ".[full]"
@echo "$(GREEN)Full installation complete!$(NC)"
setup-venv: ## Create and activate virtual environment
@echo "$(BLUE)Creating virtual environment...$(NC)"
$(PYTHON) -m venv venv
@echo "$(GREEN)Virtual environment created!$(NC)"
@echo "$(YELLOW)Activate with: source venv/bin/activate$(NC)"
setup-poetry: ## Install using Poetry
@echo "$(BLUE)Installing with Poetry...$(NC)"
poetry install
@echo "$(GREEN)Poetry installation complete!$(NC)"
setup-action: ## Create GitHub Action workflow in current repo
@echo "$(BLUE)Setting up GitHub Action...$(NC)"
@mkdir -p .github/workflows
@if [ -f templates/quick-start/codeflow-workflow.yml ]; then \
cp templates/quick-start/codeflow-workflow.yml .github/workflows/codeflow.yml; \
echo "$(GREEN)Copied from local templates$(NC)"; \
elif curl -sSL --fail https://raw.githubusercontent.com/JustAGhosT/codeflow-engine/master/engine/templates/quick-start/codeflow-workflow.yml -o .github/workflows/codeflow.yml; then \
echo "$(GREEN)Downloaded from GitHub$(NC)"; \
else \
echo "$(RED)Failed to set up GitHub Action$(NC)"; \
exit 1; \
fi
@echo "$(GREEN)Created .github/workflows/codeflow.yml$(NC)"
@echo "$(YELLOW)Remember to add OPENAI_API_KEY to your repository secrets!$(NC)"
#------------------------------------------------------------------------------
# DEVELOPMENT
#------------------------------------------------------------------------------
test: ## Run tests
@echo "$(BLUE)Running tests...$(NC)"
pytest tests/ -v
test-cov: ## Run tests with coverage
@echo "$(BLUE)Running tests with coverage...$(NC)"
pytest tests/ --cov=codeflow_engine --cov-report=html --cov-report=term
test-fast: ## Run tests (fast mode, stop on first failure)
@echo "$(BLUE)Running tests (fast mode)...$(NC)"
pytest tests/ -x -v
lint: ## Run linting checks
@echo "$(BLUE)Running linters...$(NC)"
ruff check codeflow_engine/
mypy codeflow_engine/ --ignore-missing-imports
lint-fix: ## Fix linting issues automatically
@echo "$(BLUE)Fixing linting issues...$(NC)"
ruff check codeflow_engine/ --fix
black codeflow_engine/
format: ## Format code with black and isort
@echo "$(BLUE)Formatting code...$(NC)"
black codeflow_engine/ tests/
isort codeflow_engine/ tests/
check: lint test ## Run all checks (lint + test)
run: ## Run the CLI
@echo "$(BLUE)Running CodeFlow CLI...$(NC)"
$(PYTHON) -m codeflow_engine.cli.main
server: ## Run the API server
@echo "$(BLUE)Starting API server...$(NC)"
$(PYTHON) -m codeflow_engine.server
worker: ## Run the background worker
@echo "$(BLUE)Starting background worker...$(NC)"
$(PYTHON) -m codeflow_engine.worker
#------------------------------------------------------------------------------
# DOCKER
#------------------------------------------------------------------------------
docker-build: ## Build Docker image
@echo "$(BLUE)Building Docker image...$(NC)"
docker build -t codeflow-engine:latest .
docker-up: ## Start all services with Docker Compose
@echo "$(BLUE)Starting Docker services...$(NC)"
$(DOCKER_COMPOSE) up -d
docker-down: ## Stop all Docker services
@echo "$(BLUE)Stopping Docker services...$(NC)"
$(DOCKER_COMPOSE) down
docker-logs: ## View Docker logs
$(DOCKER_COMPOSE) logs -f
docker-shell: ## Open shell in running container
$(DOCKER_COMPOSE) exec codeflow-engine bash
docker-restart: docker-down docker-up ## Restart Docker services
docker-clean: ## Remove Docker containers and volumes
@echo "$(YELLOW)Removing Docker containers and volumes...$(NC)"
$(DOCKER_COMPOSE) down -v --remove-orphans
#------------------------------------------------------------------------------
# UTILITIES
#------------------------------------------------------------------------------
env: ## Create .env file from template
@if [ ! -f .env ]; then \
cp .env.example .env; \
echo "$(GREEN)Created .env file$(NC)"; \
echo "$(YELLOW)Please edit .env with your API keys$(NC)"; \
else \
echo "$(YELLOW).env file already exists$(NC)"; \
fi
clean: ## Clean build artifacts
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
rm -rf build/ dist/ *.egg-info/ .pytest_cache/ .mypy_cache/ .ruff_cache/
rm -rf htmlcov/ .coverage
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@echo "$(GREEN)Clean complete!$(NC)"
clean-all: clean ## Clean everything including venv
rm -rf venv/
rm -rf .venv/
deps-update: ## Update dependencies
@echo "$(BLUE)Updating dependencies...$(NC)"
poetry update
docs: ## Build documentation
@echo "$(BLUE)Building documentation...$(NC)"
cd ../docs && make html
#------------------------------------------------------------------------------
# QUICK START
#------------------------------------------------------------------------------
quickstart: env install ## Quick start: create env and install
@echo ""
@echo "$(GREEN)============================================$(NC)"
@echo "$(GREEN)CodeFlow Engine is ready!$(NC)"
@echo "$(GREEN)============================================$(NC)"
@echo ""
@echo "Next steps:"
@echo " 1. Edit .env with your API keys"
@echo " 2. Run: make server"
@echo " 3. Or add to your repo: make setup-action"
@echo ""