mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-08-20 13:12:48 +00:00
ruff was never wired into this repository: no target, no CI step, no pin. It reported 45 findings across sources and tests, so nothing enforced what the codebase already mostly followed. Adds `make ruff` (check + format --check), `make ruff-fix`, and `make lint` as its alias, and makes `make test` run lint as a fourth parallel spur. The CI workflow calls `make test`, so it is covered there too. The linter is pinned in a `lint` extra: a ruff minor bump changes which rules fire, and with the suite gating on a clean run an unpinned linter would fail it on an unrelated day. The 45 findings are fixed rather than configured away. Three needed a decision instead of the mechanical fix: - The generation timestamp keeps its local wall clock (DTZ005 waived). Generations sort by that name, and UTC would order new ones before the existing ones wherever the offset is positive - "newest generation" is what every restore path selects on. - The per-volume `copy` closure now binds volume_name and vol_dir as default arguments (B023). It only worked because it is called inside the same iteration. - The two CLI top-level handlers keep their blind except (BLE001 waived): turning any failure into exit 1 is what a CLI boundary is for. The two in run.py did not need it and were narrowed to what they actually catch. Also drops the comments that restate the code: the section banners in restore/__main__.py, the filename repeated as line 1 of nine test files, step narration above the statement it narrates, and a block in app.py documenting parameters that had moved to another module. What names a trip-wire stays - the snapshot destination rule, the mysql-binary absence in MariaDB 11 images, the session-scoped FOREIGN_KEY_CHECKS, the spooled temp file for multi-GB dumps, and the negative control that loses its discriminating power if it ever passes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
83 lines
2.4 KiB
Makefile
83 lines
2.4 KiB
Makefile
.PHONY: install install-lint build clean lint ruff ruff-fix \
|
|
test test-unit test-integration test-e2e \
|
|
test-unit-run test-integration-run test-e2e-run
|
|
|
|
# Default python if no venv is active
|
|
PY_DEFAULT ?= python3
|
|
|
|
IMAGE_NAME ?= baudolo
|
|
IMAGE_TAG ?= local
|
|
IMAGE := $(IMAGE_NAME):$(IMAGE_TAG)
|
|
|
|
install:
|
|
@set -eu; \
|
|
PY="$(PY_DEFAULT)"; \
|
|
if [ -n "$${VIRTUAL_ENV:-}" ] && [ -x "$${VIRTUAL_ENV}/bin/python" ]; then \
|
|
PY="$${VIRTUAL_ENV}/bin/python"; \
|
|
fi; \
|
|
echo ">>> Using python: $$PY"; \
|
|
"$$PY" -m pip install --upgrade pip; \
|
|
"$$PY" -m pip install -e .; \
|
|
command -v baudolo >/dev/null 2>&1 || { \
|
|
echo "ERROR: baudolo not found on PATH after install"; \
|
|
exit 2; \
|
|
}; \
|
|
baudolo --help >/dev/null 2>&1 || true
|
|
|
|
# ------------------------------------------------------------
|
|
# Build the baudolo Docker image
|
|
# ------------------------------------------------------------
|
|
build:
|
|
@echo ">> Building Docker image $(IMAGE)"
|
|
docker build -t $(IMAGE) .
|
|
|
|
clean:
|
|
git clean -fdX .
|
|
|
|
# Separate from `install` so the test image does not have to carry the linter.
|
|
install-lint:
|
|
@$(PY_DEFAULT) -m pip install -q -e ".[lint]"
|
|
|
|
# Runs on the host, not in the image, so it also covers what the Dockerfile
|
|
# does not copy.
|
|
ruff: install-lint
|
|
@echo ">> Running ruff over the whole repository"
|
|
@$(PY_DEFAULT) -m ruff check .
|
|
@$(PY_DEFAULT) -m ruff format --check .
|
|
|
|
ruff-fix: install-lint
|
|
@$(PY_DEFAULT) -m ruff check --fix .
|
|
@$(PY_DEFAULT) -m ruff format .
|
|
|
|
lint: ruff
|
|
|
|
# clean + build run once and in order, then lint and the three suites run
|
|
# concurrently via -j4; the *-run targets carry no clean/build prereq so the
|
|
# sub-make cannot race a second clean against build.
|
|
test:
|
|
@$(MAKE) clean
|
|
@$(MAKE) build
|
|
@$(MAKE) -j4 lint test-unit-run test-integration-run test-e2e-run
|
|
|
|
test-unit: clean build test-unit-run
|
|
|
|
test-integration: clean build test-integration-run
|
|
|
|
test-e2e: clean build test-e2e-run
|
|
|
|
test-unit-run:
|
|
@echo ">> Running unit tests"
|
|
@docker run --rm -t $(IMAGE) \
|
|
bash -lc 'python -m unittest discover -t . -s tests/unit -p "test_*.py" -v'
|
|
|
|
test-integration-run:
|
|
@echo ">> Running integration tests"
|
|
@docker run --rm -t $(IMAGE) \
|
|
bash -lc 'python -m unittest discover -t . -s tests/integration -p "test_*.py" -v'
|
|
|
|
# E2E via isolated Docker-in-Docker (DinD): starts a DinD daemon on a dedicated
|
|
# network, loads the freshly built image into it, and runs tests/e2e inside a
|
|
# container that talks to DinD via DOCKER_HOST.
|
|
test-e2e-run:
|
|
@bash scripts/test-e2e.sh
|