Skip to content

Commit fa9a25e

Browse files
committed
add tests for all agent images
1 parent 8093f04 commit fa9a25e

File tree

1 file changed

+104
-21
lines changed

1 file changed

+104
-21
lines changed

.github/workflows/integration-tests.yml

Lines changed: 104 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,64 @@ on:
1818
default: main
1919

2020
jobs:
21+
discover-agent-images:
22+
name: "Discover Tutorial Agent Images"
23+
runs-on: ubuntu-latest
24+
outputs:
25+
agent-matrix: ${{ steps.discover.outputs.agent-matrix }}
26+
steps:
27+
- name: Login to GitHub Container Registry
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.repository_owner }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Discover tutorial agent images
35+
id: discover
36+
run: |
37+
echo "🔍 Discovering tutorial agent images from GHCR..."
38+
39+
# Get all packages for the scale-agentex-python organization
40+
echo "Fetching packages from scale-agentex-python repository..."
41+
PACKAGES=$(curl -s \
42+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
43+
-H "Accept: application/vnd.github.v3+json" \
44+
"https://api.github.com/orgs/scaleapi/packages?package_type=container&per_page=100" \
45+
| jq -r '.[] | select(.name | startswith("scale-agentex-python/tutorial-agents/")) | .name')
46+
47+
echo "📋 Found packages:"
48+
echo "$PACKAGES"
49+
50+
# For now, start with known working agents and add more as we verify they work
51+
# TODO: Expand this list as we verify more agents work with the test framework
52+
AGENT_IMAGES='[
53+
{
54+
"name": "00_sync-000_hello_acp",
55+
"image": "ghcr.io/scaleapi/scale-agentex-python/tutorial-agents/00_sync-000_hello_acp:latest",
56+
"agent_name": "s000-hello-acp"
57+
}
58+
]'
59+
60+
# Future enhancement: Dynamically discover all tutorial agents
61+
# This would require parsing the package names and generating appropriate agent_name values
62+
# Example format: scale-agentex-python/tutorial-agents/01_async-001_weather_sync
63+
# Would become: agent_name = "s001-weather-sync"
64+
65+
echo "📋 Testing with tutorial agent images:"
66+
echo "$AGENT_IMAGES" | jq '.'
67+
68+
# Convert to compact JSON for matrix
69+
echo "agent-matrix=$(echo "$AGENT_IMAGES" | jq -c '.')" >> $GITHUB_OUTPUT
70+
2171
run-integration-tests:
22-
name: "Run Integration Tests - s000-hello-acp"
72+
name: "Run Integration Tests - ${{ matrix.agent.name }}"
2373
runs-on: ubuntu-latest
74+
needs: discover-agent-images
75+
strategy:
76+
fail-fast: false # Continue testing other agents even if one fails
77+
matrix:
78+
agent: ${{ fromJson(needs.discover-agent-images.outputs.agent-matrix) }}
2479
steps:
2580
- name: Checkout
2681
uses: actions/checkout@v4
@@ -36,8 +91,8 @@ jobs:
3691

