name: Backend Tests on: push: branches: [ main, develop ] paths: - 'backend/**' - '.github/workflows/backend-tests.yml' pull_request: branches: [ main, develop ] paths: - 'backend/**' jobs: test: runs-on: ubuntu-latest services: postgres: image: ankane/pgvector:latest env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: microfunnel_test options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 redis: image: redis:7-alpine options: >- --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 6379:6379 steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install dependencies working-directory: ./backend run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Run tests with coverage working-directory: ./backend env: DATABASE_URL: postgresql://postgres:postgres@localhost:5432/microfunnel_test REDIS_URL: redis://localhost:6379 SECRET_KEY: test-secret-key-for-ci-cd-pipeline-only GEMINI_API_KEY: test-key SUPABASE_URL: https://test.supabase.co SUPABASE_KEY: test-key DEBUG: false run: | pytest --cov=app --cov-report=xml --cov-report=term - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: file: ./backend/coverage.xml flags: backend name: backend-coverage