name: CI on: push: branches: [main] pull_request: branches: [main] jobs: test: runs-on: ubuntu-latest services: redis: image: redis:7-alpine ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.11" - name: Cache pip dependencies uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} restore-keys: ${{ runner.os }}-pip- - name: Install dependencies run: pip install -r requirements.txt - name: Lint run: ruff check app/ tests/ - name: Type check run: mypy app/ --ignore-missing-imports - name: Security scan run: bandit -r app/ -q - name: Unit + integration tests with coverage env: PYTHONPATH: . OPENROUTER_API_KEY: "ci-placeholder" API_KEY: "ci-placeholder" REDIS_URL: "redis://localhost:6379/0" CELERY_RESULT_BACKEND: "redis://localhost:6379/1" CELERY_TASK_ALWAYS_EAGER: "true" run: | pytest tests/ -v \ --cov=app \ --cov-report=term-missing \ --cov-report=xml \ --cov-fail-under=80 \ --tb=short \ --ignore=tests/load \ -x - name: Upload coverage report uses: codecov/codecov-action@v4 with: file: ./coverage.xml fail_ci_if_error: false eval: needs: test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.11" - name: Cache pip dependencies uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} - name: Install dependencies run: pip install -r requirements.txt - name: Run eval suite env: PYTHONPATH: . OPENROUTER_API_KEY: "ci-placeholder" API_KEY: "ci-placeholder" run: pytest tests/eval/ -v --tb=short -s docker: needs: test runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set lowercase repo name run: echo "REPO_LOWER=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . push: true cache-from: type=gha cache-to: type=gha,mode=max tags: | ghcr.io/${{ env.REPO_LOWER }}:latest ghcr.io/${{ env.REPO_LOWER }}:${{ github.sha }}