Skip to content

Commit 323123d

Browse files
committed
Fix actions
Signed-off-by: Michael Yuan <[email protected]>
1 parent 76c477e commit 323123d

File tree

1 file changed

+3
-326
lines changed

1 file changed

+3
-326
lines changed

.github/workflows/test-mcp-server.yml

Lines changed: 3 additions & 326 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,12 @@ jobs:
122122
# Verify the response format has filename markers
123123
if ! echo "$RESPONSE" | grep -q "\[filename:"; then
124124
echo "Response does not contain filename markers:"
125-
echo "$RESPONSE"
125+
echo "$RESPONSE" | jq || echo "$RESPONSE"
126126
exit 1
127127
fi
128128
129129
echo "Compile and fix successful! Response contains code files in text format."
130+
echo "$RESPONSE" | jq || echo "$RESPONSE"
130131
fi
131132
132133
- name: Test /generate endpoint
@@ -265,6 +266,7 @@ jobs:
265266
266267
echo "Generate-sync successful! Response contains code files in text format."
267268
echo "status=success" >> $GITHUB_OUTPUT
269+
echo "$RESPONSE" | jq || echo "$RESPONSE"
268270
269271
- name: "Test workflow: /generate-sync → /compile"
270272
run: |
@@ -301,328 +303,3 @@ jobs:
301303
echo "Workflow test successful! Generated code compiles correctly."
302304
echo "$COMPILE_RESPONSE" | jq || echo "$COMPILE_RESPONSE"
303305

