Skip to content

Commit 020984e

Browse files
committed
adding the test running part
1 parent 8f51022 commit 020984e

File tree

4 files changed

+208
-37
lines changed

4 files changed

+208
-37
lines changed

.github/workflows/agentex-tutorials-test.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13+
- name: Checkout agentex-python repo
14+
uses: actions/checkout@v4
15+
1316
- name: Install UV
1417
run: |
1518
curl -LsSf https://astral.sh/uv/install.sh | sh
@@ -43,3 +46,106 @@ jobs:
4346
4447
# Verify all deps are up
4548
docker compose ps
49+
50+
- name: Run Parallel Tutorial Tests
51+
working-directory: ./examples/tutorials
52+
run: |
53+
54+
# Find all tutorial directories
55+
tutorial_paths=()
56+
for dir in $(find . -name "manifest.yaml" -exec dirname {} \; | sort); do
57+
tutorial_paths+=("${dir#./}") # Remove leading ./
58+
done
59+
60+
echo "Found ${#tutorial_paths[@]} tutorials:"
61+
printf ' %s\n' "${tutorial_paths[@]}"
62+
63+
# Run tests in parallel with unique ports
64+
pids=()
65+
failed_tests=()
66+
passed_tests=()
67+
68+
for i in "${!tutorial_paths[@]}"; do
69+
tutorial="${tutorial_paths[$i]}"
70+
port=$((8000 + i))
71+
72+
echo ""
73+
echo "========================================="
74+
echo "Starting test $((i+1))/${#tutorial_paths[@]}: $tutorial (port $port)"
75+
echo "========================================="
76+
77+
# Modify manifest.yaml to use unique port
78+
manifest_path="$tutorial/manifest.yaml"
79+
if [ -f "$manifest_path" ]; then
80+
# Backup original manifest
81+
cp "$manifest_path" "$manifest_path.backup"
82+
83+
# Update port in manifest (modify the line containing 'port: 8000' or 'port: XXXX')
84+
sed -i "s/port: [0-9]*/port: $port/" "$manifest_path"
85+
86+
echo "Updated $manifest_path to use port $port"
87+
fi
88+
89+
# Run test in background with unique port
90+
(
91+
AGENTEX_API_BASE_URL="http://localhost:5003" \
92+
./run_agent_test.sh --build-cli "$tutorial"
93+
94+
if [ $? -eq 0 ]; then
95+
echo "✅ PASSED: $tutorial (port $port)"
96+
echo "$tutorial" > "/tmp/passed_$i.txt"
97+
else
98+
echo "❌ FAILED: $tutorial (port $port)"
99+
echo "$tutorial" > "/tmp/failed_$i.txt"
100+
fi
101+
) &
102+
103+
pids+=($!)
104+
done
105+
106+
# Wait for all tests to complete
107+
echo ""
108+
echo "Waiting for all tests to complete..."
109+
for pid in "${pids[@]}"; do
110+
wait "$pid"
111+
done
112+
113+
# Restore all original manifests
114+
echo ""
115+
echo "Restoring original manifest files..."
116+
for tutorial in "${tutorial_paths[@]}"; do
117+
if [ -f "$tutorial/manifest.yaml.backup" ]; then
118+
mv "$tutorial/manifest.yaml.backup" "$tutorial/manifest.yaml"
119+
echo "Restored $tutorial/manifest.yaml"
120+
fi
121+
done
122+
123+
# Collect results
124+
for i in "${!tutorial_paths[@]}"; do
125+
if [ -f "/tmp/passed_$i.txt" ]; then
126+
passed_tests+=($(cat "/tmp/passed_$i.txt"))
127+
elif [ -f "/tmp/failed_$i.txt" ]; then
128+
failed_tests+=($(cat "/tmp/failed_$i.txt"))
129+
fi
130+
done
131+
132+
# Print summary
133+
echo ""
134+
echo "========================================="
135+
echo "TEST SUMMARY"
136+
echo "========================================="
137+
echo "Total: ${#tutorial_paths[@]}"
138+
echo "Passed: ${#passed_tests[@]}"
139+
echo "Failed: ${#failed_tests[@]}"
140+
141+
if [ ${#failed_tests[@]} -gt 0 ]; then
142+
echo ""
143+
echo "Failed tests:"
144+
for test in "${failed_tests[@]}"; do
145+
echo " ❌ $test"
146+
done
147+
exit 1
148+
else
149+
echo ""
150+
echo "🎉 All tests passed!"
151+
fi

examples/tutorials/run_agent_test.sh

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#
88
# Usage:
99
# ./run_agent_test.sh <tutorial_path> # Run single tutorial test
10+
# ./run_agent_test.sh --build-cli <tutorial_path> # Build CLI from source and run test
1011
# ./run_agent_test.sh --view-logs <tutorial_path> # View logs for specific tutorial
1112
# ./run_agent_test.sh --view-logs # View most recent agent logs
1213
#
@@ -28,10 +29,13 @@ AGENTEX_SERVER_PORT=5003
2829
# Parse arguments
2930
TUTORIAL_PATH=""
3031
VIEW_LOGS=false
32+
BUILD_CLI=false
3133

3234
for arg in "$@"; do
3335
if [[ "$arg" == "--view-logs" ]]; then
3436
VIEW_LOGS=true
37+
elif [[ "$arg" == "--build-cli" ]]; then
38+
BUILD_CLI=true
3539
else
3640
TUTORIAL_PATH="$arg"
3741
fi
@@ -105,7 +109,8 @@ start_agent() {
105109
cd "$tutorial_path" || return 1
106110

107111
# Start the agent in background and capture PID
108-
uv run agentex agents run --manifest manifest.yaml > "$logfile" 2>&1 &
112+
local agentex_cmd=$(get_agentex_command)
113+
$agentex_cmd agents run --manifest manifest.yaml > "$logfile" 2>&1 &
109114
local pid=$!
110115

111116
# Return to original directory
@@ -275,6 +280,58 @@ execute_tutorial_test() {
275280
fi
276281
}
277282

283+
# Function to build CLI from source
284+
build_cli() {
285+
echo -e "${YELLOW}🔨 Building CLI from source...${NC}"
286+
287+
# Navigate to the repo root (two levels up from examples/tutorials)
288+
local repo_root="../../"
289+
local original_dir="$PWD"
290+
291+
cd "$repo_root" || {
292+
echo -e "${RED}❌ Failed to navigate to repo root${NC}"
293+
return 1
294+
}
295+
296+
# Check if rye is available
297+
if ! command -v rye &> /dev/null; then
298+
echo -e "${RED}❌ rye is required to build the CLI${NC}"
299+
echo "Please install rye: curl -sSf https://rye.astral.sh/get | bash"
300+
cd "$original_dir"
301+
return 1
302+
fi
303+
304+
# Build the CLI
305+
echo -e "${YELLOW}Running rye sync --all-features...${NC}"
306+
if ! rye sync --all-features; then
307+
echo -e "${RED}❌ Failed to sync dependencies${NC}"
308+
cd "$original_dir"
309+
return 1
310+
fi
311+
312+
echo -e "${YELLOW}Running rye build...${NC}"
313+
if ! rye build; then
314+
echo -e "${RED}❌ Failed to build package${NC}"
315+
cd "$original_dir"
316+
return 1
317+
fi
318+
319+
echo -e "${GREEN}✅ CLI built successfully${NC}"
320+
cd "$original_dir"
321+
return 0
322+
}
323+
324+
# Function to get the appropriate agentex command
325+
get_agentex_command() {
326+
if [ "$BUILD_CLI" = true ]; then
327+
# Use the local build via rye run from repo root
328+
echo "../../rye run agentex"
329+
else
330+
# Use the system-installed version
331+
echo "uv run agentex"
332+
fi
333+
}
334+
278335
# Main execution function
279336
main() {
280337
# Handle --view-logs flag
@@ -293,11 +350,13 @@ main() {
293350
echo ""
294351
echo "Usage:"
295352
echo " ./run_agent_test.sh <tutorial_path> # Run single tutorial test"
353+
echo " ./run_agent_test.sh --build-cli <tutorial_path> # Build CLI from source and run test"
296354
echo " ./run_agent_test.sh --view-logs <tutorial_path> # View logs for specific tutorial"
297355
echo " ./run_agent_test.sh --view-logs # View most recent agent logs"
298356
echo ""
299-
echo "Example:"
357+
echo "Examples:"
300358
echo " ./run_agent_test.sh 00_sync/000_hello_acp"
359+
echo " ./run_agent_test.sh --build-cli 00_sync/000_hello_acp"
301360
exit 1
302361
fi
303362

@@ -311,6 +370,15 @@ main() {
311370

312371
echo ""
313372

373+
# Build CLI if requested
374+
if [ "$BUILD_CLI" = true ]; then
375+
if ! build_cli; then
376+
echo -e "${RED}❌ Failed to build CLI from source${NC}"
377+
exit 1
378+
fi
379+
echo ""
380+
fi
381+
314382
# Execute the single tutorial test
315383
if execute_tutorial_test "$TUTORIAL_PATH"; then
316384
echo ""

requirements-dev.lock

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ httpx==0.27.2
113113
# via mcp
114114
# via openai
115115
# via respx
116-
httpx-aiohttp==0.1.9
117116
# via scale-gp
118117
# via scale-gp-beta
118+
httpx-aiohttp==0.1.9
119119
# via agentex-sdk
120120
httpx-sse==0.4.1
121121
# via mcp
@@ -219,20 +219,6 @@ prompt-toolkit==3.0.51
219219
propcache==0.3.1
220220
# via aiohttp
221221
# via yarl
222-
pydantic==2.11.9
223-
# via agentex-sdk
224-
# via agentex-sdk
225-
# via fastapi
226-
# via litellm
227-
# via mcp
228-
# via openai
229-
# via openai-agents
230-
# via pydantic-settings
231-
# via python-on-whales
232-
# via scale-gp
233-
# via scale-gp-beta
234-
pydantic-core==2.33.2
235-
# via pydantic
236222
protobuf==5.29.5
237223
# via ddtrace
238224
# via temporalio
@@ -247,6 +233,19 @@ pyasn1==0.6.1
247233
# via rsa
248234
pyasn1-modules==0.4.2
249235
# via google-auth
236+
pydantic==2.11.9
237+
# via agentex-sdk
238+
# via fastapi
239+
# via litellm
240+
# via mcp
241+
# via openai
242+
# via openai-agents
243+
# via pydantic-settings
244+
# via python-on-whales
245+
# via scale-gp
246+
# via scale-gp-beta
247+
pydantic-core==2.33.2
248+
# via pydantic
250249
pydantic-settings==2.10.1
251250
# via mcp
252251
pygments==2.18.0
@@ -383,16 +382,15 @@ typing-extensions==4.12.2
383382
# via pydantic
384383
# via pydantic-core
385384
# via pyright
386-
# via typing-inspection
387-
typing-inspection==0.4.1
388-
# via pydantic
389385
# via python-on-whales
390386
# via referencing
391387
# via scale-gp
392388
# via scale-gp-beta
393389
# via temporalio
394390
# via typer
395391
# via typing-inspection
392+
typing-inspection==0.4.1
393+
# via pydantic
396394
# via pydantic-settings
397395
tzdata==2025.2
398396
# via agentex-sdk

requirements.lock

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ httpcore==1.0.9
9999
httpx==0.27.2
100100
# via agentex-sdk
101101
# via httpx-aiohttp
102-
httpx-aiohttp==0.1.9
103102
# via litellm
104103
# via mcp
105104
# via openai
106105
# via scale-gp
107106
# via scale-gp-beta
107+
httpx-aiohttp==0.1.9
108108
# via agentex-sdk
109109
httpx-sse==0.4.1
110110
# via mcp
@@ -200,19 +200,6 @@ prompt-toolkit==3.0.51
200200
propcache==0.3.1
201201
# via aiohttp
202202
# via yarl
203-
pydantic==2.11.9
204-
# via agentex-sdk
205-
# via fastapi
206-
# via litellm
207-
# via mcp
208-
# via openai
209-
# via openai-agents
210-
# via pydantic-settings
211-
# via python-on-whales
212-
# via scale-gp
213-
# via scale-gp-beta
214-
pydantic-core==2.33.2
215-
# via pydantic
216203
protobuf==5.29.5
217204
# via ddtrace
218205
# via temporalio
@@ -227,6 +214,19 @@ pyasn1==0.6.1
227214
# via rsa
228215
pyasn1-modules==0.4.2
229216
# via google-auth
217+
pydantic==2.11.9
218+
# via agentex-sdk
219+
# via fastapi
220+
# via litellm
221+
# via mcp
222+
# via openai
223+
# via openai-agents
224+
# via pydantic-settings
225+
# via python-on-whales
226+
# via scale-gp
227+
# via scale-gp-beta
228+
pydantic-core==2.33.2
229+
# via pydantic
230230
pydantic-settings==2.10.1
231231
# via mcp
232232
pygments==2.19.2
@@ -351,16 +351,15 @@ typing-extensions==4.12.2
351351
# via opentelemetry-api
352352
# via pydantic
353353
# via pydantic-core
354-
# via typing-inspection
355-
typing-inspection==0.4.1
356-
# via pydantic
357354
# via python-on-whales
358355
# via referencing
359356
# via scale-gp
360357
# via scale-gp-beta
361358
# via temporalio
362359
# via typer
363360
# via typing-inspection
361+
typing-inspection==0.4.1
362+
# via pydantic
364363
# via pydantic-settings
365364
tzdata==2025.2
366365
# via agentex-sdk

0 commit comments

Comments
 (0)