@@ -195,7 +195,88 @@ 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+ # Tests are located at /app/<agent_dir>/tests/test_agent.py
237+ echo "🧪 Checking for tests/test_agent.py..."
238+ TEST_FILE=$(docker run --rm "$FULL_IMAGE" find /app -name "test_agent.py" -path "*/tests/*" 2>/dev/null | head -1)
239+
240+ if [ -n "$TEST_FILE" ]; then
241+ echo "Found test file at: $TEST_FILE"
242+ # Get the directory containing the test file for proper pytest discovery
243+ TEST_DIR=$(dirname "$TEST_FILE")
244+ echo "Running tests from: $TEST_DIR"
245+ docker run --rm $ENV_VARS "$FULL_IMAGE" python -m pytest "$TEST_FILE" -v --tb=short
246+ echo "✅ Agent tests passed"
247+ else
248+ echo "❌ No tests/test_agent.py found in image - this is required for all tutorial agents"
249+ echo " Please add a tests/test_agent.py file to your agent"
250+ exit 1
251+ fi
252+
253+ # 3. Validate container can start (may fail due to missing services, but should initialize)
254+ echo "🏥 Validating container starts..."
255+ CONTAINER_NAME="validate-agent-$$"
256+
257+ # Start container in background with required env vars
258+ docker run -d --name "$CONTAINER_NAME" \
259+ $ENV_VARS \
260+ -p 8000:8000 \
261+ "$FULL_IMAGE"
262+
263+ # Give it a few seconds to attempt startup
264+ sleep 5
265+
266+ # Check if container is still running (it may exit due to missing services, that's ok)
267+ # We just want to see that it attempted to start properly
268+ echo "📋 Container logs:"
269+ docker logs "$CONTAINER_NAME" 2>&1 || true
270+
271+ # Check for successful ACP initialization in logs
272+ if docker logs "$CONTAINER_NAME" 2>&1 | grep -q "ACP.*instance"; then
273+ echo "✅ Container initialized ACP successfully"
274+ else
275+ echo "⚠️ Could not verify ACP initialization from logs"
276+ fi
277+
278+ # Cleanup container
279+ docker stop "$CONTAINER_NAME" > /dev/null 2>&1 || true
280+ docker rm "$CONTAINER_NAME" > /dev/null 2>&1 || true
281+
282+ echo "✅ All validations passed for: $FULL_IMAGE"
0 commit comments