fix(ci): replace jq with python3 for JSON parsing in Ollama test

The self-hosted runner doesn't have jq installed.
Use Python's json module as a portable alternative.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-25 12:07:23 +08:00
parent e87ac11f4f
commit b8f9cd315c

View File

@@ -231,7 +231,8 @@ jobs:
echo "🔗 測試 Ollama 連線..."
if curl -s --connect-timeout 5 http://192.168.0.188:11434/api/tags > /dev/null; then
echo "✅ Ollama 可達"
curl -s http://192.168.0.188:11434/api/tags | jq -r '.models[].name'
# 使用 Python 替代 jq (Runner 未安裝 jq)
curl -s http://192.168.0.188:11434/api/tags | python3 -c "import sys,json; [print(m['name']) for m in json.load(sys.stdin).get('models',[])]"
else
echo "⚠️ Ollama 無法連線 (192.168.0.188:11434)"
exit 0 # 不失敗,只警告
@@ -240,11 +241,12 @@ jobs:
- name: Model Smoke Test
run: |
echo "🧪 模型冒煙測試..."
# 使用 Python 替代 jq
RESPONSE=$(curl -s --max-time 60 http://192.168.0.188:11434/api/generate -d '{
"model": "qwen2.5:7b-instruct",
"prompt": "你是 AIOps 助手。回答1+1=?",
"stream": false
}' | jq -r '.response // "ERROR"')
}' | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('response','ERROR'))" 2>/dev/null || echo "ERROR")
if [ "$RESPONSE" != "ERROR" ] && [ -n "$RESPONSE" ]; then
echo "✅ 模型回應正常"