Skip to content

Fix API call on online test action #7

Fix API call on online test action

Fix API call on online test action #7

Workflow file for this run

name: Online Stack Test
on:
push:
branches:
- main
jobs:
test-online-stack:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Copy .env.example to .env
run: cp .env.example .env
- name: Create docs directory
run: mkdir -p docs
- name: Download and extract documentation
run: |
curl -L "${{ secrets.DOCS_URL }}" -o documentation.zip
unzip documentation.zip -d docs
rm documentation.zip
- name: Set environment variables
run: |
sed -i "s/^LANGFUSE_PUBLIC_KEY=.*/LANGFUSE_PUBLIC_KEY=\${{ secrets.LANGFUSE_PK }}/" .env
sed -i "s/^LANGFUSE_SECRET_KEY=.*/LANGFUSE_SECRET_KEY=\${{ secrets.LANGFUSE_SK }}/" .env
sed -i "s|^LANGFUSE_HOST=.*|LANGFUSE_HOST=\${{ secrets.LANGFUSE_HOST }}|" .env
sed -i "s|^LOCAL_EMBEDDING=false|LOCAL_EMBEDDING=true|" .env
sed -i "s|^GROQ_API_KEY=.*|GROQ_API_KEY=\${{ secrets.GROQ_API_KEY }}|" .env
- name: Show contents of .env
run: cat .env
- name: Run docker-compose
run: docker-compose up -d
- name: Basic wait
run: sleep 120
- name: List running containers
run: docker ps
- name: Log last 10 lines from all containers
run: docker ps -q | xargs -I {} docker logs --tail 100 {}
- name: Log RAG api
run: docker logs kakawa_rag_api --tail 300
- name: Test Online LangFuse API endpoint
run: |
response=$(docker exec langfuse wget --header='accept: application/json' -qO - "${{ secrets.LANGFUSE_HOST }}/api/public/health")
if echo "$response" | grep OK; then
echo "Health check OK"
else
echo "Health check failed"
exit 1
fi
- name: Execute RAG API query
run: |
commit_hash=$(git rev-parse --short HEAD)
echo "Commit Hash: $commit_hash"
success=false
for i in {1..5}; do
echo "Attempt $i:"
response=$(docker exec kakawa_rag_api python -c "import requests; try: response = requests.get('http:https://kakawa_rag_api:8000/rag?query=How%20to%20install%20Mapeo&user_id=github_action&session_id=$commit_hash', headers={'accept': 'application/json'}); print(response.status_code) except requests.exceptions.RequestException as e: print(e)")
if echo "$response" | grep -q "200"; then
echo "RAG API endpoint is up and running."
success=true
break
elif echo "$response" | grep -q "ConnectionError"; then
echo "Connection error occurred. Retrying in 20 seconds..."
sleep 20
else
echo "Attempt $i failed with status code $response. Retrying in 20 seconds..."
sleep 20
fi
done
if [ "$success" = false ]; then
echo "RAG API endpoint check failed after 5 attempts."
exit 1
fi