mirror of
https://github.com/Evil0ctal/Douyin_TikTok_Download_API.git
synced 2026-10-29 04:46:34 +08:00
Brings the compose project up, waits for health, and walks the contract a real deployment has to satisfy: migrations produce 11 tables, 3 hypertables and both continuous aggregates; the setup token appears in the container log and the endpoint closes permanently afterwards; the failure envelope carries a stable code and a request_id; three SSRF shapes are rejected, including the metadata address and a lookalike host; messages differ between ?lang=en and ?lang=zh; OpenAPI, the docs and the console are all served. It always tears down with -v, including on failure, so a run cannot leave stray containers or volumes behind. `--keep` opts out for inspection, and `make clean` removes both the test and the smoke projects. The setup token is read from the log rather than any HTTP response on purpose: under Docker's userland proxy every request appears to come from the bridge gateway, so a source-IP check would admit the whole internet.
59 lines
1.8 KiB
Makefile
59 lines
1.8 KiB
Makefile
# Every docker interaction goes through a named compose project so nothing
|
|
# stray is left behind. Never `docker run` fixtures by hand.
|
|
COMPOSE_TEST := docker compose -p dtk-test -f docker/compose.test.yml
|
|
COMPOSE := docker compose -p dtk -f docker/compose.yml
|
|
|
|
.PHONY: help install fmt lint type test test-unit test-integration \
|
|
fixtures-up fixtures-down fixtures-logs up down logs clean smoke
|
|
|
|
help:
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
|
|
|
|
install: ## Sync the dev environment with uv
|
|
uv sync --all-extras
|
|
|
|
fmt: ## Format
|
|
uv run ruff format src tests
|
|
uv run ruff check --fix src tests
|
|
|
|
lint: ## Lint
|
|
uv run ruff check src tests
|
|
uv run ruff format --check src tests
|
|
|
|
type: ## Type check
|
|
uv run mypy
|
|
|
|
fixtures-up: ## Start test PostgreSQL + Redis (compose project: dtk-test)
|
|
$(COMPOSE_TEST) up -d --wait
|
|
|
|
fixtures-down: ## Stop and remove test fixtures, including volumes
|
|
$(COMPOSE_TEST) down -v --remove-orphans
|
|
|
|
fixtures-logs:
|
|
$(COMPOSE_TEST) logs --tail=100
|
|
|
|
test-unit: ## Unit and replay tests, no services required
|
|
uv run pytest tests/unit tests/replay -q
|
|
|
|
test-integration: fixtures-up ## Integration tests against real PostgreSQL + Redis
|
|
uv run pytest tests/integration -q -m integration; \
|
|
status=$$?; $(COMPOSE_TEST) down -v --remove-orphans; exit $$status
|
|
|
|
test: test-unit test-integration ## Everything
|
|
|
|
up: ## Start the full stack
|
|
$(COMPOSE) up -d --wait
|
|
|
|
down:
|
|
$(COMPOSE) down --remove-orphans
|
|
|
|
logs:
|
|
$(COMPOSE) logs -f
|
|
|
|
smoke: ## Full-stack end-to-end check (brings the stack up and tears it down)
|
|
./scripts/smoke.sh
|
|
|
|
clean: fixtures-down ## Remove every dtk container, network and volume
|
|
-$(COMPOSE) down -v --remove-orphans
|
|
-docker compose -p dtk-smoke -f docker/compose.yml down -v --remove-orphans
|