Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
| name: CI - Build & Test | |
| # Run on all pushes and pull requests to catch build errors early | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| - huggingface-deploy # Test deploy branch before HF build | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| jobs: | |
| # Test 1: Frontend TypeScript Build | |
| frontend-build: | |
| name: Frontend Build (TypeScript + Vite) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install frontend dependencies | |
| run: | | |
| cd frontend | |
| npm ci | |
| - name: Run TypeScript type check | |
| run: | | |
| cd frontend | |
| npx tsc --noEmit | |
| - name: Build frontend | |
| run: | | |
| cd frontend | |
| npm run build | |
| - name: Check build artifacts | |
| run: | | |
| if [ ! -d "frontend/dist" ]; then | |
| echo "β Frontend build failed - no dist directory" | |
| exit 1 | |
| fi | |
| echo "β Frontend build successful" | |
| # Test 2: Documentation Site Build | |
| # CRITICAL: This catches Docusaurus config errors (like duplicate gtag) before HuggingFace deployment | |
| docs-build: | |
| name: Documentation Build (Docusaurus) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: website/package-lock.json | |
| - name: Install docs dependencies | |
| run: | | |
| cd website | |
| npm ci | |
| - name: Build documentation | |
| run: | | |
| cd website | |
| npm run build | |
| - name: Check build artifacts | |
| run: | | |
| if [ ! -d "website/build" ]; then | |
| echo "β Docs build failed - no build directory" | |
| exit 1 | |
| fi | |
| echo "β Documentation build successful" | |
| # Test 3: Python Backend | |
| backend-test: | |
| name: Backend Tests (Python) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Check Python syntax | |
| run: | | |
| python -m py_compile main.py | |
| find api -name "*.py" -exec python -m py_compile {} \; | |
| echo "β Python syntax check passed" | |
| - name: Import test | |
| run: | | |
| python -c "import main; print('β Main module imports successfully')" | |
| python -c "from api.app import app; print('β API app imports successfully')" | |
| # Test 4: Docker Build (Full Integration Test) | |
| docker-build: | |
| name: Docker Build Test (Full Stack) | |
| runs-on: ubuntu-latest | |
| needs: [frontend-build, docs-build, backend-test] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image (no push) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile.huggingface | |
| push: false | |
| tags: test-build:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Report success | |
| run: | | |
| echo "β All builds passed!" | |
| echo "β Frontend: TypeScript + Vite" | |
| echo "β Documentation: Docusaurus" | |
| echo "β Backend: Python imports" | |
| echo "β Docker: Full stack build" | |