Skip to content

Commit c61ab37

Browse files
authored
Merge pull request #209 from esnible/dependency-check-target
Feat: Introduce targets to verify A2A and MCP servers start.
2 parents 8c41e7b + 337aeef commit c61ab37

44 files changed

Lines changed: 421 additions & 11 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,19 @@ jobs:
3737
run: pip install pytest pydantic pydantic-settings httpx python-dotenv
3838
- name: Run tests
3939
run: python -m pytest -v
40+
41+
# Make sure all of the examples start up successfully by running their `test_startup.exp` scripts, which use `expect` to verify the agent starts and responds to a simple input.
42+
test-startup:
43+
runs-on: ubuntu-latest
44+
timeout-minutes: 15
45+
steps:
46+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
47+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
48+
with:
49+
python-version: "3.12"
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@c7f87aa956e4c323abf06d5dec078e358f6b4d04 # v6
52+
- name: Install expect
53+
run: sudo apt-get update && sudo apt-get install -y expect
54+
- name: Verify agents start
55+
run: make test-startup-all

Makefile

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
.PHONY: lint fmt test-docker test-a2a test-mcp sync-all-uv sync-a2a sync-mcp
1+
SHELL := /bin/bash
2+
3+
.PHONY: lint fmt test-docker test-a2a test-mcp sync-all-uv sync-a2a sync-mcp test-startup-all test-startup-a2a test-startup-mcp
24

35
lint:
46
pre-commit run --all-files
@@ -48,3 +50,26 @@ sync-mcp:
4850
uv sync --no-dev || exit; \
4951
popd; \
5052
done
53+
54+
test-startup-all: test-startup-a2a test-startup-mcp
55+
56+
# Run the test_startup.exp script for each A2A example that has one to verify it starts successfully.
57+
test-startup-a2a:
58+
@for f in $(shell find a2a -mindepth 1 -maxdepth 1 -type d); do \
59+
pushd $${f} || exit; \
60+
if [ -f test_startup.exp ]; then \
61+
echo "Testing startup for $${f}..."; \
62+
expect -f test_startup.exp || exit; \
63+
fi; \
64+
popd; \
65+
done
66+
67+
test-startup-mcp:
68+
@for f in $(shell find mcp -mindepth 1 -maxdepth 1 -type d); do \
69+
pushd $${f} || exit; \
70+
if [ -f test_startup.exp ]; then \
71+
echo "Testing startup for $${f}..."; \
72+
expect -f test_startup.exp || exit; \
73+
fi; \
74+
popd; \
75+
done
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
.venv
1+
.venv
2+
3+
# `expect` scripts
4+
test_startup.exp
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This script tests if the server has dependencies and reaches the point of starting its server.
2+
3+
# Run with `expect -f test_startup.exp`
4+
5+
set timeout 120
6+
7+
# This is similar the Dockerfile CMD
8+
spawn env HOST=localhost PORT=8001 uv run --locked . --host localhost --port 8001
9+
10+
expect {
11+
"Uvicorn running on" { puts "Success"; exit 0 }
12+
timeout { puts "Timed out waiting for startup"; exit 1 }
13+
eof { puts "Process exited early"; exit 2 }
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
.venv
22
deployment
3+
4+
# `expect` scripts
5+
test_startup.exp
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This script tests if the server has dependencies and reaches the point of starting its server.
2+
3+
# Run with `expect -f test_startup.exp`
4+
5+
set timeout 120
6+
7+
# This is similar the Dockerfile CMD
8+
spawn env HOST=localhost PORT=8001 uv run --locked app --host localhost --port 8001
9+
10+
expect {
11+
"Uvicorn running on" { puts "Success"; exit 0 }
12+
timeout { puts "Timed out waiting for startup"; exit 1 }
13+
eof { puts "Process exited early"; exit 2 }
14+
}

a2a/cheerup_agent/.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ __pycache__
22
*.pyc
33
.venv
44
.git
5+
6+
# `expect` scripts
7+
test_startup.exp

a2a/cheerup_agent/test_startup.exp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This script tests if the server has dependencies and reaches the point of starting its server.
2+
3+
# Run with `expect -f test_startup.exp`
4+
5+
set timeout 120
6+
7+
# This is similar the Dockerfile CMD
8+
spawn env HOST=localhost PORT=8001 uv run --locked server --host localhost --port 8001
9+
10+
expect {
11+
"Uvicorn running on" { puts "Success"; exit 0 }
12+
timeout { puts "Timed out waiting for startup"; exit 1 }
13+
eof { puts "Process exited early"; exit 2 }
14+
}

a2a/file_organizer/.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
.venv
1+
.venv
2+
3+
# `expect` scripts
4+
test_startup.exp
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This script tests if the server has dependencies and reaches the point of starting its server.
2+
3+
# Run with `expect -f test_startup.exp`
4+
5+
set timeout 120
6+
7+
# This is similar the Dockerfile CMD
8+
spawn env HOST=localhost PORT=8001 uv run --locked server --host localhost --port 8001
9+
10+
expect {
11+
"Uvicorn running on" { puts "Success"; exit 0 }
12+
timeout { puts "Timed out waiting for startup"; exit 1 }
13+
eof { puts "Process exited early"; exit 2 }
14+
}

0 commit comments

Comments
 (0)