name: CI — Enterprise AI Copilot on: push: branches: [main, develop] pull_request: branches: [main] jobs: # ── Lint ────────────────────────────────────────────────── lint: name: Lint (ruff) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python 3.10 uses: actions/setup-python@v5 with: python-version: "3.10" cache: "pip" - name: Install ruff run: pip install ruff==0.8.6 - name: Run ruff check run: ruff check backend/app/ agents/ services/ - name: Run ruff format check run: ruff format --check backend/app/ agents/ services/ # ── Backend Tests ───────────────────────────────────────── test: name: Tests (pytest) runs-on: ubuntu-latest needs: lint env: DEPLOY_MODE: local LLM_PROVIDER: groq GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} DATABASE_URL: sqlite+aiosqlite:///./test.db SECRET_KEY: test-secret-key-for-ci-only DEBUG: "true" steps: - uses: actions/checkout@v4 - name: Set up Python 3.10 uses: actions/setup-python@v5 with: python-version: "3.10" cache: "pip" - name: Install dependencies run: | cd backend pip install -r requirements.txt - name: Run tests run: | cd backend PYTHONPATH=/backend:/agents:/services pytest ../tests/ -v \ --cov=app --cov-report=xml --cov-report=term-missing \ --asyncio-mode=auto - name: Upload coverage report uses: codecov/codecov-action@v4 if: success() with: file: ./backend/coverage.xml # ── Docker Build ────────────────────────────────────────── docker: name: Docker Build runs-on: ubuntu-latest needs: test steps: - uses: actions/checkout@v4 - name: Build Docker image (HF Spaces) run: docker build -t enterprise-ai-copilot:latest -f Dockerfile . - name: Verify container starts run: | docker run --rm -d \ --name test-copilot \ -e GROQ_API_KEY=test \ -e SECRET_KEY=test-key \ -p 7860:7860 \ enterprise-ai-copilot:latest sleep 10 curl -f http://localhost:7860/health || exit 1 docker stop test-copilot