@@ -195,7 +195,92 @@ 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+ AGENT_NAME="${{ env.AGENT_NAME }}"
214+
215+ echo "🔍 Validating agent image: $FULL_IMAGE"
216+
217+ # Determine ACP type from path
218+ if [[ "$AGENT_PATH" == *"10_async"* ]]; then
219+ ACP_TYPE="async"
220+ else
221+ ACP_TYPE="sync"
222+ fi
223+
224+ # Common environment variables for validation
225+ ENV_VARS="-e ENVIRONMENT=development \
226+ -e AGENT_NAME=${AGENT_NAME} \
227+ -e ACP_URL=http://localhost:8000 \
228+ -e ACP_PORT=8000 \
229+ -e ACP_TYPE=${ACP_TYPE}"
230+
231+ # 1. Validate ACP entry point exists and is importable
232+ echo "📦 Checking ACP entry point..."
233+ docker run --rm $ENV_VARS "$FULL_IMAGE" python -c "from project.acp import acp; print('✅ ACP entry point validated')"
234+
235+ # 2. Check if tests/test_agent.py exists and run it
236+ echo "🧪 Checking for tests/test_agent.py..."
237+ if docker run --rm $ENV_VARS "$FULL_IMAGE" test -f /app/tests/test_agent.py; then
238+ echo "Found tests/test_agent.py - running tests..."
239+ docker run --rm $ENV_VARS "$FULL_IMAGE" python -m pytest /app/tests/test_agent.py -v --tb=short
240+ echo "✅ Agent tests passed"
241+ else
242+ echo "⚠️ No tests/test_agent.py found at /app/tests/test_agent.py - skipping test validation"
243+ echo " Consider adding tests/test_agent.py to validate agent functionality"
244+ fi
245+
246+ # 3. Health check - start container and verify /api endpoint responds
247+ echo "🏥 Running health check..."
248+ CONTAINER_NAME="validate-agent-$$"
249+
250+ # Start container in background with required env vars
251+ docker run -d --name "$CONTAINER_NAME" \
252+ $ENV_VARS \
253+ -p 8000:8000 \
254+ "$FULL_IMAGE"
255+
256+ # Wait for container to be ready (max 30 seconds)
257+ echo "Waiting for agent to start..."
258+ MAX_ATTEMPTS=30
259+ ATTEMPT=0
260+ HEALTH_OK=false
261+
262+ while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
263+ ATTEMPT=$((ATTEMPT + 1))
264+ if curl -sf http://localhost:8000/api > /dev/null 2>&1; then
265+ HEALTH_OK=true
266+ break
267+ fi
268+ sleep 1
269+ done
270+
271+ # Capture logs before cleanup
272+ echo "📋 Container logs:"
273+ docker logs "$CONTAINER_NAME" || true
274+
275+ # Cleanup container
276+ docker stop "$CONTAINER_NAME" > /dev/null 2>&1 || true
277+ docker rm "$CONTAINER_NAME" > /dev/null 2>&1 || true
278+
279+ if [ "$HEALTH_OK" = true ]; then
280+ echo "✅ Health check passed - agent responds on /api"
281+ else
282+ echo "❌ Health check failed - agent did not respond on /api within 30 seconds"
283+ exit 1
284+ fi
285+
286+ echo "✅ All validations passed for: $FULL_IMAGE"
0 commit comments