Skip to content

Commit 57d8344

Browse files
authored
Merge pull request #236 from scaleapi/RF/add-validation-tutorials
adding validation protection
2 parents b168390 + ee15d9c commit 57d8344

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

.github/workflows/build-and-push-tutorial-agent.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,83 @@ 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 (required for integration tests)
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+
else
243+
echo "❌ No tests/test_agent.py found in image - this is required for all tutorial agents"
244+
echo " Please add a tests/test_agent.py file to your agent"
245+
exit 1
246+
fi
247+
248+
# 3. Validate container can start (may fail due to missing services, but should initialize)
249+
echo "🏥 Validating container starts..."
250+
CONTAINER_NAME="validate-agent-$$"
251+
252+
# Start container in background with required env vars
253+
docker run -d --name "$CONTAINER_NAME" \
254+
$ENV_VARS \
255+
-p 8000:8000 \
256+
"$FULL_IMAGE"
257+
258+
# Give it a few seconds to attempt startup
259+
sleep 5
260+
261+
# Check if container is still running (it may exit due to missing services, that's ok)
262+
# We just want to see that it attempted to start properly
263+
echo "📋 Container logs:"
264+
docker logs "$CONTAINER_NAME" 2>&1 || true
265+
266+
# Check for successful ACP initialization in logs
267+
if docker logs "$CONTAINER_NAME" 2>&1 | grep -q "instance created "; then
268+
echo "✅ Container initialized ACP successfully"
269+
else
270+
echo "⚠️ Could not verify ACP initialization from logs"
271+
fi
272+
273+
# Cleanup container
274+
docker stop "$CONTAINER_NAME" > /dev/null 2>&1 || true
275+
docker rm "$CONTAINER_NAME" > /dev/null 2>&1 || true
276+
277+
echo "✅ All validations passed for: $FULL_IMAGE"

0 commit comments

Comments
 (0)