-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
322 lines (266 loc) · 9.5 KB
/
Copy pathMakefile
File metadata and controls
322 lines (266 loc) · 9.5 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# Groq Speech SDK Makefile
# Professional build automation and development workflows
.PHONY: help install install-dev test test-unit test-integration test-e2e test-coverage lint format type-check clean build docker-build docker-run docker-stop docs serve-docs release
# Variables
PYTHON := python3
PIP := pip3
PYTEST := pytest
COVERAGE := coverage
BLACK := black
FLAKE8 := flake8
MYPY := mypy
ISORT := isort
# Project information
PROJECT_NAME := groq-speech-sdk
VERSION := $(shell python -c "import groq_speech; print(groq_speech.__version__)")
PYTHON_VERSION := $(shell python --version)
# Directories
SRC_DIR := groq_speech
API_DIR := api
TESTS_DIR := tests
DOCS_DIR := docs
BUILD_DIR := build
DIST_DIR := dist
COVERAGE_DIR := htmlcov
# Files
REQUIREMENTS := requirements.txt
REQUIREMENTS_DEV := requirements-dev.txt
SETUP_PY := setup.py
README := README.md
DOCKERFILE := deployment/docker/Dockerfile
DOCKER_COMPOSE := deployment/docker/docker-compose.yml
# Default target
help: ## Show this help message
@echo "Groq Speech SDK - Development Commands"
@echo "======================================"
@echo ""
@echo "Available commands:"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Environment:"
@echo " Python: $(PYTHON_VERSION)"
@echo " Version: $(VERSION)"
@echo ""
# Installation
install: ## Install production dependencies
@echo "Installing production dependencies..."
$(PIP) install -r $(REQUIREMENTS)
@echo "✅ Production dependencies installed"
install-dev: ## Install development dependencies
@echo "Installing development dependencies..."
$(PIP) install -r $(REQUIREMENTS)
$(PIP) install -r $(REQUIREMENTS_DEV)
@echo "✅ Development dependencies installed"
install-editable: ## Install package in editable mode
@echo "Installing package in editable mode..."
$(PIP) install -e .
@echo "✅ Package installed in editable mode"
# Testing
test: ## Run all tests
@echo "Running all tests..."
$(PYTHON) run_tests.py --verbose
@echo "✅ All tests completed"
test-unit: ## Run unit tests only
@echo "Running unit tests..."
$(PYTHON) run_tests.py --unit --verbose
@echo "✅ Unit tests completed"
test-integration: ## Run integration tests only
@echo "Running integration tests..."
$(PYTHON) run_tests.py --e2e --verbose
@echo "✅ Integration tests completed"
test-e2e: ## Run end-to-end tests only
@echo "Running end-to-end tests..."
$(PYTHON) run_tests.py --e2e --verbose
@echo "✅ End-to-end tests completed"
test-cli: ## Run CLI tests only
@echo "Running CLI tests..."
$(PYTHON) run_tests.py --cli --verbose
@echo "✅ CLI tests completed"
test-api: ## Run API tests only
@echo "Running API tests..."
$(PYTHON) -m pytest tests/test_e2e_api.py -v --tb=short
@echo "✅ API tests completed"
test-quick: ## Run quick tests (unit tests only)
@echo "Running quick tests..."
$(PYTHON) run_tests.py --unit
@echo "✅ Quick tests completed"
test-performance: ## Run performance tests
@echo "Running performance tests..."
$(PYTEST) $(TESTS_DIR)/performance/ -v
@echo "✅ Performance tests completed"
test-coverage: ## Run tests with coverage report
@echo "Running tests with coverage..."
$(PYTEST) $(TESTS_DIR) --cov=$(SRC_DIR) --cov=$(API_DIR) --cov-report=html --cov-report=term
@echo "✅ Coverage report generated in $(COVERAGE_DIR)/"
test-watch: ## Run tests in watch mode
@echo "Running tests in watch mode..."
$(PYTEST) $(TESTS_DIR) -f -v
# Code Quality
lint: ## Run linting checks
@echo "Running linting checks..."
$(FLAKE8) $(SRC_DIR) $(API_DIR) $(TESTS_DIR)
@echo "✅ Linting completed"
format: ## Format code with black and isort
@echo "Formatting code..."
$(BLACK) $(SRC_DIR) $(API_DIR) $(TESTS_DIR)
$(ISORT) $(SRC_DIR) $(API_DIR) $(TESTS_DIR)
@echo "✅ Code formatting completed"
format-check: ## Check code formatting without making changes
@echo "Checking code formatting..."
$(BLACK) --check $(SRC_DIR) $(API_DIR) $(TESTS_DIR)
$(ISORT) --check-only $(SRC_DIR) $(API_DIR) $(TESTS_DIR)
@echo "✅ Code formatting check completed"
type-check: ## Run type checking with mypy
@echo "Running type checking..."
$(MYPY) $(SRC_DIR) $(API_DIR)
@echo "✅ Type checking completed"
quality: lint format-check type-check ## Run all code quality checks
@echo "✅ All code quality checks completed"
# Building
build: clean ## Build the package
@echo "Building package..."
$(PYTHON) setup.py sdist bdist_wheel
@echo "✅ Package built in $(DIST_DIR)/"
clean: ## Clean build artifacts
@echo "Cleaning build artifacts..."
rm -rf $(BUILD_DIR) $(DIST_DIR) $(COVERAGE_DIR)
find . -type d -name "__pycache__" -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
@echo "✅ Build artifacts cleaned"
# Docker
docker-build: ## Build Docker image
@echo "Building Docker image..."
docker build -f $(DOCKERFILE) -t $(PROJECT_NAME):latest .
@echo "✅ Docker image built"
docker-run: ## Run Docker container
@echo "Running Docker container..."
docker run -d --name $(PROJECT_NAME)-container -p 8000:8000 $(PROJECT_NAME):latest
@echo "✅ Docker container running on http://localhost:8000"
docker-stop: ## Stop Docker container
@echo "Stopping Docker container..."
docker stop $(PROJECT_NAME)-container || true
docker rm $(PROJECT_NAME)-container || true
@echo "✅ Docker container stopped"
docker-compose-up: ## Start services with Docker Compose
@echo "Starting services with Docker Compose..."
docker-compose -f $(DOCKER_COMPOSE) up -d
@echo "✅ Services started"
docker-compose-down: ## Stop services with Docker Compose
@echo "Stopping services with Docker Compose..."
docker-compose -f $(DOCKER_COMPOSE) down
@echo "✅ Services stopped"
docker-compose-logs: ## View Docker Compose logs
docker-compose -f $(DOCKER_COMPOSE) logs -f
# Documentation
docs: ## Build documentation
@echo "Building documentation..."
cd $(DOCS_DIR) && make html
@echo "✅ Documentation built"
serve-docs: ## Serve documentation locally
@echo "Serving documentation on http://localhost:8001..."
cd $(DOCS_DIR)/_build/html && python -m http.server 8001
# Development
dev-install: install-dev install-editable ## Install for development
@echo "✅ Development environment ready"
dev-setup: dev-install ## Complete development setup
@echo "Setting up pre-commit hooks..."
pre-commit install
@echo "✅ Development setup completed"
dev-test: quality test-coverage ## Run all development checks
@echo "✅ All development checks completed"
# Examples
examples: ## Run example scripts
@echo "Running examples..."
$(PYTHON) examples/basic_recognition.py
$(PYTHON) examples/continuous_recognition.py
@echo "✅ Examples completed"
demo: ## Run interactive demo
@echo "Running interactive demo..."
$(PYTHON) demo.py
@echo "✅ Demo completed"
# Configuration
config-test: ## Test configuration
@echo "Testing configuration..."
$(PYTHON) test_config.py
@echo "✅ Configuration test completed"
# Security
security-check: ## Run security checks
@echo "Running security checks..."
bandit -r $(SRC_DIR) $(API_DIR)
safety check
@echo "✅ Security checks completed"
# Performance
benchmark: ## Run performance benchmarks
@echo "Running performance benchmarks..."
$(PYTHON) -m pytest tests/performance/ -v --benchmark-only
@echo "✅ Performance benchmarks completed"
# Release
release: clean build test quality ## Prepare for release
@echo "Preparing release..."
@echo "Version: $(VERSION)"
@echo "✅ Release preparation completed"
release-publish: release ## Publish to PyPI
@echo "Publishing to PyPI..."
twine upload $(DIST_DIR)/*
@echo "✅ Package published to PyPI"
# Monitoring
monitor: ## Start monitoring services
@echo "Starting monitoring services..."
docker-compose -f $(DOCKER_COMPOSE) up -d prometheus grafana
@echo "✅ Monitoring services started"
@echo "Prometheus: http://localhost:9090"
@echo "Grafana: http://localhost:3000"
# Database
db-migrate: ## Run database migrations
@echo "Running database migrations..."
alembic upgrade head
@echo "✅ Database migrations completed"
db-rollback: ## Rollback database migrations
@echo "Rolling back database migrations..."
alembic downgrade -1
@echo "✅ Database rollback completed"
# Utilities
check-deps: ## Check for outdated dependencies
@echo "Checking for outdated dependencies..."
$(PIP) list --outdated
@echo "✅ Dependency check completed"
update-deps: ## Update dependencies
@echo "Updating dependencies..."
$(PIP) install --upgrade -r $(REQUIREMENTS)
$(PIP) install --upgrade -r $(REQUIREMENTS_DEV)
@echo "✅ Dependencies updated"
# Environment
env-create: ## Create virtual environment
@echo "Creating virtual environment..."
$(PYTHON) -m venv .venv
@echo "✅ Virtual environment created"
@echo "Activate with: source .venv/bin/activate"
env-activate: ## Activate virtual environment
@echo "Activating virtual environment..."
source .venv/bin/activate
# CI/CD
ci-test: lint format-check type-check test-coverage ## Run CI tests
@echo "✅ CI tests completed"
ci-build: ci-test build ## Run CI build
@echo "✅ CI build completed"
# Helpers
version: ## Show version information
@echo "Project: $(PROJECT_NAME)"
@echo "Version: $(VERSION)"
@echo "Python: $(PYTHON_VERSION)"
status: ## Show project status
@echo "Project Status"
@echo "=============="
@echo "Project: $(PROJECT_NAME)"
@echo "Version: $(VERSION)"
@echo "Python: $(PYTHON_VERSION)"
@echo ""
@echo "Directories:"
@ls -la | grep "^d"
@echo ""
@echo "Recent files:"
@ls -la --time-style=long-iso | head -10
# Default target
.DEFAULT_GOAL := help