forked from hypersdk/hyper2kvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
286 lines (248 loc) · 7.85 KB
/
Makefile
File metadata and controls
286 lines (248 loc) · 7.85 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
# SPDX-License-Identifier: LGPL-3.0-or-later
# Makefile for hyper2kvm - Enterprise-friendly wrapper around Hatch
#
# This Makefile provides traditional make targets for enterprise users
# while leveraging Hatch for modern Python project management.
#
# Quick start:
# make help - Show available targets
# make test - Run unit tests
# make install - Install the package
# make clean - Clean build artifacts
.PHONY: help test test-unit test-integration test-all test-cov lint fmt security check ci install dev-install build publish clean clean-all docs rpm
# Default target
.DEFAULT_GOAL := help
# Check if hatch is installed
HATCH := $(shell command -v hatch 2> /dev/null)
help: ## Show this help message
@echo "hyper2kvm - Hypervisor to KVM/QEMU Migration Toolkit"
@echo ""
@echo "Available targets:"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36mmake %-20s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Advanced Hatch commands:"
@echo " hatch run test-cov-all - Test with coverage for all tests"
@echo " hatch run security-audit - Generate security audit report"
@echo " hatch run docs-build - Build documentation"
@echo " hatch env show - Show all environments"
@echo ""
@echo "For more information, see: https://github.com/ssahani/hyper2kvm"
# Testing targets
test: ## Run unit tests
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run test
test-unit: ## Run unit tests only
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run test-unit
test-integration: ## Run integration tests
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run test-integration
test-all: ## Run all tests (unit + integration)
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run test-all
test-cov: ## Run tests with coverage report
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run test-cov
@echo ""
@echo "Coverage report generated in htmlcov/index.html"
# Code quality targets
lint: ## Run code linting (ruff + mypy)
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run lint
fmt: ## Format code with ruff
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run fmt
fmt-check: ## Check code formatting without modifying
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run fmt-check
# Security targets
security: ## Run security scans (bandit + safety)
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run security
# Combined targets
check: ## Run tests + lint + security
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run check
ci: ## Run full CI pipeline (test-cov + lint + security)
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run ci
# Installation targets
install: ## Install the package
pip install .
install-full: ## Install with all optional dependencies
pip install .[full]
dev-install: ## Install in development mode with all dependencies
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
pip install -e .[dev,full]
@echo ""
@echo "Development environment ready!"
@echo "Run 'make test' to verify installation."
# Build targets
build: ## Build source and wheel distributions
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch build
@echo ""
@echo "Built packages:"
@ls -lh dist/
publish: ## Publish to PyPI (requires PYPI_TOKEN)
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch publish
publish-test: ## Publish to TestPyPI
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch publish -r test
# Documentation targets
docs: ## Build documentation
$(MAKE) -C man html
@echo ""
@echo "Documentation built in man/build/html/"
@echo "Open man/build/html/index.html in your browser"
docs-serve: ## Serve documentation locally
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run docs-serve
# RPM packaging (Fedora/RHEL)
rpm: ## Build RPM package
python3 -m build --sdist
@echo ""
@echo "To build RPM, run:"
@echo " rpmbuild -ba hyper2kvm.spec"
# Cleanup targets
clean: ## Clean build artifacts
rm -rf build/ dist/ *.egg-info .eggs/
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name '*.pyc' -delete
find . -type f -name '*.pyo' -delete
find . -type d -name '*.egg' -exec rm -rf {} + 2>/dev/null || true
rm -rf htmlcov/ .coverage .pytest_cache/
rm -rf .ruff_cache/ .mypy_cache/
@echo "Build artifacts cleaned"
clean-all: clean ## Clean everything including test data
rm -rf tests/test-data/*.vmdk tests/test-data/*.img tests/test-data/*.qcow2
rm -rf man/build/
@echo "All artifacts and test data cleaned"
# Matrix testing across Python versions
test-matrix: ## Test across all Python versions (3.10, 3.11, 3.12)
ifndef HATCH
@echo "Hatch not found. Installing hatch..."
pip install hatch
endif
hatch run test:run
# Version information
version: ## Show version information
@python3 -c "import sys; sys.path.insert(0, '.'); from hyper2kvm import __version__; print(f'hyper2kvm version: {__version__}')"
@echo "Python: $(shell python3 --version)"
ifdef HATCH
@echo "Hatch: $(shell hatch --version)"
else
@echo "Hatch: not installed (pip install hatch)"
endif
# Show environment information
env-info: ## Show development environment information
@echo "Development Environment Information"
@echo "===================================="
@echo "Python: $(shell python3 --version)"
@echo "Pip: $(shell pip --version)"
ifdef HATCH
@echo "Hatch: $(shell hatch --version)"
@hatch env show
else
@echo "Hatch: not installed"
@echo ""
@echo "To install hatch: pip install hatch"
endif
# Quick start for new developers
quickstart: ## Quick start for new developers
@echo "Setting up hyper2kvm development environment..."
@echo ""
pip install hatch
$(MAKE) dev-install
@echo ""
@echo "Running initial tests..."
$(MAKE) test
@echo ""
@echo "=========================================="
@echo "Development environment ready!"
@echo "=========================================="
@echo ""
@echo "Next steps:"
@echo " make test - Run tests"
@echo " make lint - Check code quality"
@echo " make help - Show all commands"
# ============================================================================
# Kubernetes E2E Testing
# ============================================================================
.PHONY: e2e-k8s
e2e-k8s: ## Run automated Kubernetes E2E test for CentOS 9
@bash scripts/run-e2e-test.sh
.PHONY: e2e-k8s-detailed
e2e-k8s-detailed: ## Run detailed Kubernetes E2E test workflow
@bash scripts/test-centos9-e2e-k8s.sh
.PHONY: build-images
build-images: ## Build container images locally
@bash scripts/build-and-push-images.sh
.PHONY: push-images
push-images: ## Build and push images to GHCR (requires GITHUB_TOKEN)
@PUSH=true bash scripts/build-and-push-images.sh
.PHONY: e2e-clean
e2e-clean: ## Clean up E2E test resources
@kubectl delete migrationjob centos9-e2e-test -n hyper2kvm-test --timeout=30s 2>/dev/null || true
@kubectl delete namespace hyper2kvm-test --timeout=60s 2>/dev/null || true
@echo "✅ E2E test resources cleaned up"
.PHONY: e2e-ubuntu
e2e-ubuntu: ## Run automated Kubernetes E2E test for Ubuntu
@bash scripts/test-ubuntu-e2e-k8s.sh
.PHONY: e2e-all
e2e-all: ## Run E2E tests for both CentOS 9 and Ubuntu
@echo "Running CentOS 9 E2E test..."
@bash scripts/test-centos9-e2e-k8s.sh
@echo ""
@echo "Running Ubuntu E2E test..."
@bash scripts/test-ubuntu-e2e-k8s.sh