diff --git a/playwright.config.ts b/playwright.config.ts index b371f9a..00de701 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -8,12 +8,22 @@ export default defineConfig({ use: { trace: "on-first-retry", }, - webServer: { - command: "npm --workspace @chatballs/internal-ui run dev", - url: "http://localhost:5173", - reuseExistingServer: true, - timeout: 120_000, - }, + // Оба проекта должны подниматься сами: web-chat-mobile ходит на :5175, и без + // второго сервера прогон падал везде, где dev-стек не был поднят заранее. + webServer: [ + { + command: "npm --workspace @chatballs/internal-ui run dev", + url: "http://localhost:5173", + reuseExistingServer: true, + timeout: 120_000, + }, + { + command: "npm --workspace @chatballs/web-chat run dev", + url: "http://localhost:5175", + reuseExistingServer: true, + timeout: 120_000, + }, + ], projects: [ { name: "internal-ui", diff --git a/scripts/check.ps1 b/scripts/check.ps1 index 456aff3..22ac329 100644 --- a/scripts/check.ps1 +++ b/scripts/check.ps1 @@ -1,6 +1,52 @@ +# Полная проверка репозитория Chatballs (Windows). +# +# Запускается из любого каталога: скрипт сам переходит в корень code/chatballs. +# +# Два места, где прежняя редакция скрипта молча врала: +# 1) голый `docker compose` читает только compose.yaml, а сервисы frontend и +# web-chat (node) существуют лишь в dev-оверлее — в базовом compose +# frontend это production-образ nginx, где нет npm; +# 2) $ErrorActionPreference не останавливает скрипт на ненулевом коде +# возврата нативных команд, поэтому падение тестов проходило как успех. +# Каждый шаг проверяется явно по $LASTEXITCODE. +# +# Требуется один раз: npx playwright install chromium. $ErrorActionPreference = "Stop" -docker compose run --rm backend-app pytest -docker compose run --rm frontend npm run test -docker compose run --rm frontend npm run typecheck -docker compose run --rm web-chat npm run typecheck +Set-Location (Join-Path $PSScriptRoot "..") + +$compose = "compose", "-f", "compose.yaml", "-f", "compose.dev.yaml" +$failed = @() + +function Invoke-Step { + param( + [Parameter(Mandatory = $true)][string] $Name, + [Parameter(Mandatory = $true)][scriptblock] $Body + ) + Write-Host "" + Write-Host "==> $Name" -ForegroundColor Cyan + & $Body + if ($LASTEXITCODE -ne 0) { + $script:failed += $Name + Write-Host "!!! $Name — код возврата $LASTEXITCODE" -ForegroundColor Red + } +} + +# Сначала быстрые проверки, затем длинные: backend-сьют идёт около 20 минут. +Invoke-Step "internal-ui · typecheck" { docker @compose run --rm --no-deps frontend npm run typecheck } +Invoke-Step "web-chat · typecheck" { docker @compose run --rm --no-deps web-chat npm run typecheck } +Invoke-Step "internal-ui · vitest" { docker @compose run --rm --no-deps frontend npm run test } +Invoke-Step "deployment CLI · pytest" { python -m pytest -q tests/cli } +# Playwright сам поднимает нужные dev-серверы (webServer в playwright.config.ts). +Invoke-Step "e2e · playwright" { npx playwright test } +# backend-app сам поднимает postgres, redis и миграции через сервис init. +Invoke-Step "backend · pytest" { docker @compose run --rm backend-app pytest -q } + +Write-Host "" +if ($failed.Count -gt 0) { + Write-Host "Провалено шагов: $($failed.Count)" -ForegroundColor Red + $failed | ForEach-Object { Write-Host " - $_" -ForegroundColor Red } + exit 1 +} + +Write-Host "Все проверки пройдены." -ForegroundColor Green