|
| 1 | +name: Daily Docker Model Runner Health Check |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + schedule: |
| 8 | + # Run daily at 6 AM UTC |
| 9 | + - cron: '0 6 * * *' |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + test_model: |
| 13 | + description: 'Model to test with (default: ai/smollm2:360M-Q4_K_M)' |
| 14 | + required: false |
| 15 | + type: string |
| 16 | + default: 'ai/smollm2:360M-Q4_K_M' |
| 17 | + |
| 18 | +jobs: |
| 19 | + dmr-health-check: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + timeout-minutes: 30 |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Set up Docker |
| 25 | + uses: docker/setup-docker-action@v4 |
| 26 | + |
| 27 | + - name: Install docker-model-plugin |
| 28 | + run: | |
| 29 | + echo "Installing docker-model-plugin..." |
| 30 | + # Add Docker's official GPG key: |
| 31 | + sudo apt-get update |
| 32 | + sudo apt-get install ca-certificates curl |
| 33 | + sudo install -m 0755 -d /etc/apt/keyrings |
| 34 | + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc |
| 35 | + sudo chmod a+r /etc/apt/keyrings/docker.asc |
| 36 | + |
| 37 | + # Add the repository to Apt sources: |
| 38 | + echo \ |
| 39 | + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ |
| 40 | + $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \ |
| 41 | + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null |
| 42 | + sudo apt-get update |
| 43 | + sudo apt-get install -y docker-model-plugin |
| 44 | + |
| 45 | + echo "Installation completed successfully" |
| 46 | +
|
| 47 | + - name: Test docker model version |
| 48 | + run: | |
| 49 | + echo "Testing docker model version command..." |
| 50 | + sudo docker model version |
| 51 | + |
| 52 | + # Verify the command returns successfully |
| 53 | + if [ $? -eq 0 ]; then |
| 54 | + echo "✅ docker model version command works correctly" |
| 55 | + else |
| 56 | + echo "❌ docker model version command failed" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | +
|
| 60 | + - name: Test model pull and run |
| 61 | + run: | |
| 62 | + MODEL="${{ github.event.inputs.test_model || 'ai/smollm2:360M-Q4_K_M' }}" |
| 63 | + echo "Testing with model: $MODEL" |
| 64 | + |
| 65 | + # Test model pull |
| 66 | + echo "Pulling model..." |
| 67 | + sudo docker model pull "$MODEL" |
| 68 | + |
| 69 | + if [ $? -eq 0 ]; then |
| 70 | + echo "✅ Model pull successful" |
| 71 | + else |
| 72 | + echo "❌ Model pull failed" |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | + |
| 76 | + # Test basic model run (with timeout to avoid hanging) |
| 77 | + echo "Testing docker model run..." |
| 78 | + timeout 60s sudo docker model run "$MODEL" "Give me a fact about whales." || { |
| 79 | + exit_code=$? |
| 80 | + if [ $exit_code -eq 124 ]; then |
| 81 | + echo "✅ Model run test completed (timed out as expected for non-interactive test)" |
| 82 | + else |
| 83 | + echo "❌ Model run failed with exit code: $exit_code" |
| 84 | + exit 1 |
| 85 | + fi |
| 86 | + } |
| 87 | +
|
| 88 | + - name: Test API endpoint |
| 89 | + run: | |
| 90 | + MODEL="${{ github.event.inputs.test_model || 'ai/smollm2:360M-Q4_K_M' }}" |
| 91 | + echo "Testing API endpoint with model: $MODEL" |
| 92 | + |
| 93 | + # Test API call with curl |
| 94 | + echo "Testing API call..." |
| 95 | + RESPONSE=$(curl -s http://localhost:12434/engines/llama.cpp/v1/chat/completions \ |
| 96 | + -H "Content-Type: application/json" \ |
| 97 | + -d "{ |
| 98 | + \"model\": \"$MODEL\", |
| 99 | + \"messages\": [ |
| 100 | + { |
| 101 | + \"role\": \"user\", |
| 102 | + \"content\": \"Say hello\" |
| 103 | + } |
| 104 | + ], |
| 105 | + \"top_k\": 1, |
| 106 | + \"temperature\": 0 |
| 107 | + }") |
| 108 | + |
| 109 | + if [ $? -eq 0 ]; then |
| 110 | + echo "✅ API call successful" |
| 111 | + echo "Response received: $RESPONSE" |
| 112 | + |
| 113 | + # Check if response contains "hello" (case-insensitive) |
| 114 | + if echo "$RESPONSE" | grep -qi "hello"; then |
| 115 | + echo "✅ Response contains 'hello' (case-insensitive)" |
| 116 | + else |
| 117 | + echo "❌ Response does not contain 'hello'" |
| 118 | + echo "Full response: $RESPONSE" |
| 119 | + exit 1 |
| 120 | + fi |
| 121 | + else |
| 122 | + echo "❌ API call failed" |
| 123 | + exit 1 |
| 124 | + fi |
| 125 | +
|
| 126 | + - name: Test model cleanup |
| 127 | + run: | |
| 128 | + MODEL="${{ github.event.inputs.test_model || 'ai/smollm2:360M-Q4_K_M' }}" |
| 129 | + |
| 130 | + echo "Cleaning up test model..." |
| 131 | + sudo docker model rm "$MODEL" || echo "Model removal failed or model not found" |
| 132 | + |
| 133 | + # Verify model was removed |
| 134 | + echo "Verifying model cleanup..." |
| 135 | + sudo docker model ls |
| 136 | + |
| 137 | + echo "✅ Model cleanup completed" |
| 138 | +
|
| 139 | + - name: Report success |
| 140 | + if: success() |
| 141 | + run: | |
| 142 | + echo "🎉 Docker Model Runner daily health check completed successfully!" |
| 143 | + echo "All tests passed:" |
| 144 | + echo " ✅ docker-model-plugin installation successful" |
| 145 | + echo " ✅ docker model version command working" |
| 146 | + echo " ✅ Model pull and run operations successful" |
| 147 | + echo " ✅ API endpoint operations successful" |
| 148 | + echo " ✅ Cleanup operations successful" |
0 commit comments