@@ -195,7 +195,74 @@ jobs:
195195 if [ "$SHOULD_PUSH" = "true" ]; then
196196 agentex agents build $BUILD_ARGS --push
197197 echo "✅ Successfully built and pushed: ${REGISTRY}/${REPOSITORY_NAME}:${VERSION_TAG}"
198+ # Set full image name for validation step
199+ echo "FULL_IMAGE=${REGISTRY}/${REPOSITORY_NAME}:${VERSION_TAG}" >> $GITHUB_ENV
198200 else
199201 agentex agents build $BUILD_ARGS
200202 echo "✅ Build validation successful for: ${{ matrix.agent_path }}"
203+ # Set full image name for validation step (local build)
204+ echo "FULL_IMAGE=${REGISTRY}/${REPOSITORY_NAME}:${VERSION_TAG}" >> $GITHUB_ENV
201205 fi
206+
207+ - name : Validate agent image
208+ run : |
209+ set -e
210+
211+ FULL_IMAGE="${{ env.FULL_IMAGE }}"
212+ AGENT_PATH="${{ matrix.agent_path }}"
213+
214+ echo "🔍 Validating agent image: $FULL_IMAGE"
215+
216+ # 1. Validate ACP entry point exists and is importable
217+ echo "📦 Checking ACP entry point..."
218+ docker run --rm "$FULL_IMAGE" python -c "from project.acp import acp; print('✅ ACP entry point validated')"
219+
220+ # 2. Check if tests/test_agent.py exists and run it
221+ echo "🧪 Checking for tests/test_agent.py..."
222+ if docker run --rm "$FULL_IMAGE" test -f /app/tests/test_agent.py; then
223+ echo "Found tests/test_agent.py - running tests..."
224+ docker run --rm "$FULL_IMAGE" python -m pytest /app/tests/test_agent.py -v --tb=short
225+ echo "✅ Agent tests passed"
226+ else
227+ echo "⚠️ No tests/test_agent.py found at /app/tests/test_agent.py - skipping test validation"
228+ echo " Consider adding tests/test_agent.py to validate agent functionality"
229+ fi
230+
231+ # 3. Health check - start container and verify /api endpoint responds
232+ echo "🏥 Running health check..."
233+ CONTAINER_NAME="validate-agent-$$"
234+
235+ # Start container in background
236+ docker run -d --name "$CONTAINER_NAME" -p 8000:8000 "$FULL_IMAGE"
237+
238+ # Wait for container to be ready (max 30 seconds)
239+ echo "Waiting for agent to start..."
240+ MAX_ATTEMPTS=30
241+ ATTEMPT=0
242+ HEALTH_OK=false
243+
244+ while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
245+ ATTEMPT=$((ATTEMPT + 1))
246+ if curl -sf http://localhost:8000/api > /dev/null 2>&1; then
247+ HEALTH_OK=true
248+ break
249+ fi
250+ sleep 1
251+ done
252+
253+ # Capture logs before cleanup
254+ echo "📋 Container logs:"
255+ docker logs "$CONTAINER_NAME" || true
256+
257+ # Cleanup container
258+ docker stop "$CONTAINER_NAME" > /dev/null 2>&1 || true
259+ docker rm "$CONTAINER_NAME" > /dev/null 2>&1 || true
260+
261+ if [ "$HEALTH_OK" = true ]; then
262+ echo "✅ Health check passed - agent responds on /api"
263+ else
264+ echo "❌ Health check failed - agent did not respond on /api within 30 seconds"
265+ exit 1
266+ fi
267+
268+ echo "✅ All validations passed for: $FULL_IMAGE"
0 commit comments