Skip to content

Test: Implement End-to-End Testing Pipeline using Cypress #56

Test: Implement End-to-End Testing Pipeline using Cypress

Test: Implement End-to-End Testing Pipeline using Cypress #56

Workflow file for this run

name: CI – Run Tests
on:
push:
branches: ["main", "master"]
pull_request:
branches: ["main", "master"]
jobs:
test:
name: pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r backend/requirements.txt
pip install pytest pytest-cov
pip install flask-wtf bleach Pillow beautifulsoup4 "pydantic[email]" pytest pytest-cov
- name: Run pytest
env:
GOOGLE_BOOKS_API_KEY: "ci-fake-key"
OPENAI_API_KEY: "ci-fake-key"
GROQ_API_KEY: "ci-fake-key"
GEMINI_API_KEY: "ci-fake-key"
FLASK_ENV: testing
PYTHONPATH: ".:backend"
run: |
python -m pytest tests/ \
--ignore=tests/test_llm.py \
--ignore=tests/test_mood_improvements.py \
--ignore=tests/test_mood_cache_db.py \
--ignore=tests/test_category_cache.py \
--ignore=tests/test_env_validation.py \
--ignore=tests/test_purchase_links.py \
-v --tb=short --cov=backend
- name: Install dependencies
run: |
pip install --upgrade pip
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install -r backend/requirements.txt
pip install flask-wtf bleach Pillow pytest pytest-cov
- name: Install dependencies
run: |
pip install --upgrade pip
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install -r backend/requirements.txt
pip install flask-wtf bleach Pillow beautifulsoup4 pytest pytest-cov
e2e:
name: Cypress E2E
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install backend dependencies
run: |
pip install --upgrade pip
pip install -r backend/requirements.txt
pip install flask-wtf bleach Pillow beautifulsoup4 "pydantic[email]" pytest pytest-cov
- name: Start backend server
env:
GOOGLE_BOOKS_API_KEY: "ci-fake-key"
OPENAI_API_KEY: "ci-fake-key"
GROQ_API_KEY: "ci-fake-key"
GEMINI_API_KEY: "ci-fake-key"
JWT_SECRET_KEY: "ci-fake-jwt-secret-key-that-is-at-least-32-bytes"
DATABASE_URL: "sqlite:///:memory:"
FLASK_ENV: testing
PYTHONPATH: ".:backend"
run: |
nohup python backend/app.py > backend.log 2>&1 &
sleep 5
- name: Install frontend dependencies
run: npm install
- name: Start frontend server
run: |
nohup python -m http.server 5500 > frontend.log 2>&1 &
sleep 2
- name: Run Cypress tests
uses: cypress-io/github-action@v6
with:
wait-on: 'http://127.0.0.1:5000, http://127.0.0.1:5500'
wait-on-timeout: 30
browser: chrome
- name: Print backend logs on failure
if: failure()
run: |
echo "=== BACKEND LOG ==="
cat backend.log || true
echo "=== FRONTEND LOG ==="
cat frontend.log || true