Spaces:
Running
Running
name: Python Test | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
UV_SYSTEM_PYTHON: 1 | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
steps: | |
- name: Checkout PR with full history | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v6 | |
with: | |
enable-cache: true | |
cache-dependency-glob: "pyproject.toml" | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: bash scripts/install-linux.sh | |
- name: List dependencies | |
run: pip list | |
- name: Login to Hugging Face | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN_READ_ONLY }} | |
run: huggingface-cli login --token $HF_TOKEN | |
- name: Run tests | |
env: | |
PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }} | |
PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }} | |
run: pytest -vra -n 5 --dist=loadscope tests | |
- name: Squash commits and trial push to Hugging Face | |
if: github.event_name == 'pull_request' | |
id: trial_push | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
TRIAL_BRANCH: trial-sync-${{ github.sha }}-${{ matrix.python-version }} | |
run: | | |
# Configure Git user identity | |
git config user.name "github-actions[ci]" | |
git config user.email "github-actions[ci]@users.noreply.github.com" | |
# Install Git LFS | |
sudo apt-get update | |
sudo apt-get install -y git-lfs | |
git lfs install | |
# Configure LFS tracking for binary files (only for HF push) | |
git lfs track "*.pdf" | |
git lfs track "*.png" | |
git add .gitattributes | |
# Setup LFS for the remote | |
git lfs fetch | |
git lfs checkout | |
# Rebase and squash all PR commits into one | |
BASE=$(git merge-base origin/main HEAD) | |
git reset --soft $BASE | |
# Re-add all files (binary files will now be tracked by LFS) | |
git add . | |
git commit -m "Squashed commit from PR #${{ github.event.pull_request.number }}" | |
# Create a new orphan branch (no history) | |
git checkout --orphan hf-clean | |
git add . | |
git commit -m "Clean sync from main branch - $(date '+%Y-%m-%d %H:%M:%S')" | |
# Push to temporary branch on Hugging Face | |
git push -f https://HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/atomind/mlip-arena HEAD:refs/heads/$TRIAL_BRANCH | |
- name: Delete trial branch from Hugging Face | |
if: steps.trial_push.outcome == 'success' | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
TRIAL_BRANCH: trial-sync-${{ github.sha }}-${{ matrix.python-version }} | |
run: | | |
git push https://HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/atomind/mlip-arena --delete $TRIAL_BRANCH || true | |