citesting-fix1
Some checks failed
Deploy on push / deploy (push) Failing after 2m0s

This commit is contained in:
2025-08-17 11:37:55 +03:00
parent 4b88a8c449
commit bc8447a444
6 changed files with 648 additions and 227 deletions

View File

@@ -49,15 +49,88 @@ jobs:
uv sync --group dev
cd panel && npm ci && cd ..
- name: Setup test database
- name: Verify Redis connection
run: |
echo "Verifying Redis connection..."
max_retries=5
for attempt in $(seq 1 $max_retries); do
if redis-cli ping > /dev/null 2>&1; then
echo "✅ Redis is ready!"
break
else
if [ $attempt -eq $max_retries ]; then
echo "❌ Redis connection failed after $max_retries attempts"
echo "⚠️ Tests may fail due to Redis unavailability"
# Не выходим с ошибкой, продолжаем тесты
break
else
echo "⚠️ Redis not ready, retrying in 2 seconds... (attempt $attempt/$max_retries)"
sleep 2
fi
fi
done
- name: Setup test environment
run: |
echo "Setting up test environment..."
# Создаем .env.test для тестов
cat > .env.test << EOF
DATABASE_URL=sqlite:///database.db
REDIS_URL=redis://localhost:6379
TEST_MODE=true
EOF
# Проверяем что файл создан
echo "Test environment file created:"
cat .env.test
- name: Initialize test database
run: |
echo "Initializing test database..."
touch database.db
uv run python -c "
from orm.base import Base
from services.db import get_engine
engine = get_engine()
Base.metadata.create_all(engine)
print('Test database initialized')
import time
import sys
from pathlib import Path
# Добавляем корневую папку в путь
sys.path.insert(0, str(Path.cwd()))
try:
from orm.base import Base
from orm.community import Community, CommunityFollower, CommunityAuthor
from orm.draft import Draft
from orm.invite import Invite
from orm.notification import Notification
from orm.reaction import Reaction
from orm.shout import Shout
from orm.topic import Topic
from auth.orm import Author, AuthorBookmark, AuthorRating, AuthorFollower
from services.db import engine
from sqlalchemy import inspect
print('✅ Engine imported successfully')
print('Creating all tables...')
Base.metadata.create_all(engine)
# Проверяем что таблицы созданы
inspector = inspect(engine)
tables = inspector.get_table_names()
print(f'✅ Created tables: {tables}')
# Проверяем конкретно community_author
if 'community_author' in tables:
print('✅ community_author table exists!')
else:
print('❌ community_author table missing!')
print('Available tables:', tables)
except Exception as e:
print(f'❌ Error initializing database: {e}')
import traceback
traceback.print_exc()
sys.exit(1)
"
- name: Start servers
@@ -67,20 +140,64 @@ jobs:
echo $! > ci-server.pid
echo "Waiting for servers..."
timeout 120 bash -c '
timeout 180 bash -c '
while ! (curl -f http://localhost:8000/ > /dev/null 2>&1 && \
curl -f http://localhost:3000/ > /dev/null 2>&1); do
sleep 2
curl -f http://localhost:3000/ > /dev/null 2>&1); do
sleep 3
done
echo "Servers ready!"
'
- name: Run tests
- name: Run tests with retry
run: |
# Создаем папку для результатов тестов
mkdir -p test-results
# Сначала проверяем здоровье серверов
echo "🏥 Проверяем здоровье серверов..."
if uv run pytest tests/test_server_health.py -v; then
echo "✅ Серверы здоровы!"
else
echo "⚠️ Тест здоровья серверов не прошел, но продолжаем..."
fi
for test_type in "not e2e" "integration" "e2e" "browser"; do
echo "Running $test_type tests..."
uv run pytest tests/ -m "$test_type" -v --tb=short || \
if [ "$test_type" = "browser" ]; then echo "Browser tests failed (expected)"; else exit 1; fi
max_retries=3 # Увеличиваем количество попыток
for attempt in $(seq 1 $max_retries); do
echo "Attempt $attempt/$max_retries for $test_type tests..."
# Добавляем специальные параметры для browser тестов
if [ "$test_type" = "browser" ]; then
echo "🚀 Запускаем browser тесты с увеличенным таймаутом..."
if uv run pytest tests/ -m "$test_type" -v --tb=short --timeout=60; then
echo "✅ $test_type tests passed!"
break
else
if [ $attempt -eq $max_retries ]; then
echo "⚠️ Browser tests failed after $max_retries attempts (expected in CI) - continuing..."
break
else
echo "⚠️ Browser tests failed, retrying in 15 seconds..."
sleep 15
fi
fi
else
# Обычные тесты
if uv run pytest tests/ -m "$test_type" -v --tb=short; then
echo "✅ $test_type tests passed!"
break
else
if [ $attempt -eq $max_retries ]; then
echo "❌ $test_type tests failed after $max_retries attempts"
exit 1
else
echo "⚠️ $test_type tests failed, retrying in 10 seconds..."
sleep 10
fi
fi
fi
done
done
- name: Generate coverage