veza/make/tools.mk
senke 4ee8c38536
Some checks failed
Veza CI / Backend (Go) (push) Failing after 0s
Veza CI / Frontend (Web) (push) Failing after 0s
Veza CI / Rust (Stream Server) (push) Failing after 0s
Frontend CI / test (push) Failing after 0s
Security Scan / Secret Scanning (gitleaks) (push) Failing after 0s
Veza CI / Notify on failure (push) Failing after 0s
feat(ci): enforce OpenAPI type sync — drift prevention (v1.0.8 P0)
Phase 0 of the OpenAPI typegen migration. Locks in the existing
check-types-sync.sh (which was committed but never wired) so we stop
accumulating drift between veza-backend-api/openapi.yaml and
apps/web/src/types/generated/ before we migrate to orval (Phase 1).

Three enforcement points:

1. Pre-commit hook (.husky/pre-commit)
   Replaces the naked generate-types.sh call with check-types-sync.sh,
   which regenerates and fails if the working tree differs. Skippable
   via SKIP_TYPES=1 (already documented in CLAUDE.md) for emergency
   commits and for environments without node_modules.

2. CI gate (.github/workflows/frontend-ci.yml)
   New "Check OpenAPI types in sync" step before lint/build. Catches
   PRs that touched openapi.yaml without regenerating types.
   Expanded the paths trigger to include veza-backend-api/openapi.yaml
   and docs/swagger.yaml so spec-only edits still run the check.

3. Makefile target (make openapi-check)
   Local convenience — same check as CI/hook, callable without staging
   anything. Pairs with existing `make openapi` (regenerate spec from
   swaggo annotations).

No spec or type file changes in this commit — pure plumbing.

Refs:
- AUDIT_REPORT.md §9 item #8 (OpenAPI typegen, deferred v1.0.8)
- Memory: project_next_priority_openapi_client.md
- /home/senke/.claude/plans/audit-fonctionnel-wild-hickey.md Item 2 Phase 0

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 20:33:13 +02:00

98 lines
5.2 KiB
Makefile

