name: CI - Backend Testing on: push: branches: [ main ] pull_request: branches: [ main ] jobs: test-backend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python 3.12 uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install dependencies run: | cd backend python -m pip install --upgrade pip pip install -r requirements.txt pip install pytest httpx - name: Run Pytest run: | cd backend pytest test_main.py - name: Start server for Stress Test run: | cd backend # Install uvicorn if not present (it should be in requirements.txt) nohup python -m uvicorn main:app --host 0.0.0.0 --port 13002 > server.log 2>&1 & # Wait for the AI model to download and load (might take a while in CI) timeout 120 bash -c 'until curl -s http://localhost:13002/ > /dev/null; do sleep 5; done' - name: Run Stress Test run: | cd backend python stress_test.py - name: Show server logs on failure if: failure() run: cat backend/server.log