mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-06-26 13:01:55 +02:00
96a78d79f6
- Default-off coverage in pyproject.toml addopts; opt-in via make test-cov - Add pytest-xdist for parallel execution (make test = pytest -nauto --no-cov) - Promote API test fixtures to session/module scope (engine, app, mocks); per-test isolation via table truncation instead of schema rebuild - Remove Makefile include .env/export that leaked config vars into tests; docker-compose reads .env natively - Add _ignore_dotenv autouse fixture: disables env_file, clears leaked env vars from Settings fields and Click CLI envvars - Patch time.sleep in 3 subscriber scheduler tests (~3s -> ~0.03s) - Fix pytest.raises(Exception, match='') warning -> IntegrityError - Add .venv activation to .envrc - Suppress warn_unused_ignores for tests in mypy config (single-file pre-commit checks lack full-project context)
47 lines
1.5 KiB
Makefile
47 lines
1.5 KiB
Makefile
COMPOSE_PROJECT_NAME ?= hub
|
|
PROFILES ?= mqtt core
|
|
COMPOSE_FILES = -f docker-compose.yml -f docker-compose.dev.yml
|
|
VOLUMES = $(COMPOSE_PROJECT_NAME)_data $(COMPOSE_PROJECT_NAME)_mqtt_data \
|
|
$(COMPOSE_PROJECT_NAME)_observer_data
|
|
|
|
.PHONY: build up down logs backup restore test test-cov test-unit
|
|
|
|
build:
|
|
docker compose $(COMPOSE_FILES) --profile all build --no-cache
|
|
|
|
up:
|
|
docker compose $(COMPOSE_FILES) $(foreach p,$(PROFILES),--profile $(p)) up -d --force-recreate
|
|
|
|
down:
|
|
docker compose $(COMPOSE_FILES) --profile all down --remove-orphans
|
|
|
|
logs:
|
|
docker compose $(COMPOSE_FILES) --profile all logs -f
|
|
|
|
backup:
|
|
@mkdir -p backup
|
|
@for vol in $(VOLUMES); do \
|
|
echo "Backing up $$vol..."; \
|
|
docker run --rm -v $$vol:/data -v $(PWD)/backup:/backup \
|
|
alpine tar czf /backup/$$vol-$$(date +%Y%m%d-%H%M%S).tar.gz -C / data; \
|
|
done
|
|
@echo "Backups saved to $(PWD)/backup/"
|
|
|
|
restore:
|
|
@if [ -z "$(FILE)" ]; then echo "Usage: make restore FILE=backup/<tarball>"; exit 1; fi
|
|
@vol=$$(basename $(FILE) | sed 's/-[0-9]\{8\}-[0-9]\{6\}\.tar\.gz//'); \
|
|
echo "Restoring $$vol from $(FILE)..."; \
|
|
docker run --rm -v $$vol:/data -v $(PWD)/backup:/backup \
|
|
alpine sh -c "cd / && tar xzf /backup/$$(basename $(FILE))"
|
|
|
|
# --- Tests ---------------------------------------------------------------
|
|
# Coverage is opt-in (use test-cov). Dev loop runs in parallel across cores.
|
|
test:
|
|
pytest -nauto --no-cov
|
|
|
|
test-cov:
|
|
pytest --cov=meshcore_hub --cov-report=term-missing
|
|
|
|
test-unit:
|
|
pytest -nauto --no-cov tests/test_common/ tests/test_api/ tests/test_collector/ tests/test_web/
|