File size: 1,633 Bytes
d4167d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fcd4d8a
 
d4167d9
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash

# Exit on error
set -e

# Kill any existing processes using port 7862
echo "Cleaning up port 7862..."
lsof -ti:7862 | xargs kill -9 2>/dev/null || true

# Check if uv is installed, if not install it
if ! command -v uv &> /dev/null; then
    echo "Installing uv package installer..."
    curl -LsSf https://astral.sh/uv/install.sh | sh
fi

# Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
    echo "Creating virtual environment..."
    python -m venv venv
fi

# Activate virtual environment
echo "Activating virtual environment..."
source venv/bin/activate

# Install dependencies using uv
echo "Installing dependencies with uv..."
uv pip install -r requirements.txt

# Install Playwright browsers
echo "Installing Playwright browsers..."
playwright install chromium

# Run unit tests
echo "Running unit tests..."
python -m pytest test_app.py -v

if [ $? -eq 0 ]; then
    echo "Unit tests passed! Starting Gradio app..."
    # Start Gradio app in background
    python app.py &
    GRADIO_PID=$!
    
    # Wait for server to start
    echo "Waiting for Gradio server to start..."
    sleep 3
    
    # Run e2e tests
    echo "Running e2e tests..."
    python -m pytest test_e2e.py -v
    E2E_STATUS=$?
    
    # Kill Gradio server
    kill $GRADIO_PID
    
    if [ $E2E_STATUS -eq 0 ]; then
        echo "All tests passed!"
        exit 0
    else
        echo "E2E tests failed! Please fix the issues before running the app."
        exit 1
    fi
else
    echo "Unit tests failed! Please fix the issues before running e2e tests."
    exit 1
fi

# Deactivate virtual environment
deactivate