2.8.2 #213
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Leaderboard Dockerfile | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'Dockerfile' | |
| - '.github/workflows/leaderboard_docker.yml' | |
| - 'pyproject.toml' | |
| - 'uv.lock' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'Dockerfile' | |
| - '.github/workflows/leaderboard_docker.yml' | |
| - 'pyproject.toml' | |
| - 'uv.lock' | |
| workflow_dispatch: | |
| jobs: | |
| test-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 | |
| docker system prune -af | |
| - 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 and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: ${{ github.ref == 'refs/heads/main' }} | |
| tags: | | |
| ghcr.io/${{ github.repository }}/leaderboard:${{ github.sha }} | |
| ghcr.io/${{ github.repository }}/leaderboard:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| load: true | |
| - name: Prepare image for local testing | |
| run: | | |
| docker tag ghcr.io/${{ github.repository }}/leaderboard:${{ github.sha }} mteb-leaderboard:test | |
| - name: Test container can start and run | |
| timeout-minutes: 9 | |
| run: | | |
| # Start the container in background | |
| docker run -d --name mteb-test -p 7860:7860 mteb-leaderboard:test | |
| # Monitor container with smart exit conditions | |
| echo "Starting leaderboard container..." | |
| START_TIME=$(date +%s) | |
| STARTUP_DETECTED=false | |
| PROGRESS_DETECTED=false | |
| INIT_COMPLETE_DETECTED=false | |
| while true; do | |
| CURRENT_TIME=$(date +%s) | |
| ELAPSED=$((CURRENT_TIME - START_TIME)) | |
| # Maximum timeout: 8 minutes - always fail at timeout | |
| if [ $ELAPSED -gt 480 ]; then | |
| echo "❌ Timeout reached after ${ELAPSED}s - container failed to complete initialization" | |
| docker logs --tail 20 mteb-test | |
| docker stop mteb-test | |
| docker rm mteb-test | |
| exit 1 | |
| fi | |
| # Check if container is still running | |
| if ! docker ps | grep -q mteb-test; then | |
| # Container exited, check exit code and logs | |
| EXIT_CODE=$(docker inspect mteb-test --format='{{.State.ExitCode}}') | |
| echo "Container exited with code: $EXIT_CODE after ${ELAPSED}s" | |
| # Check if we made good progress before exit | |
| LOGS=$(docker logs mteb-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-test | |
| exit 0 | |
| else | |
| echo "❌ Container failed before completing startup initialization" | |
| echo "Last logs:" | |
| echo "$LOGS" | tail -10 | |
| docker rm mteb-test | |
| exit 1 | |
| fi | |
| fi | |
| # Get current logs and check for progress indicators | |
| LOGS=$(docker logs mteb-test 2>&1) | |
| # Check for startup detection | |
| if [ "$STARTUP_DETECTED" = "false" ] && echo "$LOGS" | grep -q "Starting leaderboard app in process"; then | |
| echo "✅ Detected leaderboard app startup" | |
| STARTUP_DETECTED=true | |
| fi | |
| # Check for full initialization complete | |
| if [ "$INIT_COMPLETE_DETECTED" = "false" ] && echo "$LOGS" | grep -q "=== Leaderboard app initialization complete"; then | |
| echo "✅ Detected full app initialization complete!" | |
| INIT_COMPLETE_DETECTED=true | |
| echo "🔄 Testing if server is responding..." | |
| # Give it a moment for the server to fully start | |
| sleep 3 | |
| # Try to ping the server | |
| if curl -s --max-time 5 http://localhost:7860/ > /dev/null; then | |
| echo "✅ Server is responding - container fully operational!" | |
| docker stop mteb-test | |
| docker rm mteb-test | |
| exit 0 | |
| else | |
| echo "⏳ Server not yet responding, continuing to wait..." | |
| PROGRESS_DETECTED=true | |
| fi | |
| fi | |
| # Check for Gradio server ready | |
| if echo "$LOGS" | grep -q "Running on.*http"; then | |
| echo "✅ Detected Gradio server ready - container fully operational!" | |
| docker stop mteb-test | |
| docker rm mteb-test | |
| exit 0 | |
| fi | |
| # Show progress every 30 seconds | |
| if [ $((ELAPSED % 30)) -eq 0 ] && [ $ELAPSED -gt 0 ]; then | |
| echo "Container still running after ${ELAPSED}s... (startup: $STARTUP_DETECTED, init_complete: $INIT_COMPLETE_DETECTED)" | |
| # Show last few lines of logs for progress | |
| echo "$LOGS" | grep -E "(Step [0-9]/7|Starting leaderboard|initialization complete|Running on)" | tail -2 | |
| fi | |
| sleep 5 | |
| done |