-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
296 lines (263 loc) · 12.5 KB
/
Makefile
File metadata and controls
296 lines (263 loc) · 12.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
.PHONY: build-dist \
clean-artifacts clean-venv \
help \
install-dev install-prod \
quality-check quality-format quality-format-check quality-lint \
serve-all 5555-serve-event-flow 5556-serve-event-recorder 5557-serve-mock-exchange 5558-serve-scenario-testing \
setup-dev setup-venv \
test tests test-coverage test-unit
# ============================================================================
# VARIABLES
# ============================================================================
PYTHON := python3
PIP := pip
PROJECT_NAME := python_pubsub_devtools
PROJECT_PATH := src/python_pubsub_devtools
VENV := .venv
CONFIG := devtools_config.yaml
# ============================================================================
# HELP
# ============================================================================
help:
@echo "╔══════════════════════════════════════════════════════════════════╗"
@echo "║ PubSub DevTools - Makefile Commands ║"
@echo "╚══════════════════════════════════════════════════════════════════╝"
@echo ""
@echo "📦 Build:"
@echo " make build-dist Build distribution packages"
@echo ""
@echo "🧹 Clean:"
@echo " make clean-artifacts Remove build artifacts and cache"
@echo " make clean-venv Remove virtual environment"
@echo ""
@echo "📦 Installation:"
@echo " make install-dev Install with dev dependencies (editable)"
@echo " make install-prod Install in production mode"
@echo ""
@echo "✨ Quality:"
@echo " make quality-check Run all quality checks (format + lint + test)"
@echo " make quality-format Format code with black"
@echo " make quality-format-check Check formatting without modifying"
@echo " make quality-lint Run linting (flake8 + mypy)"
@echo ""
@echo "🚀 Run Services (using $(CONFIG)):"
@echo " make serve-all Launch all services simultaneously"
@echo " make 5555-serve-event-flow Launch Event Flow Visualization (port 5555)"
@echo " make 5556-serve-event-recorder Launch Event Recorder Dashboard (port 5556)"
@echo " make 5557-serve-mock-exchange Launch Mock Exchange Simulator (port 5557)"
@echo " make 5558-serve-scenario-testing Launch Scenario Testing Dashboard (port 5558)"
@echo ""
@echo "⚙️ Setup:"
@echo " make setup-dev Complete dev setup (venv + install-dev)"
@echo " make setup-venv Create virtual environment"
@echo ""
@echo "🧪 Testing:"
@echo " make test Run unit tests (alias for test-unit)"
@echo " make tests Run unit tests (alias for test-unit)"
@echo " make test-unit Run unit tests with pytest"
@echo " make test-coverage Run tests with coverage report"
@echo ""
# ============================================================================
# BUILD
# ============================================================================
build-dist: clean-artifacts
@echo "📦 Building distribution packages..."
$(PYTHON) -m pip install --upgrade build
$(PYTHON) -m build
@echo "✅ Build complete! Packages in dist/"
# ============================================================================
# CLEAN
# ============================================================================
clean-artifacts:
@echo "🧹 Cleaning build artifacts..."
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf src/*.egg-info
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf .coverage
rm -rf htmlcov/
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
@echo "✅ Clean complete!"
clean-venv:
@echo "🧹 Removing virtual environment..."
rm -rf $(VENV)
@echo "✅ Virtual environment removed!"
# ============================================================================
# INSTALLATION
# ============================================================================
install-dev:
@echo "📦 Installing $(PROJECT_NAME) in development mode..."
@if [ ! -d "$(VENV)" ]; then \
make setup-venv; \
fi
@. $(VENV)/bin/activate && $(PIP) install --upgrade pip setuptools wheel
@. $(VENV)/bin/activate && $(PIP) install -e ".[dev]"
@echo "✅ Development installation complete!"
@echo ""
@echo "💡 To use the CLI, either:"
@echo " 1. Activate venv: source $(VENV)/bin/activate"
@echo " 2. Use make commands (automatic venv activation)"
install-prod:
@echo "📦 Installing $(PROJECT_NAME)..."
@if [ -d "$(VENV)" ]; then \
. $(VENV)/bin/activate && $(PIP) install .; \
else \
$(PIP) install .; \
fi
@echo "✅ Installation complete!"
# ============================================================================
# QUALITY
# ============================================================================
quality-check: quality-format-check quality-lint test-unit
@echo ""
@echo "╔══════════════════════════════════════════════════════════════════╗"
@echo "║ ✅ All checks passed! ║"
@echo "╚══════════════════════════════════════════════════════════════════╝"
quality-format:
@echo "✨ Formatting code with black..."
@if [ -d "$(VENV)" ]; then \
. $(VENV)/bin/activate && black $(PROJECT_PATH) tests/; \
else \
black $(PROJECT_PATH) tests/; \
fi
@echo "✅ Formatting complete!"
quality-format-check:
@echo "🔍 Checking code formatting..."
@if [ -d "$(VENV)" ]; then \
. $(VENV)/bin/activate && black $(PROJECT_PATH) tests/ --check; \
else \
black $(PROJECT_PATH) tests/ --check; \
fi
quality-lint:
@echo "🔍 Running flake8..."
@if [ -d "$(VENV)" ]; then \
. $(VENV)/bin/activate && flake8 $(PROJECT_PATH) tests/ --max-line-length=100 --exclude=__pycache__,.venv,build,dist; \
else \
flake8 $(PROJECT_PATH) tests/ --max-line-length=100 --exclude=__pycache__,.venv,build,dist; \
fi
@echo "🔍 Running mypy..."
@if [ -d "$(VENV)" ]; then \
. $(VENV)/bin/activate && mypy $(PROJECT_PATH) --ignore-missing-imports; \
else \
mypy $(PROJECT_PATH) --ignore-missing-imports; \
fi
@echo "✅ Linting complete!"
# ============================================================================
# RUN SERVICES
# ============================================================================
check-config: check-installed
@if [ ! -f $(CONFIG) ]; then \
echo "❌ Configuration file not found: $(CONFIG)"; \
echo ""; \
echo "💡 Create one with:"; \
echo " pubsub-tools config-example -o $(CONFIG)"; \
exit 1; \
fi
check-installed:
@if [ ! -d "$(VENV)" ]; then \
echo "❌ Virtual environment not found!"; \
echo ""; \
echo "💡 Install with:"; \
echo " make install-dev"; \
echo ""; \
exit 1; \
fi
@if ! [ -f "$(VENV)/bin/pubsub-tools" ]; then \
echo "❌ Package not installed in venv!"; \
echo ""; \
echo "💡 Install with:"; \
echo " make install-dev"; \
echo ""; \
exit 1; \
fi
serve-all: check-config
@echo "╔══════════════════════════════════════════════════════════════════╗"
@echo "║ 🚀 Launching ALL DevTools Services ║"
@echo "╚══════════════════════════════════════════════════════════════════╝"
@echo ""
@echo "📊 Event Flow: http://localhost:5555"
@echo "🎬 Event Recorder: http://localhost:5556"
@echo "🎰 Mock Exchange: http://localhost:5557"
@echo "🎯 Scenario Testing: http://localhost:5558"
@echo ""
@echo "⚙️ Config: $(CONFIG)"
@echo ""
@echo "Press Ctrl+C to stop all services"
@echo ""
@. $(VENV)/bin/activate && pubsub-tools serve-all --config $(CONFIG)
5555-serve-event-flow: check-config
@echo "╔══════════════════════════════════════════════════════════════════╗"
@echo "║ 🎯 Launching Event Flow Visualization ║"
@echo "╚══════════════════════════════════════════════════════════════════╝"
@echo ""
@echo "📊 Dashboard: http://localhost:5555"
@echo "⚙️ Config: $(CONFIG)"
@echo ""
@. $(VENV)/bin/activate && pubsub-tools event-flow --config $(CONFIG)
5556-serve-event-recorder: check-config
@echo "╔══════════════════════════════════════════════════════════════════╗"
@echo "║ 🎬 Launching Event Recorder Dashboard ║"
@echo "╚══════════════════════════════════════════════════════════════════╝"
@echo ""
@echo "📊 Dashboard: http://localhost:5556"
@echo "⚙️ Config: $(CONFIG)"
@echo ""
@. $(VENV)/bin/activate && pubsub-tools event-recorder --config $(CONFIG)
5557-serve-mock-exchange: check-config
@echo "╔══════════════════════════════════════════════════════════════════╗"
@echo "║ 🎰 Launching Mock Exchange Simulator ║"
@echo "╚══════════════════════════════════════════════════════════════════╝"
@echo ""
@echo "📊 Dashboard: http://localhost:5557"
@echo "⚙️ Config: $(CONFIG)"
@echo ""
@. $(VENV)/bin/activate && pubsub-tools mock-exchange --config $(CONFIG)
5558-serve-scenario-testing: check-config
@echo "╔══════════════════════════════════════════════════════════════════╗"
@echo "║ 🎯 Launching Scenario Testing Dashboard ║"
@echo "╚══════════════════════════════════════════════════════════════════╝"
@echo ""
@echo "📊 Dashboard: http://localhost:5558"
@echo "⚙️ Config: $(CONFIG)"
@echo ""
@. $(VENV)/bin/activate && pubsub-tools scenario-testing --config $(CONFIG)
# ============================================================================
# SETUP
# ============================================================================
setup-dev: setup-venv
@echo "🔧 Setting up development environment..."
@. $(VENV)/bin/activate && $(PIP) install --upgrade pip setuptools wheel
@. $(VENV)/bin/activate && $(PIP) install -e ".[dev]"
@echo "✅ Development environment ready!"
@echo " Activate with: source $(VENV)/bin/activate"
setup-venv:
@echo "📦 Creating virtual environment..."
$(PYTHON) -m venv $(VENV)
@echo "✅ Virtual environment created!"
@echo " Activate with: source $(VENV)/bin/activate"
# ============================================================================
# TESTING
# ============================================================================
test: test-unit
@echo ""
tests: test-unit
@echo ""
test-unit:
@echo "🧪 Running unit tests..."
@if [ -d "$(VENV)" ]; then \
. $(VENV)/bin/activate && pytest tests/ -v; \
else \
pytest tests/ -v; \
fi
test-coverage:
@echo "🧪 Running tests with coverage..."
@if [ -d "$(VENV)" ]; then \
. $(VENV)/bin/activate && pytest tests/ --cov=$(PROJECT_PATH) --cov-report=html --cov-report=term-missing -v; \
else \
pytest tests/ --cov=$(PROJECT_PATH) --cov-report=html --cov-report=term-missing -v; \
fi
@echo "✅ Coverage report: htmlcov/index.html"