Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions .github/workflows/hf_space_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Test HF Space Dockerfile

on:
push:
branches: [ main ]
paths:
- 'Dockerfile.hf-space'
- '.github/workflows/hf_space_docker.yml'
pull_request:
branches: [ main ]
paths:
- 'Dockerfile.hf-space'
- '.github/workflows/hf_space_docker.yml'
Comment on lines +5 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this action won't be triggered

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@Samoed Samoed Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this. This will be triggered only on changed in dockerfile for spaces, but I'm not sure if it will be enough to test then

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to move these checks to leaderboard_docker.yml to test this more frequently and make sure that our leaderboard will work

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, that's what the paths section of the workflow file shows. I'm not sure there's new info here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping these tests separate makes more sense.

workflow_dispatch:

jobs:
test-hf-space-dockerfile:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Free disk space
run: |
sudo rm -rf \
"$AGENT_TOOLSDIRECTORY" \
/opt/ghc \
/opt/google/chrome \
/opt/microsoft/msedge \
/opt/microsoft/powershell \
/opt/pipx \
/usr/lib/mono \
/usr/local/julia* \
/usr/local/lib/android \
/usr/local/lib/node_modules \
/usr/local/share/chromium \
/usr/local/share/powershell \
/usr/share/dotnet \
/usr/share/swift || true
docker system prune -af || true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build HF Space Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.hf-space
push: false
tags: mteb-hf-space:test
load: true

- name: Test container can start and run
timeout-minutes: 6
run: |
# Start the container in background
docker run -d --name mteb-hf-test -p 7860:7860 mteb-hf-space:test

# Monitor container with smart exit conditions
echo "Starting HF Space leaderboard container..."
START_TIME=$(date +%s)
STARTUP_DETECTED=false
INIT_COMPLETE_DETECTED=false

while true; do
CURRENT_TIME=$(date +%s)
ELAPSED=$((CURRENT_TIME - START_TIME))

# Maximum timeout: 5.5 minutes
if [ $ELAPSED -gt 330 ]; then
echo "Timeout reached after ${ELAPSED}s - container failed to complete initialization"
docker logs --tail 20 mteb-hf-test
docker stop mteb-hf-test
docker rm mteb-hf-test
exit 1
fi

# Check if container is still running
if ! docker ps | grep -q mteb-hf-test; then
EXIT_CODE=$(docker inspect mteb-hf-test --format='{{.State.ExitCode}}')
echo "Container exited with code: $EXIT_CODE after ${ELAPSED}s"

LOGS=$(docker logs mteb-hf-test 2>&1)
if echo "$LOGS" | grep -q "=== Leaderboard app initialization complete" || \
echo "$LOGS" | grep -q "Running on.*http"; then
echo "Container completed significant startup progress successfully"
docker rm mteb-hf-test
exit 0
else
echo "Container failed before completing startup initialization"
echo "Last logs:"
echo "$LOGS" | tail -10
docker rm mteb-hf-test
exit 1
fi
fi

LOGS=$(docker logs mteb-hf-test 2>&1)

if [ "$STARTUP_DETECTED" = "false" ] && echo "$LOGS" | grep -q "Starting leaderboard app in process"; then
echo "Detected leaderboard app startup"
STARTUP_DETECTED=true
fi

if [ "$INIT_COMPLETE_DETECTED" = "false" ] && echo "$LOGS" | grep -q "=== Leaderboard app initialization complete"; then
echo "Detected full app initialization complete!"
INIT_COMPLETE_DETECTED=true
sleep 3
if curl -s --max-time 5 http://localhost:7860/ > /dev/null; then
echo "Server is responding - container fully operational!"
docker stop mteb-hf-test
docker rm mteb-hf-test
exit 0
fi
fi

if echo "$LOGS" | grep -q "Running on.*http"; then
echo "Detected Gradio server ready - container fully operational!"
docker stop mteb-hf-test
docker rm mteb-hf-test
exit 0
fi

if [ $((ELAPSED % 30)) -eq 0 ] && [ $ELAPSED -gt 0 ]; then
echo "Container still running after ${ELAPSED}s... (startup: $STARTUP_DETECTED, init_complete: $INIT_COMPLETE_DETECTED)"
echo "$LOGS" | grep -E "(Step [0-9]/7|Starting leaderboard|initialization complete|Running on)" | tail -2
fi

sleep 5
done
6 changes: 6 additions & 0 deletions Dockerfile.hf-space
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ghcr.io/embeddings-benchmark/mteb/leaderboard:latest

ENV GRADIO_SERVER_NAME="0.0.0.0"
EXPOSE 7860

CMD ["make", "run-leaderboard"]
Loading