Skip to content

Commit 54996c2

Browse files
committed
adding the test running part
1 parent 8f51022 commit 54996c2

File tree

4 files changed

+216
-37
lines changed

4 files changed

+216
-37
lines changed

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

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,22 @@ 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
1619
echo "$HOME/.local/bin" >> $GITHUB_PATH
1720
21+
- name: Install Rye
22+
run: |
23+
curl -sSf https://rye.astral.sh/get | bash
24+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
25+
env:
26+
RYE_VERSION: "0.44.0"
27+
RYE_INSTALL_OPTION: "--yes"
28+
1829
- name: Checkout scale-agentex repo
1930
uses: actions/checkout@v4
2031
with:
@@ -43,3 +54,106 @@ jobs:
4354
4455
# Verify all deps are up
4556
docker compose ps
57+
58+
- name: Run Parallel Tutorial Tests
59+
working-directory: ./examples/tutorials
60+
run: |
61+
62+
# Find all tutorial directories
63+
tutorial_paths=()
64+
for dir in $(find . -name "manifest.yaml" -exec dirname {} \; | sort); do
65+
tutorial_paths+=("${dir#./}") # Remove leading ./
66+
done
67+
68+
echo "Found ${#tutorial_paths[@]} tutorials:"
69+
printf ' %s\n' "${tutorial_paths[@]}"
70+
71+
# Run tests in parallel with unique ports
72+
pids=()
73+
failed_tests=()
74+
passed_tests=()
75+
76+
for i in "${!tutorial_paths[@]}"; do
77+
tutorial="${tutorial_paths[$i]}"
78+
port=$((8000 + i))
79+
80+
echo ""
81+
echo "========================================="
82+
echo "Starting test $((i+1))/${#tutorial_paths[@]}: $tutorial (port $port)"
83+
echo "========================================="
84+
85+
# Modify manifest.yaml to use unique port
86+
manifest_path="$tutorial/manifest.yaml"
87+
if [ -f "$manifest_path" ]; then
88+
# Backup original manifest
89+
cp "$manifest_path" "$manifest_path.backup"
90+
91+
# Update port in manifest (modify the line containing 'port: 8000' or 'port: XXXX')
92+
sed -i "s/port: [0-9]*/port: $port/" "$manifest_path"
93+
94+
echo "Updated $manifest_path to use port $port"
95+
fi
96+
97+
# Run test in background with unique port
98+
(
99+
AGENTEX_API_BASE_URL="http://localhost:5003" \
100+
./run_agent_test.sh --build-cli "$tutorial"
101+
102+
if [ $? -eq 0 ]; then
103+
echo "✅ PASSED: $tutorial (port $port)"
104+
echo "$tutorial" > "/tmp/passed_$i.txt"
105+
else
106+
echo "❌ FAILED: $tutorial (port $port)"
107+
echo "$tutorial" > "/tmp/failed_$i.txt"
108+
fi
109+
) &
110+
111+
pids+=($!)
112+
done
113+
114+
# Wait for all tests to complete
115+
echo ""
116+
echo "Waiting for all tests to complete..."
117+
for pid in "${pids[@]}"; do
118+
wait "$pid"
119+
done
120+
121+
# Restore all original manifests
122+
echo ""
123+
echo "Restoring original manifest files..."
124+
for tutorial in "${tutorial_paths[@]}"; do
125+
if [ -f "$tutorial/manifest.yaml.backup" ]; then
126+
mv "$tutorial/manifest.yaml.backup" "$tutorial/manifest.yaml"
127+
echo "Restored $tutorial/manifest.yaml"
128+
fi
129+
done
130+
131+
# Collect results
132+
for i in "${!tutorial_paths[@]}"; do
133+
if [ -f "/tmp/passed_$i.txt" ]; then
134+
passed_tests+=($(cat "/tmp/passed_$i.txt"))
135+
elif [ -f "/tmp/failed_$i.txt" ]; then
136+
failed_tests+=($(cat "/tmp/failed_$i.txt"))
137+
fi
138+
done
139+
140+
# Print summary
141+
echo ""
142+
echo "========================================="
143+
echo "TEST SUMMARY"
144+
echo "========================================="
145+
echo "Total: ${#tutorial_paths[@]}"
146+
echo "Passed: ${#passed_tests[@]}"
147+
echo "Failed: ${#failed_tests[@]}"
148+
149+
if [ ${#failed_tests[@]} -gt 0 ]; then
150+
echo ""
151+
echo "Failed tests:"
152+
for test in "${failed_tests[@]}"; do
153+
echo " ❌ $test"
154+
done
155+
exit 1
156+
else
157+
echo ""
158+
echo "🎉 All tests passed!"
159+
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)