gendesign/.claude/rules/deploy.md

63 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
paths:
- docker-compose*.yml
- Caddyfile
- .github/workflows/**
- .forgejo/workflows/**
- scripts/setup-*.sh
---
# Deploy conventions
## Post-deploy verification (MANDATORY)
После КАЖДОГО успешного merge+deploy на main — **немедленно** spawn `qa-tester` subagent с playwright smoke по тому, что merged.
**Why:** Без auto-smoke user сам ловит prod TypeErrors / 4xx / overlay bugs которые qa-tester catched бы за 2 мин. Плохой UX + потерянное время на P0 hotfixes уже после того как user увидел проблему. User rule (2026-05-18): «проверяй через плэйврайт сразу после деплоя».
**How to apply:**
- После `mcp__forgejo__get_pull_request` `merged: true` И подтверждения deploy success (HTTP 200 на routes / GHA run finished / user сказал «deploy прошёл») — `Agent` subagent_type=qa-tester.
- Prompt: routes изменённые в PR + expected behaviour из PR body + console errors check + critical API calls (4xx/5xx detection) + regression baseline (`/`, `/health`, `/landing/stats`).
- Background OK — wait notification, не блокировать остальной flow.
- НЕ дожидаться user feedback «не работает» — qa-tester ловит сам.
Reference incident: PR #346 (2026-05-18) deploy → user сам нашёл prod 500 на by-bbox, потом 400 на analyze, потом TypeError на poi-score, потом UI overlap. Каждое ловилось бы playwright smoke по `/site-finder/analysis/{cad}`.
## GHA path triggers
- `backend/**`, `frontend/**`, `Caddyfile`, `docker-compose.prod.yml`, `data/sql/*.sql``deploy.yml` (main stack)
- `docker-compose.obsidian.yml`, `scripts/setup-couchdb.sh``deploy-obsidian.yml`
- `docs/**` alone → НЕ триггерит деплой
## После изменения .env на VPS
```bash
docker compose up -d --force-recreate --no-deps <service>
```
`docker compose restart` НЕ перечитывает `env_file`.
## Caddyfile
Bind-mounted → нужен явный `caddy reload` после изменения. `deploy.yml` делает автоматически после `compose up -d`.
## Sentry release tracking
`SENTRY_RELEASE=$IMAGE_TAG` пишется в `backend/.env.runtime` на VPS через `sed`**не** полная перезапись файла (там user-managed `COUCHDB_PASSWORD` и пр.).
## VPS git state
`deploy.yml` делает `git reset --hard origin/main` → любые ручные правки в `/opt/gendesign` стираются. `.env`-файлы выживают (в `.gitignore`).
## DB migrations через deploy
`data/sql/NN_*.sql` применяются **до** `compose up -d`. Если SQL падает → deploy останавливается (exit 1), containers не обновляются.
Diagnose: GHA log "Apply DB migrations". См. `.claude/rules/sql.md` для migration order.
## Запреты
- ❌ Менять `env_file` секреты в `docker-compose*.yml` — секреты через VPS `.env` файлы
- ❌ Полностью перезаписывать `.env.runtime` — только `sed` для конкретных переменных
-`git pull` на VPS вручную — deploy.yml уже делает `git reset --hard`
- ❌ Hardcode tags / SHA в compose files — `${IMAGE_TAG}` через env