| name: SmartRAG CI/CD |
|
|
| on: |
| push: |
| branches: [main, dev] |
| pull_request: |
| branches: [main] |
|
|
| jobs: |
| |
| test: |
| name: Run Test Suite |
| runs-on: ubuntu-latest |
|
|
| steps: |
| - uses: actions/checkout@v4 |
|
|
| - name: Set up Python 3.11 |
| uses: actions/setup-python@v5 |
| with: |
| python-version: "3.11" |
| cache: "pip" |
|
|
| - name: Install dependencies |
| run: | |
| pip install --upgrade pip |
| pip install pytest pytest-cov |
| # Install CPU-only torch for CI (no GPU needed for unit tests) |
| pip install torch --index-url https://download.pytorch.org/whl/cpu |
| pip install transformers peft datasets langchain langchain-community \ |
| chromadb sentence-transformers fastapi httpx pydantic \ |
| uvicorn trl bitsandbytes mlflow ragas |
| |
| - name: Run unit tests (no GPU required) |
| run: | |
| pytest tests/ -v -m "not slow" --cov=. --cov-report=xml |
| |
| - name: Upload coverage |
| uses: codecov/codecov-action@v4 |
| with: |
| file: coverage.xml |
|
|
| |
| build: |
| name: Build Docker Image |
| runs-on: ubuntu-latest |
| needs: test |
|
|
| steps: |
| - uses: actions/checkout@v4 |
|
|
| - name: Set up Docker Buildx |
| uses: docker/setup-buildx-action@v3 |
|
|
| - name: Log in to Docker Hub |
| uses: docker/login-action@v3 |
| with: |
| username: ${{ secrets.DOCKER_USERNAME }} |
| password: ${{ secrets.DOCKER_PASSWORD }} |
|
|
| - name: Build & push API image |
| uses: docker/build-push-action@v5 |
| with: |
| context: . |
| file: ./Dockerfile |
| push: ${{ github.ref == 'refs/heads/main' }} |
| tags: | |
| ${{ secrets.DOCKER_USERNAME }}/smartrag-api:latest |
| ${{ secrets.DOCKER_USERNAME }}/smartrag-api:${{ github.sha }} |
| cache-from: type=gha |
| cache-to: type=gha,mode=max |
|
|
| |
| deploy-hf-spaces: |
| name: Deploy to HF Spaces |
| runs-on: ubuntu-latest |
| needs: [test, build] |
| if: github.ref == 'refs/heads/main' |
|
|
| steps: |
| - uses: actions/checkout@v4 |
|
|
| - name: Push to HF Spaces |
| uses: huggingface/hf-actions/push-to-hub@v1 |
| with: |
| space_name: ${{ secrets.HF_USERNAME }}/smartrag |
| token: ${{ secrets.HF_TOKEN }} |
|
|