-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
349 lines (290 loc) · 8.56 KB
/
Makefile
File metadata and controls
349 lines (290 loc) · 8.56 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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
.PHONY: all develop test lint clean doc format build serve
.PHONY: deploy deploy-docker clean-server clean-and-deploy
.PHONY: test-all test-ci test-demos test-demos-docker test-demos-ssh
.PHONY: test-tutorials test-tutorials-ssh test-installer build-installers
.PHONY: test-dev test-ci-new test-nightly test-list test-run
.PHONY: test-system test-system-clean test-apps test-app
# For tests, set HOP3_DEV_HOST in your environment
all: ruff test lint
#
# Help
#
help:
adt help-make
#
# Development
#
## Install dependencies and setup dev environment
develop: install-deps activate-pre-commit configure-git
## Alias for develop
install: install-deps
install-deps:
@echo "--> Installing dependencies"
uv sync --inexact
activate-pre-commit:
@echo "--> Activating pre-commit hook"
pre-commit install
configure-git:
@echo "--> Configuring git"
git config branch.autosetuprebase always
## Check development environment
check-dev-env:
python3 scripts/check-dev-env.py
## Update dependencies
update-deps:
@echo "--> Updating dependencies"
uv sync --all-groups -U
uv run pre-commit autoupdate
uv pip list --outdated
uv pip list --format=freeze > compliance/requirements-full.txt
## Run full development stack (web server + uWSGI emperor)
serve:
hop3-server setup
honcho -f Procfile.dev start
## Aliases for serve
dev: serve
run: serve
## Run only the web server (without uWSGI)
serve-web:
litestar --app asgi:create_app run --debug --reload
#
# Code Quality
#
## Quick lint
ruff:
uv run ruff format --check packages/*/src packages/*/tests
uv run ruff check packages/*/src packages/*/tests
## Lint and type check
lint:
@echo "--> Linting code"
@make ruff
uv run ty check packages/hop3-testing/src
uv run mypy packages/hop3-server/src
# cd packages/hop3-server && uv run deptry src
@echo ""
## Alias for lint (used by CI)
check: lint
## Format code
format:
@echo "--> Formatting code"
uv run ruff format packages/*/src packages/*/tests
uv run ruff check --fix packages/*/src packages/*/tests
@make update-tocs
# python scripts/update-copyright.py
@echo ""
update-tocs:
uv run markdown-toc --maxdepth 3 -i README.md
uv run markdown-toc --maxdepth 3 -i notes/todo/TODO-next.md
uv run markdown-toc --maxdepth 3 -i notes/todo/TODO-NGI.md
uv run markdown-toc --maxdepth 3 -i notes/roadmap.md
uv run markdown-toc --maxdepth 3 -i notes/current-status.md
uv run markdown-toc --maxdepth 3 -i notes/test-status.md
## Run security audit
audit:
@echo "--> Running security audit"
nox -e audit
@echo ""
#
# Testing
#
## Run all pytest tests (unit, integration, e2e)
test:
@echo "--> Running Python tests"
uv run pytest packages/hop3-server/tests/a_unit
uv run pytest -n 4 packages/hop3-server/tests/b_integration
uv run pytest packages/hop3-server/tests/d_e2e
uv run pytest packages/hop3-cli/tests
@echo ""
## Run tests with coverage report
test-with-coverage:
@echo "--> Running Python tests with coverage"
uv run pytest --cov=hop3 --cov-report term-missing
@echo ""
## Run tests with runtime type checking
test-with-typeguard:
@echo "--> Running Python tests with typeguard"
uv run pytest --typeguard-packages=hop3,hop3_agent,hop3_server,hop3_web,hop3_lib
@echo ""
## Run full CI test suite (pytest + demos + tutorials)
test-all: test-ci
test-ci:
@echo "=========================================="
@echo "Running CI test suite"
@echo "=========================================="
@echo ""
@echo "Phase 1: Run pytest..."
@make test
@echo ""
@echo "Phase 2: Deploy to Docker..."
uv run hop3-deploy --local --docker
@echo ""
@echo "Phase 3: Deploy to SSH target (${HOP3_DEV_HOST})..."
uv run hop3-deploy --local
@echo ""
@echo "Phase 4: Run demos on Docker..."
python demos/demo.py --backend docker --local --quiet
@echo ""
@echo "Phase 5: Run demos on SSH target..."
python demos/demo.py --host ${HOP3_DEV_HOST} --local --quiet
@echo ""
@echo "Phase 6: Run tutorials..."
python ./scripts/run-all-tutorials.py
@echo ""
@echo "=========================================="
@echo "CI test suite completed!"
@echo "=========================================="
## Run demos on both backends
test-demos: test-demos-docker test-demos-ssh
## Run demos on Docker backend
test-demos-docker:
@echo "--> Running demos on Docker backend"
python demos/demo.py --backend docker --local --quiet
@echo ""
## Run demos on SSH backend (requires HOP3_DEV_HOST)
test-demos-ssh:
@echo "--> Running demos on SSH backend (${HOP3_DEV_HOST})"
python demos/demo.py --host ${HOP3_DEV_HOST} --local --quiet
@echo ""
## Run tutorials
test-tutorials: test-tutorials-ssh
## Run tutorials on SSH backend
test-tutorials-ssh:
@echo "--> Running tutorials on SSH backend"
./scripts/run-all-tutorials.sh
@echo ""
#
# New unified test runner (hop3-test)
#
## Run quick tests with new runner (fast, P0 only) - LEGACY
test-dev:
@echo "--> Running dev tests (fast, P0)"
uv run hop3-test dev --target docker
@echo ""
## Run CI tests with new runner (fast+medium, P0)
test-ci-new:
@echo "--> Running CI tests (fast+medium, P0)"
uv run hop3-test ci --target docker
@echo ""
## Run nightly tests with new runner (all tiers, all priorities)
test-nightly:
@echo "--> Running nightly tests (all)"
uv run hop3-test nightly --target docker
@echo ""
## List available tests
test-list:
@uv run hop3-test list
## Run specific tests by name
test-run:
@echo "Usage: make test-run APPS='app1 app2'"
@echo "Example: make test-run APPS='010-flask-pip-wsgi 020-nodejs-express'"
#
# System and App Testing (NEW - uses hop3-deploy)
#
## Test Hop3 system with hop3-deploy (local code)
test-system:
@echo "--> Testing Hop3 system (via hop3-deploy)"
uv run hop3-test system --deploy-from local
@echo ""
## Test Hop3 system with clean install
test-system-clean:
@echo "--> Testing Hop3 system (clean install)"
uv run hop3-test system --deploy-from local --clean
@echo ""
## Test apps against pre-built image (fast, no deployment)
test-apps:
@echo "--> Testing apps (pre-built image)"
uv run hop3-test apps
@echo ""
## Test specific app
test-app:
@echo "Usage: make test-app APP=010-flask-pip-wsgi"
@if [ -n "$(APP)" ]; then uv run hop3-test apps $(APP); fi
#
# Installer Testing
#
## Build single-file installers
build-installers:
@echo "--> Building single-file installers"
@mkdir -p installer
uv run hop3-install bundle --all --output-dir installer/
@echo ""
## Test installers (Docker by default, use 'hop3-install test --help' for more options)
test-installer: build-installers
@echo "--> Testing installers in Docker"
uv run hop3-install test docker --distro ubuntu --type both --method local
uv run hop3-install test ssh --distro ubuntu --type both --method local
@echo ""
#
# Deployment
#
## Deploy to development server (set HOP3_DEV_HOST)
deploy:
@echo "--> Deploying to ${HOP3_DEV_HOST}"
uv run hop3-deploy --local
## Deploy to local Docker container
deploy-docker:
@echo "--> Deploying to Docker container"
uv run hop3-deploy --local --docker
## Clean development server (WARNING: removes everything)
clean-server:
@echo "--> Cleaning server (WARNING: removes everything)"
-ssh root@${HOP3_DEV_HOST} apt-get purge -y nginx nginx-core nginx-common
ssh root@${HOP3_DEV_HOST} rm -rf /home/hop3 /etc/nginx
## Clean server and redeploy
clean-and-deploy:
make clean-server
make deploy
#
# Build & Release
#
## Build Python packages
build:
@make clean
uv build packages/hop3-server
uv build packages/hop3-cli
## Generate SBOM for CRA compliance
generate-sbom:
@echo "--> Generating SBOM"
make clean
rm -rf .venv
uv sync -q --no-dev
uv pip list --format=freeze > compliance/requirements-prod.txt
syft .venv \
-o spdx-json=compliance/sbom-spdx.json \
-o cyclonedx-json=compliance/sbom-cyclonedx.json \
-o syft-text=compliance/sbom-syft.txt
npx prettier -w compliance/sbom-spdx.json
npx prettier -w compliance/sbom-cyclonedx.json
uv sync -q
#
# Documentation
#
## Build documentation
doc:
@echo "--> Building documentation"
cd docs && $(MAKE) build
## Serve documentation locally
doc-serve:
@echo "--> Serving documentation"
cd docs && $(MAKE) serve
## Deploy documentation to hop3.cloud
doc-deploy:
@echo "--> Deploying documentation"
make doc
rsync -e ssh -avz docs/site/ root@hop3.cloud:/var/www/hop3.cloud/
#
# Cleanup
#
## Clean build artifacts
clean:
bash -c "shopt -s globstar && rm -f **/*.pyc"
find . -type d -empty -delete
rm -rf *.egg-info *.egg .coverage .eggs .cache .mypy_cache .pyre \
.pytest_cache .pytest .DS_Store docs/_build docs/cache docs/tmp \
dist build pip-wheel-metadata junit-*.xml htmlcov coverage.xml \
tmp
rm -rf packages/*/dist packages/*/.pdm-build
rm -rf .nox
rm -rf docs/site
rm -rf test-logs/
adt clean