Skip to content

Commit fde7150

Browse files
committed
Add tests for /generate-sync endpoint and workflow integration with /mcp/compile
1 parent 551d5e2 commit fde7150

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,75 @@ jobs:
214214
echo "Project download successful!"
215215
ls -la "project-$PROJECT_ID.zip"
216216
217+
- name: Test /generate-sync endpoint
218+
run: |
219+
echo "Testing /generate-sync endpoint..."
220+
RESPONSE=$(curl -s -S -f -X POST http://localhost:8000/generate-sync \
221+
-H "Content-Type: application/json" \
222+
-d '{
223+
"description": "A simple hello world program in Rust",
224+
"requirements": "Print a greeting message to the console"
225+
}' || echo "CURL_FAILED")
226+
227+
if [ "$RESPONSE" = "CURL_FAILED" ]; then
228+
echo "Failed to connect to API service"
229+
docker ps
230+
docker logs $(docker ps -q --filter name=api)
231+
exit 1
232+
fi
233+
234+
# Save response to file for later use
235+
echo "$RESPONSE" > generate_output.txt
236+
237+
# Verify the response format has filename markers
238+
if ! echo "$RESPONSE" | grep -q "\[filename:"; then
239+
echo "Response does not contain filename markers:"
240+
echo "$RESPONSE" | head -20
241+
exit 1
242+
fi
243+
244+
# Check if build succeeded
245+
if ! echo "$RESPONSE" | grep -q "# Build succeeded"; then
246+
echo "Build did not succeed:"
247+
echo "$RESPONSE" | tail -20
248+
exit 1
249+
fi
250+
251+
echo "Generate-sync successful! Response contains code files in text format."
252+
echo "First 20 lines of response:"
253+
echo "$RESPONSE" | head -20
254+
255+
- name: Test workflow: /generate-sync → /mcp/compile
256+
run: |
257+
echo "Testing workflow: /generate-sync → /mcp/compile..."
258+
259+
# Get the output from the previous step
260+
GENERATE_OUTPUT=$(cat generate_output.txt)
261+
262+
# Pass the generated code directly to compile
263+
COMPILE_RESPONSE=$(curl -s -S -f -X POST http://localhost:8000/mcp/compile \
264+
-H "Content-Type: application/json" \
265+
-d "{
266+
\"code\": $(echo "$GENERATE_OUTPUT" | jq -Rs .)
267+
}" || echo "CURL_FAILED")
268+
269+
if [ "$COMPILE_RESPONSE" = "CURL_FAILED" ]; then
270+
echo "Failed to connect to API service"
271+
docker ps
272+
docker logs $(docker ps -q --filter name=api)
273+
exit 1
274+
fi
275+
276+
# Check for success in response
277+
if ! echo "$COMPILE_RESPONSE" | jq -e '.success == true' > /dev/null; then
278+
echo "Compilation failed:"
279+
echo "$COMPILE_RESPONSE" | jq || echo "$COMPILE_RESPONSE"
280+
exit 1
281+
fi
282+
283+
echo "Workflow test successful! Generated code compiles correctly."
284+
echo "$COMPILE_RESPONSE" | jq || echo "$COMPILE_RESPONSE"
285+
217286
- name: Check Docker logs on failure
218287
if: failure()
219288
run: |

0 commit comments

Comments
 (0)