3792
- name: Pull agent image
3893
run: |
39-
echo "🐳 Pulling agent image..."
40-
docker pull ghcr.io/scaleapi/scale-agentex-python/tutorial-agents/00_sync-000_hello_acp:latest
94+
echo "🐳 Pulling agent image: ${{ matrix.agent.image }}"
95+
docker pull ${{ matrix.agent.image }}
4196
echo "✅ Agent image pulled successfully"
4297
4398
- name: Start AgentEx services with host access
@@ -88,21 +143,25 @@ jobs:
88143
89144
- name: Run agent integration test
90145
run: |
91-
echo "🧪 Running integration test for agent: s000-hello-acp"
92-
echo "🐳 Using image: ghcr.io/scaleapi/scale-agentex-python/tutorial-agents/00_sync-000_hello_acp:latest"
146+
# Set variables for this agent
147+
AGENT_NAME="${{ matrix.agent.agent_name }}"
148+
AGENT_IMAGE="${{ matrix.agent.image }}"
149+
CONTAINER_NAME="agent-test-${AGENT_NAME}"
93150
94-
# Start the agent container
151+
echo "🧪 Running integration test for agent: ${AGENT_NAME}"
152+
echo "🐳 Using image: ${AGENT_IMAGE}"
95153
96-
docker run -d --name agent-test-s000-hello-acp \
97-
-e AGENT_NAME=s000-hello-acp \
98-
-e ACP_URL=http://agent-test-s000-hello-acp \
154+
# Start the agent container
155+
docker run -d --name "${CONTAINER_NAME}" \
156+
-e AGENT_NAME="${AGENT_NAME}" \
157+
-e ACP_URL="http://${CONTAINER_NAME}" \
99158
-e ACP_PORT=8000 \
100159
-e ACP_TYPE=sync \
101160
-e AGENTEX_BASE_URL=http://agentex:5003 \
102161
-e AGENTEX_API_BASE_URL=http://agentex:5003 \
103162
-p 8000:8000 \
104163
--network agentex-network \
105-
ghcr.io/scaleapi/scale-agentex-python/tutorial-agents/00_sync-000_hello_acp:latest
164+
"${AGENT_IMAGE}"
106165
107166
echo "⏳ Waiting for agent to start..."
108167
sleep 10
@@ -113,7 +172,7 @@ jobs:
113172
ELAPSED=0
114173
115174
while [ $ELAPSED -lt $TIMEOUT ]; do
116-
if docker logs agent-test-s000-hello-acp 2>&1 | grep -q "Application startup complete"; then
175+
if docker logs "${CONTAINER_NAME}" 2>&1 | grep -q "Application startup complete"; then
117176
echo "✅ Agent application has started successfully"
118177
break
119178
fi
@@ -126,7 +185,7 @@ jobs:
126185
if [ $ELAPSED -ge $TIMEOUT ]; then
127186
echo "❌ Timeout waiting for 'Application startup complete' message"
128187
echo "📋 Container logs:"
129-
docker logs agent-test-s000-hello-acp
188+
docker logs "${CONTAINER_NAME}"
130189
exit 1
131190
fi
132191
@@ -136,7 +195,7 @@ jobs:
136195
137196
while [ $REGISTRATION_ELAPSED -lt $REGISTRATION_TIMEOUT ]; do
138197
AGENT_DATA=$(curl -s http://localhost:5003/api/agents)
139-
if echo "$AGENT_DATA" | grep -q "s000-hello-acp"; then
198+
if echo "$AGENT_DATA" | grep -q "${AGENT_NAME}"; then
140199
echo "✅ Agent successfully registered with AgentEx"
141200
142201
# Verify the ACP URL doesn't have double port
@@ -163,13 +222,13 @@ jobs:
163222
164223
# Test connectivity before running main tests
165224
echo "🔍 Testing connectivity to agent..."
166-
if ! docker exec agent-test-s000-hello-acp curl -s http://localhost:8000/health > /dev/null 2>&1; then
225+
if ! docker exec "${CONTAINER_NAME}" curl -s http://localhost:8000/health > /dev/null 2>&1; then
167226
echo "⚠️ Agent health endpoint not responding, checking if agent is listening..."
168-
docker exec agent-test-s000-hello-acp netstat -tlnp 2>/dev/null || echo "netstat not available"
227+
docker exec "${CONTAINER_NAME}" netstat -tlnp 2>/dev/null || echo "netstat not available"
169228
fi
170229
171230
echo "🔍 Testing connectivity to AgentEx from agent container..."
172-
if ! docker exec agent-test-s000-hello-acp curl -s http://agentex:5003/health > /dev/null 2>&1; then
231+
if ! docker exec "${CONTAINER_NAME}" curl -s http://agentex:5003/health > /dev/null 2>&1; then
173232
echo "❌ Cannot reach AgentEx from agent container"
174233
echo "📋 AgentEx service logs:"
175234
cd agentex && docker compose logs --tail=50 agentex
@@ -180,7 +239,7 @@ jobs:
180239
181240
# Show pre-test logs
182241
echo "📋 Agent logs before testing:"
183-
docker logs --tail=20 agent-test-s000-hello-acp
242+
docker logs --tail=20 "${CONTAINER_NAME}"
184243
185244
echo "📋 AgentEx logs before testing:"
186245
cd agentex && docker compose logs --tail=20 agentex
@@ -189,15 +248,15 @@ jobs:
189248
# Run the test inside the container with explicit exit code handling
190249
echo "🧪 Running tests inside the agent container..."
191250
set +e # Don't exit on error immediately
192-
docker exec agent-test-s000-hello-acp pytest tests/test_agent.py -v
251+
docker exec "${CONTAINER_NAME}" pytest tests/test_agent.py -v
193252
TEST_EXIT_CODE=$?
194253
set -e # Re-enable exit on error
195254
196255
echo "🔍 Test exit code: $TEST_EXIT_CODE"
197256
198257
# Show post-test logs regardless of outcome
199258
echo "📋 Agent logs after testing:"
200-
docker logs --tail=50 agent-test-s000-hello-acp
259+
docker logs --tail=50 "${CONTAINER_NAME}"
201260
202261
echo "📋 AgentEx logs after testing:"
203262
cd agentex && docker compose logs --tail=50 agentex
@@ -208,12 +267,36 @@ jobs:
208267
else
209268
echo "❌ Tests failed with exit code $TEST_EXIT_CODE"
210269
echo "📋 Full agent logs:"
211-
docker logs agent-test-s000-hello-acp
270+
docker logs "${CONTAINER_NAME}"
212271
echo "📋 Full AgentEx logs:"
213272
cd agentex && docker compose logs agentex
214273
cd ..
215274
exit 1
216275
fi
217276
218277
echo "🧹 Cleaning up container..."
219-
docker rm -f agent-test-s000-hello-acp
278+
docker rm -f "${CONTAINER_NAME}"
279+
280+
# Summary job to ensure the workflow fails if any test fails
281+
integration-tests-summary:
282+
name: "Integration Tests Summary"
283+
runs-on: ubuntu-latest
284+
needs: [discover-agent-images, run-integration-tests]
285+
if: always() # Run even if some tests fail
286+
steps:
287+
- name: Check test results
288+
run: |
289+
echo "🔍 Checking integration test results..."
290+
291+
# Check if the matrix job had any failures
292+
if [ "${{ needs.run-integration-tests.result }}" != "success" ]; then
293+
echo "❌ One or more integration tests failed"
294+
echo "Matrix job result: ${{ needs.run-integration-tests.result }}"
295+
exit 1
296+
else
297+
echo "✅ All integration tests passed successfully"
298+
fi
299+
300+
- name: Final status
301+
run: |
302+
echo "🎉 All tutorial agent integration tests completed successfully!"

0 commit comments

Comments
 (0)