-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
291 lines (258 loc) · 9.03 KB
/
Copy pathMakefile
File metadata and controls
291 lines (258 loc) · 9.03 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
# Devix Makefile
# Modern Python Package Management with UV
.PHONY: help install build test run analyze publish version clean dev lint format check setup
# Python and UV configuration
PYTHON := python3
UV := uv
PACKAGE_NAME := devix
SRC_DIR := src
TEST_DIR := tests
# Version management
VERSION_FILE := $(SRC_DIR)/$(PACKAGE_NAME)/__init__.py
# Default target
help:
@echo "🔧 Devix - Modern Code Analysis Package"
@echo ""
@echo "📦 Package Management:"
@echo " make install - Install dependencies with UV"
@echo " make build - Build the package"
@echo " make publish - Publish to PyPI (auto-bumps version)"
@echo " make publish-test - Publish to Test PyPI (auto-bumps version)"
@echo " make version - Show current version"
@echo " make version-bump VERSION=x.y.z - Bump to specific version"
@echo " make version-bump-auto - Auto-increment patch version"
@echo ""
@echo "🧪 Development & Testing:"
@echo " make test - Run all tests"
@echo " make test-unit - Run unit tests only"
@echo " make test-integration - Run integration tests"
@echo " make lint - Run linting (flake8, pylint)"
@echo " make format - Format code (black, isort)"
@echo " make check - Type checking with mypy"
@echo ""
@echo "🚀 Usage:"
@echo " make run - Run devix analysis on current project"
@echo " make analyze - Run devix with custom path"
@echo " make dev - Install in development mode"
@echo ""
@echo "🧹 Maintenance:"
@echo " make clean - Clean build artifacts"
@echo " make setup - Setup development environment"
@echo " make status - Show comprehensive project status"
@echo ""
@echo "🐳 Docker Commands:"
@echo " make docker-build - Build Docker image"
@echo " make docker-run - Run Devix in Docker container"
@echo " make docker-shell - Open interactive Docker shell"
@echo " make docker-clean - Clean Docker images"
@echo ""
@echo "🚀 Advanced:"
@echo " make watch - Watch mode (continuous analysis)"
@echo " make init-project - Initialize new project for Devix"
@echo " make dev-workflow - Complete development workflow"
@echo " make ci - CI/CD pipeline simulation"
@echo ""
@echo "📖 Usage Examples:"
@echo " make run # Analyze current directory"
@echo " make analyze PATH=../myproject # Analyze specific project"
@echo " make publish VERSION=1.0.1 # Publish with version bump"
@echo " make docker-run # Run analysis in Docker"
@echo " make watch # Continuous analysis mode"
# Development setup
setup:
@echo "🛠️ Setting up Devix development environment..."
@if ! command -v uv &> /dev/null; then \
echo "UV not found. You can install it manually with:"; \
echo " curl -LsSf https://astral.sh/uv/install.sh | sh"; \
echo "Or continue using pip/build/twine for package management."; \
else \
echo "✅ UV found and ready to use"; \
fi
@echo "✅ Development environment ready"
# Install dependencies
install:
@echo "📦 Installing dependencies..."
@if false; then \
echo "Using UV..."; \
$(UV) sync; \
else \
echo "Using pip..."; \
$(PYTHON) -m pip install -e .; \
$(PYTHON) -m pip install pytest coverage flake8 pylint black isort build twine; \
fi
@echo "✅ Dependencies installed"
# Development installation
dev: install
@echo "🔧 Installing in development mode..."
$(PYTHON) -m pip install -e .
@echo "✅ Development installation complete"
# Build package
build:
@echo "🏗️ Building Devix package..."
@$(PYTHON) -m build
@echo "✅ Package built successfully"
# Run devix analysis
run:
@echo "🚀 Running Devix analysis..."
@echo "📁 Project: $$(pwd)/.."
cd .. && PYTHONPATH=$$(pwd)/devix/$(SRC_DIR) $(PYTHON) -m devix analyze
# Run devix with custom path
analyze:
@echo "🔍 Running Devix analysis..."
@if [ -n "$(PROJECT_PATH)" ]; then \
echo "📁 Project: $(PROJECT_PATH)"; \
PYTHONPATH=$$(pwd)/$(SRC_DIR) $(PYTHON) -m devix analyze $(PROJECT_PATH); \
else \
echo "📁 Project: $$(pwd)/.."; \
cd .. && PYTHONPATH=$$(pwd)/devix/$(SRC_DIR) $(PYTHON) -m devix analyze; \
fi
# Testing
test:
@echo "🧪 Running all Devix tests..."
$(PYTHON) -m pytest test_devix_integration.py -v --override-ini addopts=
@echo "✅ Tests completed"
test-unit:
@echo "🧪 Running unit tests..."
$(PYTHON) -m pytest $(TEST_DIR)/ -v --override-ini addopts= --cov=$(SRC_DIR) --cov-report=term
@echo "✅ Unit tests completed"
test-integration:
@echo "🧪 Running integration tests..."
$(PYTHON) test_devix_integration.py
@echo "✅ Integration tests completed"
# Code quality
lint:
@echo "🔍 Running linting..."
$(PYTHON) -m flake8 $(SRC_DIR)/$(PACKAGE_NAME)
$(PYTHON) -m pylint $(SRC_DIR)/$(PACKAGE_NAME)
@echo "✅ Linting completed"
format:
@echo "🎨 Formatting code..."
$(PYTHON) -m black $(SRC_DIR) $(TEST_DIR)
$(PYTHON) -m isort $(SRC_DIR) $(TEST_DIR)
@echo "✅ Code formatted"
check:
@echo "🔍 Type checking..."
$(PYTHON) -m mypy $(SRC_DIR)/$(PACKAGE_NAME)
@echo "✅ Type checking completed"
# Version management
version:
@echo "📋 Current version:"
@grep "__version__" $(VERSION_FILE) | sed 's/.*= *"\([^"]*\)".*/\1/'
version-bump:
@echo "🔢 Bumping version..."
@if [ -z "$(VERSION)" ]; then \
echo "❌ Please specify VERSION: make version-bump VERSION=1.0.1"; \
exit 1; \
fi
@sed -i 's/__version__ = "[^"]*"/__version__ = "$(VERSION)"/' $(VERSION_FILE)
@sed -i 's/version = "[^"]*"/version = "$(VERSION)"/' pyproject.toml
@echo "✅ Version bumped to $(VERSION) in both files"
version-bump-auto:
@echo "🔢 Auto-bumping version..."
@CURRENT_VERSION=$$(grep "__version__" $(VERSION_FILE) | sed 's/.*= *"\([^"]*\)".*/\1/'); \
echo "📋 Current version: $$CURRENT_VERSION"; \
NEW_VERSION=$$(echo $$CURRENT_VERSION | awk -F. '{$$NF=$$NF+1; print $$1"."$$2"."$$NF}'); \
echo "📈 New version: $$NEW_VERSION"; \
sed -i 's/__version__ = "[^"]*"/__version__ = "'"$$NEW_VERSION"'"/' $(VERSION_FILE); \
sed -i 's/version = "[^"]*"/version = "'"$$NEW_VERSION"'"/' pyproject.toml; \
echo "✅ Version auto-bumped to $$NEW_VERSION in both files"
# Publishing
publish:
@echo "📤 Publishing to PyPI..."
@echo "🧹 Cleaning previous builds..."
@make clean > /dev/null 2>&1 || true
@if [ -n "$(VERSION)" ]; then \
make version-bump VERSION=$(VERSION); \
else \
make version-bump-auto; \
fi
@echo "🏗️ Building package with new version..."
@make build
@if false; then \
echo "Using UV for publishing..."; \
$(UV) publish; \
else \
echo "Using twine for publishing..."; \
$(PYTHON) -m pip install --upgrade twine; \
$(PYTHON) -m twine upload dist/*; \
fi
@echo "✅ Package published successfully"
publish-test:
@echo "📤 Publishing to Test PyPI..."
@echo "🧹 Cleaning previous builds..."
@make clean > /dev/null 2>&1 || true
@if [ -n "$(VERSION)" ]; then \
make version-bump VERSION=$(VERSION); \
else \
make version-bump-auto; \
fi
@echo "🏗️ Building package with new version..."
@make build
@if false; then \
echo "Using UV for publishing to Test PyPI..."; \
$(UV) publish --repository testpypi; \
else \
echo "Using twine for publishing to Test PyPI..."; \
$(PYTHON) -m pip install --upgrade twine; \
$(PYTHON) -m twine upload --repository testpypi dist/*; \
fi
@echo "✅ Package published to Test PyPI"
# Generate report
report:
@echo "📊 Generating Devix analysis report..."
$(PYTHON) -m devix analyze --output-format both --output-dir reports/
@echo "✅ Report generated in reports/ directory"
# Clean build artifacts and cache
clean:
@echo "🧹 Cleaning build artifacts..."
rm -rf build/
rm -rf dist/
rm -rf *.egg-info/
rm -rf .pytest_cache/
rm -rf __pycache__/
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -name "*.pyc" -delete
find . -name "*.pyo" -delete
find . -name "*.pyd" -delete
find . -name ".coverage" -delete
find . -name "*.cover" -delete
find . -name "*.log" -delete
@echo "✅ Cleanup completed"
# Show package information
info:
@echo "📋 Devix Package Information"
@echo "================================"
@echo "Package: $(PACKAGE_NAME)"
@echo "Source: $(SRC_DIR)/$(PACKAGE_NAME)"
@echo "Tests: $(TEST_DIR)"
@echo "Python: $(PYTHON)"
@echo "UV: $(UV)"
@echo ""
@echo "📊 Project Statistics:"
@find $(SRC_DIR) -name "*.py" | wc -l | sed 's/^/Python files: /'
@find $(SRC_DIR) -name "*.py" -exec cat {} \; | wc -l | sed 's/^/Lines of code: /'
# Quick development workflow
dev-workflow: clean lint test build
@echo "🎉 Development workflow completed successfully!"
# CI/CD pipeline simulation
ci: clean lint test build
@echo "🚀 CI Pipeline completed successfully!"
# Watch mode - continuous development
watch:
@echo "👀 Starting watch mode..."
@./scripts/watch.sh
# Docker commands (for containerization)
docker-build:
@./scripts/docker.sh build
docker-run:
@./scripts/docker.sh run
docker-shell:
@./scripts/docker.sh shell
docker-clean:
@./scripts/docker.sh clean
# Project initialization for new users
init-project:
@./scripts/init-project.sh
# Project status check
status:
@./scripts/status.sh