github_sync / .github /workflows /push_to_hf_space.yml
Amol Kaushik
testing
211a04f
raw
history blame
2.15 kB
name: Sync to Hugging Face hub
on:
push:
branches: [main]
workflow_dispatch:
jobs:
sync-to-hub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
# -------------------------
# 1. Set up Python
# -------------------------
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
# -------------------------
# 2. Install dependencies
# -------------------------
- name: Install dependencies
run: |
pip install --upgrade pip
pip install flake8
# -------------------------
# 3. Linting (QUALITY GATE)
# Pipeline FAILS if lint fails
# -------------------------
- name: Run linting
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# -------------------------
# 4. Block problematic files (pdf/xlsx)
# Prevents HuggingFace sync crashes
# -------------------------
- name: Check for restricted file types
run: |
if git diff --name-only HEAD~1 | grep -E '\.(pdf|xlsx)$'; then
echo "❌ PDF/XLSX files detected. These break HuggingFace sync."
exit 1
fi
# -------------------------
# 5. Placeholder for unit tests
# (does NOT fail pipeline yet)
# Replace later with pytest
# -------------------------
- name: Run unit tests (placeholder)
run: |
echo "No tests implemented yet — placeholder step."
echo "This will later run pytest."
# this is the completed test step
# - name: Run unit tests
# run: |
# pip install pytest
# pytest A4/ -v --tb=short
# -------------------------
# 6. Push to HuggingFace
# ONLY runs if lint passes
# -------------------------
- name: Push to hub
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
git push -f https://Bachstelze:$HF_TOKEN@huggingface.co/spaces/Bachstelze/github_sync main