Spaces:
Running
Running
| name: CI Pipeline | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| backend-lint: | |
| name: Backend Checks (Lint) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up 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 ruff | |
| - name: Lint with Ruff | |
| run: | | |
| ruff check backend/ --select=E9,F63,F7,F82 | |
| frontend-build-and-deploy: | |
| name: Build & Deploy to HuggingFace | |
| needs: backend-lint | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| lfs: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install Frontend Dependencies | |
| working-directory: ./frontend | |
| run: npm install | |
| - name: Build Frontend | |
| working-directory: ./frontend | |
| run: npm run build | |
| - name: Push Clean Release to Hugging Face Space | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| HUGGINGFACE_TOKEN: ${{ secrets.HUGGINGFACE_TOKEN }} | |
| HF_SPACE: ${{ secrets.HF_SPACE }} | |
| run: | | |
| TOKEN="${HF_TOKEN:-$HUGGINGFACE_TOKEN}" | |
| SPACE_NAME="${HF_SPACE:-datavision-ai/Datavision}" | |
| if [ -n "$TOKEN" ]; then | |
| echo "๐ Syncing clean release to Hugging Face Space: $SPACE_NAME" | |
| git config --global user.email "ci@datavision.ai" | |
| git config --global user.name "DataVision CI/CD Bot" | |
| git config --global lfs.allowincompletepush false | |
| git lfs install | |
| git lfs pull | |
| # Create clean orphan release branch without historical broken LFS pointers | |
| git checkout --orphan hf-release | |
| git reset | |
| # Stage current active files and built frontend assets | |
| git add -A | |
| git add -f frontend/dist 2>/dev/null || true | |
| git commit -m "release: clean production build for HuggingFace Space" || true | |
| # Setup HF remote and force push clean orphan branch to main | |
| git remote remove hf 2>/dev/null || true | |
| git remote add hf "https://user:$TOKEN@huggingface.co/spaces/$SPACE_NAME" | |
| git lfs push hf hf-release | |
| git push -f hf hf-release:main | |
| echo "โ Successfully pushed clean release to Hugging Face Space: $SPACE_NAME" | |
| else | |
| echo "โ ๏ธ Secret HF_TOKEN not set. Set HF_TOKEN in GitHub Settings -> Secrets -> Actions to auto-deploy." | |
| fi | |