# ==============================================================================
# TOOLS: check, install deps, ports, doctor
# ==============================================================================
.PHONY: check-tools check-tools-incus install-tools install-deps check-ports openapi openapi-check doctor
doctor: ## [HIGH] Verify all dependencies and environment (TASK-QA-008)
@$(ECHO_CMD) "${BOLD}${PURPLE}🔬 VEZA Doctor — Environment Check${NC}"
@$(ECHO_CMD) ""
@$(ECHO_CMD) "${BOLD}Runtime versions:${NC}"
@if [ -f $(ROOT)/.nvmrc ]; then \
expected=$$(cat $(ROOT)/.nvmrc); \
actual=$$(node -v 2>/dev/null || echo "not installed"); \
if command -v node >/dev/null 2>&1; then \
$(ECHO_CMD) " Node.js: $$actual (expected: v$$expected)"; \
else \
$(ECHO_CMD) " ${RED}Node.js: not installed${NC}"; \
fi; \
else \
$(ECHO_CMD) " Node.js: $$(node -v 2>/dev/null || echo 'not installed')"; \
fi
@$(ECHO_CMD) " Go: $$(go version 2>/dev/null || echo 'not installed')"
@$(ECHO_CMD) " Rust: $$(rustc --version 2>/dev/null || echo 'not installed')"
@$(ECHO_CMD) " Docker: $$(docker --version 2>/dev/null || echo 'not installed')"
@$(ECHO_CMD) " Compose: $$(docker compose version 2>/dev/null || echo 'not installed')"
@$(ECHO_CMD) ""
@$(ECHO_CMD) "${BOLD}Optional (hot reload):${NC}"
@command -v air >/dev/null 2>&1 && $(ECHO_CMD) " air: $(GREEN)${NC}" || $(ECHO_CMD) " air: $(YELLOW)not installed (run make install-tools)${NC}"
@command -v cargo-watch >/dev/null 2>&1 && $(ECHO_CMD) " cargo-watch: $(GREEN)${NC}" || $(ECHO_CMD) " cargo-watch: $(YELLOW)not installed (run make install-tools)${NC}"
@$(ECHO_CMD) ""
@$(ECHO_CMD) "${BOLD}Environment validation (scripts/validate-env.sh):${NC}"
@(cd $(ROOT) && ./scripts/validate-env.sh development) || true
@$(ECHO_CMD) ""
@$(ECHO_CMD) "${BOLD}Env quick check:${NC}"
@$(ECHO_CMD) " DATABASE_URL: $${DATABASE_URL:-(not set)}"
@$(ECHO_CMD) " REDIS_URL: $${REDIS_URL:-(not set)}"
@$(ECHO_CMD) ""
@$(ECHO_CMD) "${BOLD}Infra connectivity (requires infra-up):${NC}"
@if docker compose -f $(COMPOSE_FILE) exec -T postgres pg_isready -U $(DB_USER) 2>/dev/null; then \
$(ECHO_CMD) " Postgres: $(GREEN)✓ reachable${NC}"; \
else \
$(ECHO_CMD) " Postgres: $(YELLOW)not reachable (run make infra-up)${NC}"; \
fi
@if docker compose -f $(COMPOSE_FILE) exec -T redis redis-cli ping 2>/dev/null | grep -q PONG; then \
$(ECHO_CMD) " Redis: $(GREEN)✓ reachable${NC}"; \
else \
$(ECHO_CMD) " Redis: $(YELLOW)not reachable (run make infra-up)${NC}"; \
fi
@$(ECHO_CMD) ""
@$(ECHO_CMD) "${GREEN}Run 'make install-deps' to install code dependencies.${NC}"
check-tools: ## [LOW] Check required tools
@$(ECHO_CMD) "${BLUE}Checking core requirements...${NC}"
@for tool in docker go cargo npm; do \
command -v $$tool >/dev/null 2>&1 || { $(ECHO_CMD) "${RED}$$tool is missing!${NC}"; exit 1; }; \
done
@$(ECHO_CMD) "${GREEN}✅ All tools present.${NC}"
check-tools-incus: ## [LOW] Check required tools for Incus deployment
@$(ECHO_CMD) "${BLUE}Checking Incus deployment requirements...${NC}"
@command -v incus >/dev/null 2>&1 || { $(ECHO_CMD) "${RED}❌ incus is missing! Install with: sudo snap install incus${NC}"; exit 1; }
@command -v go >/dev/null 2>&1 || { $(ECHO_CMD) "${RED}❌ go is missing!${NC}"; exit 1; }
@command -v cargo >/dev/null 2>&1 || { $(ECHO_CMD) "${RED}❌ cargo is missing!${NC}"; exit 1; }
@command -v npm >/dev/null 2>&1 || { $(ECHO_CMD) "${RED}❌ npm is missing!${NC}"; exit 1; }
@$(ECHO_CMD) "${GREEN}✅ All Incus tools present.${NC}"
install-tools: ## [LOW] Install Power User tools (Hot Reload, Linters)
@$(ECHO_CMD) "${BLUE}🛠️ Installing Dev Tools...${NC}"
@command -v air >/dev/null 2>&1 || go install github.com/air-verse/air@latest
@command -v cargo-watch >/dev/null 2>&1 || cargo install cargo-watch
@command -v sqlx >/dev/null 2>&1 || cargo install sqlx-cli --no-default-features --features native-tls,postgres
@$(ECHO_CMD) "${GREEN}✅ Tools installed.${NC}"
install-deps: ## [LOW] Install code dependencies (all backends + npm workspaces)
@$(ECHO_CMD) "${BLUE}📦 Installing dependencies...${NC}"
@$(ECHO_CMD) " -> [Go] Downloading modules..."
@(cd $(ROOT)/$(SERVICE_DIR_backend-api) && go mod download)
@$(ECHO_CMD) " -> [Rust Stream] Fetching crates..."
@(cd $(ROOT)/$(SERVICE_DIR_stream-server) && cargo fetch)
@$(ECHO_CMD) " -> [Web] Installing npm packages..."
@(cd $(ROOT)/$(SERVICE_DIR_web) && npm install --silent)
@$(ECHO_CMD) "${GREEN}✅ Dependencies installed.${NC}"
check-ports: ## [LOW] Check if ports are available
@$(ECHO_CMD) "${BLUE}🔍 Checking ports...${NC}"
@for port in $(PORT_backend-api) $(PORT_stream-server) $(PORT_web); do \
if lsof -i :$$port -t >/dev/null 2>&1; then \
$(ECHO_CMD) "${YELLOW}⚠️ Port $$port is busy${NC}"; \
else \
$(ECHO_CMD) "${GREEN}✅ Port $$port is free${NC}"; \
fi; \
done
openapi: ## [LOW] Régénère openapi.yaml depuis les annotations Swagger (v0.923)
@$(MAKE) -C $(ROOT)/$(SERVICE_DIR_backend-api) openapi
openapi-check: ## [LOW] Vérifie que apps/web/src/types/generated/ est en sync avec openapi.yaml (drift guard v1.0.8)
@cd $(ROOT)/apps/web && bash scripts/check-types-sync.sh