diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 9f706db..47e00f9 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -67,7 +67,10 @@ jobs: run: bash scripts/install-playwright-chromium.sh - name: E2E mock suite - run: npm run test:e2e + run: | + # act hostexecutor: зомби vite preview (cwd deleted) держит порт → HTTP 404 → webServer timeout + bash scripts/free-e2e-port.sh + npm run test:e2e - name: Upload dist for docker job if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full') diff --git a/playwright.config.ts b/playwright.config.ts index 30b2e5b..cf6cda7 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -50,9 +50,12 @@ export default defineConfig({ webServer: liveTarget ? undefined : { - command: `npm run preview -- --host 127.0.0.1 --port ${port}`, + // strictPort: не молчать, если порт занят зомби act-preview + command: `npm run preview -- --host 127.0.0.1 --port ${port} --strictPort`, url: baseURL, reuseExistingServer: !process.env.CI, timeout: 120_000, + stdout: 'pipe', + stderr: 'pipe', }, }); diff --git a/scripts/free-e2e-port.sh b/scripts/free-e2e-port.sh new file mode 100644 index 0000000..b9f1601 --- /dev/null +++ b/scripts/free-e2e-port.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# Act hostexecutor делит сеть с хостом: после cancel/fail остаётся vite preview +# с cwd (deleted), порт занят, HTTP 404 → Playwright webServer ждёт 2xx до таймаута. +set -euo pipefail + +PORT="${E2E_PORT:-4173}" + +free_port() { + local pids="" + if command -v fuser >/dev/null 2>&1; then + fuser -k "${PORT}/tcp" >/dev/null 2>&1 || true + return 0 + fi + if command -v lsof >/dev/null 2>&1; then + pids="$(lsof -t -iTCP:"${PORT}" -sTCP:LISTEN 2>/dev/null || true)" + elif command -v ss >/dev/null 2>&1; then + pids="$(ss -ltnp "sport = :${PORT}" 2>/dev/null | sed -n 's/.*pid=\([0-9]\+\).*/\1/p' | sort -u || true)" + fi + if [[ -n "${pids}" ]]; then + echo "free-e2e-port: killing PIDs on :${PORT}: ${pids}" + # shellcheck disable=SC2086 + kill ${pids} 2>/dev/null || true + sleep 1 + # shellcheck disable=SC2086 + kill -9 ${pids} 2>/dev/null || true + fi +} + +echo "free-e2e-port: ensuring :${PORT} is free" +free_port +if command -v ss >/dev/null 2>&1; then + if ss -ltn | grep -qE ":${PORT}\\s"; then + echo "WARN: :${PORT} still in use after free attempt" >&2 + ss -ltnp | grep ":${PORT}" || true + else + echo "free-e2e-port: :${PORT} is free" + fi +fi