304-
- name: Test basic API endpoints (non-LLM)
305-
run: |
306-
# Test /compile endpoint with valid code first
307-
echo "Testing /compile endpoint..."
308-
COMPILE_RESPONSE=$(curl -s -S -f -X POST http://localhost:8000/compile \
309-
-H "Content-Type: application/json" \
310-
-d '{
311-
"code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\");\n}"
312-
}' || echo "CURL_FAILED")
313-
314-
if [ "$COMPILE_RESPONSE" = "CURL_FAILED" ] || ! echo "$COMPILE_RESPONSE" | jq -e '.success == true' > /dev/null; then
315-
echo "Basic compilation failed - API endpoints are not working properly"
316-
exit 1
317-
fi
318-
319-
echo "Basic API endpoints are working correctly"
320-
321-
- name: Check LLM API connectivity
322-
id: check-llm
323-
continue-on-error: true
324-
run: |
325-
# Test LLM connectivity with a simple request
326-
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST http://localhost:8000/generate-sync \
327-
-H "Content-Type: application/json" \
328-
-d '{
329-
"description": "A simple hello world program",
330-
"requirements": "Print hello"
331-
}')
332-
333-
if [[ "$HTTP_CODE" == "500" ]]; then
334-
echo "LLM API key is invalid or service is unavailable"
335-
echo "llm_available=false" >> $GITHUB_OUTPUT
336-
else
337-
echo "LLM service is available"
338-
echo "llm_available=true" >> $GITHUB_OUTPUT
339-
fi
340-
341-
- name: Test LLM-dependent endpoints
342-
if: steps.check-llm.outputs.llm_available == 'true'
343-
run: |
344-
echo "LLM service is available, testing all endpoints..."
345-
# Continue with the rest of the tests for /generate-sync, etc.
346-
347-
- name: Skip LLM-dependent tests
348-
if: steps.check-llm.outputs.llm_available != 'true'
349-
run: |
350-
echo "NOTICE: Skipping LLM-dependent tests due to invalid API key or unavailable service"
351-
echo "The following endpoints were not tested: /generate-sync, parts of /generate"
352-
echo "Basic endpoints like /compile and /compile-and-fix are working correctly"
353-
354-
- name: Check Docker logs on failure
355-
if: failure()
356-
run: |
357-
echo "Checking Docker logs for troubleshooting..."
358-
docker compose logs || echo "Failed to get logs"
359-
360-
# test-with-external-llm:
361-
# runs-on: ubuntu-latest
362-
# needs: test # Run after the local tests complete
363-
364-
# env:
365-
# LLM_API_BASE: "https://0x9fcf7888963793472bfcb8c14f4b6b47a7462f17.gaia.domains/v1"
366-
# LLM_MODEL: "Qwen2.5-Coder-3B-Instruct"
367-
# LLM_EMBED_MODEL: "gte-Qwen2-1.5B-instruct"
368-
# LLM_EMBED_SIZE: "1536"
369-
# LLM_API_KEY: "" # No API key needed for this public node
370-
# SKIP_VECTOR_SEARCH: "true"
371-
372-
# services:
373-
# qdrant:
374-
# image: qdrant/qdrant:latest
375-
# ports:
376-
# - 6333:6333
377-
# - 6334:6334
378-
379-
# steps:
380-
# - name: Checkout code
381-
# uses: actions/[email protected]
382-
383-
# - name: Install Python and dependencies
384-
# uses: actions/setup-python@v4
385-
# with:
386-
# python-version: '3.10'
387-
388-
# # Add Rust setup - this was missing
389-
# - name: Set up Rust
390-
# uses: actions-rs/toolchain@v1
391-
# with:
392-
# toolchain: stable
393-
# profile: minimal
394-
395-
# - name: Install jq and curl
396-
# run: sudo apt-get install -y jq curl
397-
398-
# - name: Install Python dependencies
399-
# run: pip install -r requirements.txt
400-
401-
# - name: Create test directories
402-
# run: |
403-
# mkdir -p output
404-
# mkdir -p data/project_examples
405-
# mkdir -p data/error_examples
406-
407-
# - name: Start API server with external LLM
408-
# run: |
409-
# echo "Starting API server with external Gaia node..."
410-
# # Set USE_MOCK_LLM=true in environment for this command
411-
# export USE_MOCK_LLM=true
412-
413-
# # Add a dummy API key for the public node to bypass validation
414-
# export LLM_API_KEY="dummy_key_for_public_node"
415-
416-
# # Add debug output to see what's being used
417-
# echo "LLM_API_BASE: $LLM_API_BASE"
418-
# echo "USE_MOCK_LLM: $USE_MOCK_LLM"
419-
# echo "LLM_API_KEY is set to a dummy value for the public node"
420-
421-
# # Redirect output to log file for debugging
422-
# python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 > server.log 2>&1 &
423-
# SERVER_PID=$!
424-
# echo "Server started with PID: $SERVER_PID"
425-
# sleep 10 # Give the server time to start
426-
427-
# # Check if server process is still running
428-
# if ps -p $SERVER_PID > /dev/null; then
429-
# echo "Server process is running"
430-
# else
431-
# echo "Server process died. Check server logs:"
432-
# cat server.log
433-
# exit 1
434-
# fi
435-
436-
# - name: Verify API server is running
437-
# run: |
438-
# HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/docs || echo "CURL_FAILED")
439-
# if [[ "$HTTP_CODE" != "200" ]]; then
440-
# echo "API server is not running properly. Status code: $HTTP_CODE"
441-
# ps aux | grep uvicorn
442-
# echo "Server logs:"
443-
# cat server.log
444-
# exit 1
445-
# fi
446-
# echo "API server is running correctly"
447-
448-
# - name: Test /compile endpoint with external LLM
449-
# run: |
450-
# echo "Testing /compile endpoint..."
451-
# RESPONSE=$(curl -s -S -f -X POST http://localhost:8000/compile \
452-
# -H "Content-Type: application/json" \
453-
# -d '{
454-
# "code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\");\n}"
455-
# }' || echo "CURL_FAILED")
456-
457-
# if [ "$RESPONSE" = "CURL_FAILED" ]; then
458-
# echo "Failed to connect to API service"
459-
# exit 1
460-
# fi
461-
462-
# # Check for success in response
463-
# if ! echo "$RESPONSE" | jq -e '.success == true' > /dev/null; then
464-
# echo "Compilation failed:"
465-
# echo "$RESPONSE" | jq || echo "$RESPONSE"
466-
# exit 1
467-
# fi
468-
469-
# echo "Compilation successful with external LLM!"
470-
# echo "$RESPONSE" | jq || echo "$RESPONSE"
471-
472-
# - name: Test /compile-and-fix endpoint with external LLM
473-
# run: |
474-
# echo "Testing /compile-and-fix endpoint..."
475-
# RESPONSE=$(curl -s -S -f -X POST http://localhost:8000/compile-and-fix \
476-
# -H "Content-Type: application/json" \
477-
# -d '{
478-
# "code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\\\" // Missing closing parenthesis\n}",
479-
# "description": "A simple hello world program",
480-
# "max_attempts": 3
481-
# }' || echo "CURL_FAILED")
482-
483-
# if [ "$RESPONSE" = "CURL_FAILED" ]; then
484-
# echo "Failed to connect to API service"
485-
# exit 1
486-
# fi
487-
488-
# # Save full response for debugging
489-
# echo "$RESPONSE" > compile_fix_response.txt
490-
491-
# # Check if response is JSON or text format
492-
# if [[ "$RESPONSE" == {* ]]; then
493-
# # JSON response (likely error)
494-
# echo "Got JSON response (may be expected with external LLM):"
495-
# echo "$RESPONSE" | jq || echo "$RESPONSE"
496-
# else
497-
# # Text response (success case)
498-
# echo "Compile and fix successful with external LLM! Got text response with fixed code."
499-
# fi
500-
501-
# - name: Test /generate-sync with external LLM
502-
# id: test-generate-sync-external
503-
# continue-on-error: true
504-
# run: |
505-
# echo "Testing /generate-sync endpoint with external LLM..."
506-
# RESPONSE=$(curl -X POST http://localhost:8000/generate-sync \
507-
# -H "Content-Type: application/json" \
508-
# -d '{"description": "A simple command-line calculator in Rust", "requirements": "Should support addition, subtraction, multiplication, and division"}')
509-
510-
# HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST http://localhost:8000/generate-sync \
511-
# -H "Content-Type: application/json" \
512-
# -d '{"description": "A simple command-line calculator in Rust", "requirements": "Should support addition, subtraction, multiplication, and division"}')
513-
514-
# echo "HTTP response code: $HTTP_CODE"
515-
516-
# if [[ "$HTTP_CODE" != "200" ]]; then
517-
# echo "External LLM generation failed with code $HTTP_CODE"
518-
# echo "Response: $RESPONSE"
519-
# echo "status=error" >> $GITHUB_OUTPUT
520-
# exit 1
521-
# fi
522-
523-
# # Save response to file for later use
524-
# echo "$RESPONSE" > external_generate_output.txt
525-
526-
# # Verify the response format has filename markers
527-
# if ! echo "$RESPONSE" | grep -q "\[filename:"; then
528-
# echo "Response does not contain filename markers:"
529-
# echo "$RESPONSE" | head -20
530-
# echo "status=error" >> $GITHUB_OUTPUT
531-
# exit 1
532-
# fi
533-
534-
# # Check if this is a fallback template
535-
# if echo "$RESPONSE" | grep -q "THIS IS A FALLBACK TEMPLATE - LLM generation failed"; then
536-
# echo "WARNING: Response contains fallback template - external LLM generation failed"
537-
# echo "status=fallback" >> $GITHUB_OUTPUT
538-
# else
539-
# echo "External LLM generate-sync successful! Response contains code files in text format."
540-
# echo "status=success" >> $GITHUB_OUTPUT
541-
# fi
542-
543-
# - name: "Test workflow with external LLM: /generate-sync → /compile"
544-
# if: steps.test-generate-sync-external.outcome == 'success'
545-
# run: |
546-
# echo "Testing workflow with external LLM: /generate-sync → /compile..."
547-
548-
# # Check if response contains fallback template
549-
# if grep -q "FALLBACK TEMPLATE" external_generate_output.txt; then
550-
# echo "WARNING: Testing with fallback template code - external LLM generation failed but continuing with tests"
551-
# fi
552-
553-
# # Get the output from the previous step and remove the build status comment
554-
# GENERATE_OUTPUT=$(cat external_generate_output.txt | sed '/^# Build/,$d')
555-
556-
# # Pass the cleaned generated code directly to compile
557-
# COMPILE_RESPONSE=$(curl -s -S -f -X POST http://localhost:8000/compile \
558-
# -H "Content-Type: application/json" \
559-
# -d "{
560-
# \"code\": $(echo "$GENERATE_OUTPUT" | jq -Rs .)
561-
# }" || echo "CURL_FAILED")
562-
563-
# if [ "$COMPILE_RESPONSE" = "CURL_FAILED" ]; then
564-
# echo "Failed to connect to API service"
565-
# exit 1
566-
# fi
567-
568-
# # Check for success in response
569-
# if ! echo "$COMPILE_RESPONSE" | jq -e '.success == true' > /dev/null; then
570-
# echo "Compilation failed:"
571-
# echo "$COMPILE_RESPONSE" | jq || echo "$COMPILE_RESPONSE"
572-
# exit 1
573-
# fi
574-
575-
# echo "External LLM workflow test successful! Generated code compiles correctly."
576-
# echo "$COMPILE_RESPONSE" | jq || echo "$COMPILE_RESPONSE"
577-
578-
# - name: Test /generate endpoint with external LLM
579-
# continue-on-error: true
580-
# run: |
581-
# echo "Testing /generate endpoint with external LLM..."
582-
583-
# # Generate the project
584-
# RESPONSE=$(curl -s -S -f -X POST http://localhost:8000/generate \
585-
# -H "Content-Type: application/json" \
586-
# -d '{
587-
# "description": "A Rust program that converts between different units of measurement",
588-
# "requirements": "Support length (m, cm, inch, feet), weight (kg, g, lb), and temperature (C, F, K)"
589-
# }' || echo "CURL_FAILED")
590-
591-
# if [ "$RESPONSE" = "CURL_FAILED" ]; then
592-
# echo "Failed to connect to API service"
593-
# exit 1
594-
# fi
595-
596-
# # Extract project_id from response
597-
# PROJECT_ID=$(echo "$RESPONSE" | jq -r '.project_id')
598-
# echo "Project ID: $PROJECT_ID"
599-
600-
# # Poll for project completion (maximum 6 attempts, 20 seconds apart)
601-
# echo "Polling for project completion..."
602-
# for i in {1..6}; do
603-
# echo "Checking project status (attempt $i)..."
604-
# STATUS_RESPONSE=$(curl -s -S -f "http://localhost:8000/project/$PROJECT_ID" || echo "CURL_FAILED")
605-
606-
# if [ "$STATUS_RESPONSE" = "CURL_FAILED" ]; then
607-
# echo "Failed to get project status"
608-
# continue
609-
# fi
610-
611-
# STATUS=$(echo "$STATUS_RESPONSE" | jq -r '.status')
612-
# echo "Current status: $STATUS"
613-
614-
# if [ "$STATUS" = "completed" ] || [ "$STATUS" = "failed" ]; then
615-
# echo "Project generation finished with status: $STATUS"
616-
# echo "$STATUS_RESPONSE" | jq
617-
# break
618-
# fi
619-
620-
# # If still processing, wait and try again
621-
# if [ $i -eq 6 ]; then
622-
# echo "Project generation taking too long, but this is acceptable for testing"
623-
# break
624-
# fi
625-
626-
# echo "Waiting 20 seconds before next check..."
627-
# sleep 20
628-
# done

0 commit comments

Comments
 (0)