backend / .github /workflows /sync-to-hf.yml
PopovDanil's picture
try 1
d412733
name: Sync to Hugging Face Hub
on:
push:
branches: [main]
workflow_dispatch:
jobs:
sync-to-hub:
runs-on: ubuntu-latest
environment: Integration test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Configure Git identity
run: |
git config --global user.name "Andrchest"
git config --global user.email "andreipolevoi220@gmail.com"
- name: Push to HF1
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
git checkout -b hf1-single-commit
git reset --soft $(git rev-list --max-parents=0 HEAD)
git commit -m "Single commit for HF1"
git remote add hf1 https://Andrchest:$HF_TOKEN@huggingface.co/spaces/The-Ultimate-RAG-HF/RAG-Integration-test
git push --force hf1 hf1-single-commit:main
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install -r app/requirements.txt
- name: Wait for HF1 deployment
run: sleep 120
- name: Debug environment variables
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
SECRET_PEPPER: ${{ secrets.SECRET_PEPPER }}
JWT_ALGORITHM: ${{ secrets.JWT_ALGORITHM }}
PYTHONPATH: ${{ github.workspace }}
run: |
echo "DATABASE_URL is set: ${DATABASE_URL:+set}"
echo "GEMINI_API_KEY is set: ${GEMINI_API_KEY:+set}"
echo "SECRET_PEPPER is set: ${SECRET_PEPPER:+set}"
echo "JWT_ALGORITHM is set: ${JWT_ALGORITHM:+set}"
env | grep -E 'DATABASE_URL|GEMINI_API_KEY|SECRET_PEPPER|JWT_ALGORITHM'
- name: Initialize directories
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
SECRET_PEPPER: ${{ secrets.SECRET_PEPPER }}
JWT_ALGORITHM: ${{ secrets.JWT_ALGORITHM }}
PYTHONPATH: ${{ github.workspace }}
working-directory: ./
run: |
python -m app.initializer
- name: Debug directory structure
run: |
ls -R
- name: Run integration tests with coverage
env:
HF1_URL: ${{ secrets.HF1_URL }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
SECRET_PEPPER: ${{ secrets.SECRET_PEPPER }}
JWT_ALGORITHM: ${{ secrets.JWT_ALGORITHM }}
PYTHONPATH: ${{ github.workspace }}
working-directory: ./
run: |
echo "PYTHONPATH: $PYTHONPATH"
python -m pytest app/tests/integration/test.py -v --cov=app --cov-report=xml --cov-report=html
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: integration-coverage-report
path: |
coverage.xml
htmlcov/
- name: Push to HF2 if tests pass
if: success()
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
git checkout -b hf2-single-commit
git reset --soft $(git rev-list --max-parents=0 HEAD)
git commit -m "Single commit for HF2"
git remote add hf2 https://Andrchest:$HF_TOKEN@huggingface.co/spaces/The-Ultimate-RAG-HF/The-Ultimate-RAG
git push --force hf2 hf2-single-commit:main