Spaces:
Sleeping
Sleeping
Reem commited on
Commit ·
8c1034b
1
Parent(s): 6e4d79b
update-push_to_hf_space.yaml
Browse files
.github/workflows/push_to_hf_space.yml
CHANGED
|
@@ -1,20 +1,72 @@
|
|
| 1 |
name: Sync to Hugging Face hub
|
|
|
|
| 2 |
on:
|
| 3 |
push:
|
| 4 |
branches: [main]
|
| 5 |
|
| 6 |
-
# to run this workflow manually from the Actions tab
|
| 7 |
workflow_dispatch:
|
| 8 |
|
| 9 |
jobs:
|
| 10 |
sync-to-hub:
|
| 11 |
runs-on: ubuntu-latest
|
|
|
|
| 12 |
steps:
|
| 13 |
- uses: actions/checkout@v3
|
| 14 |
with:
|
| 15 |
fetch-depth: 0
|
| 16 |
lfs: true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
- name: Push to hub
|
| 18 |
env:
|
| 19 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
-
run:
|
|
|
|
|
|
| 1 |
name: Sync to Hugging Face hub
|
| 2 |
+
|
| 3 |
on:
|
| 4 |
push:
|
| 5 |
branches: [main]
|
| 6 |
|
|
|
|
| 7 |
workflow_dispatch:
|
| 8 |
|
| 9 |
jobs:
|
| 10 |
sync-to-hub:
|
| 11 |
runs-on: ubuntu-latest
|
| 12 |
+
|
| 13 |
steps:
|
| 14 |
- uses: actions/checkout@v3
|
| 15 |
with:
|
| 16 |
fetch-depth: 0
|
| 17 |
lfs: true
|
| 18 |
+
|
| 19 |
+
# -------------------------
|
| 20 |
+
# 1. Set up Python
|
| 21 |
+
# -------------------------
|
| 22 |
+
- name: Set up Python
|
| 23 |
+
uses: actions/setup-python@v4
|
| 24 |
+
with:
|
| 25 |
+
python-version: '3.10'
|
| 26 |
+
|
| 27 |
+
# -------------------------
|
| 28 |
+
# 2. Install dependencies
|
| 29 |
+
# -------------------------
|
| 30 |
+
- name: Install dependencies
|
| 31 |
+
run: |
|
| 32 |
+
pip install --upgrade pip
|
| 33 |
+
pip install flake8
|
| 34 |
+
|
| 35 |
+
# -------------------------
|
| 36 |
+
# 3. Linting (QUALITY GATE)
|
| 37 |
+
# Pipeline FAILS if lint fails
|
| 38 |
+
# -------------------------
|
| 39 |
+
- name: Run linting
|
| 40 |
+
run: |
|
| 41 |
+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
| 42 |
+
|
| 43 |
+
# -------------------------
|
| 44 |
+
# 4. Block problematic files (pdf/xlsx)
|
| 45 |
+
# Prevents HuggingFace sync crashes
|
| 46 |
+
# -------------------------
|
| 47 |
+
- name: Check for restricted file types
|
| 48 |
+
run: |
|
| 49 |
+
if git diff --name-only HEAD~1 | grep -E '\.(pdf|xlsx)$'; then
|
| 50 |
+
echo "❌ PDF/XLSX files detected. These break HuggingFace sync."
|
| 51 |
+
exit 1
|
| 52 |
+
fi
|
| 53 |
+
|
| 54 |
+
# -------------------------
|
| 55 |
+
# 5. Placeholder for unit tests
|
| 56 |
+
# (does NOT fail pipeline yet)
|
| 57 |
+
# Replace later with pytest
|
| 58 |
+
# -------------------------
|
| 59 |
+
- name: Run unit tests (placeholder)
|
| 60 |
+
run: |
|
| 61 |
+
echo "No tests implemented yet — placeholder step."
|
| 62 |
+
echo "This will later run pytest."
|
| 63 |
+
|
| 64 |
+
# -------------------------
|
| 65 |
+
# 6. Push to HuggingFace
|
| 66 |
+
# ONLY runs if lint passes
|
| 67 |
+
# -------------------------
|
| 68 |
- name: Push to hub
|
| 69 |
env:
|
| 70 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 71 |
+
run: |
|
| 72 |
+
git push -f https://Bachstelze:$HF_TOKEN@huggingface.co/spaces/Bachstelze/github_sync main
|