Spaces:
Running
Running
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "src/**" | |
| - "api/**" | |
| - "docker/**" | |
| - "app.py" | |
| - "requirements.txt" | |
| workflow_dispatch: | |
| jobs: | |
| test-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install test dependencies only | |
| run: | | |
| pip install pytest fastapi httpx pydantic numpy pillow python-multipart | |
| - name: Run pytest | |
| run: PYTHONPATH=. pytest tests/test_api.py -v --tb=short | |
| - name: Deploy to HuggingFace Spaces | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| pip install huggingface_hub | |
| python -c " | |
| from huggingface_hub import HfApi | |
| import os | |
| api = HfApi(token=os.environ['HF_TOKEN']) | |
| api.upload_folder( | |
| folder_path='.', | |
| repo_id='CaffeinatedCoding/anomalyos', | |
| repo_type='space', | |
| ignore_patterns=['*.pyc','__pycache__','.git','tests/','notebooks/','data/','models/','logs/','reports/'] | |
| ) | |
| print('Deployed to HF Spaces') | |
| " | |
| - name: Smoke test | |
| run: | | |
| sleep 60 | |
| curl --fail --retry 5 --retry-delay 30 \ | |
| https://caffeinatedcoding-anomalyos.hf.space/health || echo "Space still warming up" |