diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index a0f6b0c..44c0d5c 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -4,6 +4,162 @@ on: workflow_dispatch: inputs: commit-sha: - description: "Commit SHA to test against" - required: true + description: "Commit SHA to test against (defaults to current branch)" + required: false type: string + +permissions: + contents: read + packages: write + +jobs: + run-integration-tests: + name: "Run Integration Tests - s000-hello-acp" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.commit-sha || github.ref }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pull agent image + run: | + echo "๐Ÿณ Pulling agent image..." + docker pull ghcr.io/scaleapi/scale-agentex-python/tutorial-agents/00_sync-000_hello_acp:latest + echo "โœ… Agent image pulled successfully" + + - name: Start AgentEx services with host access + working-directory: ./agentex + run: | + echo "๐Ÿš€ Starting AgentEx services with host access override..." + docker compose -f docker-compose.yml -f docker-compose.host-access.yml up -d + echo "โณ Waiting for services to be ready..." + sleep 30 + docker compose ps + + - name: Run agent integration test + run: | + echo "๐Ÿงช Running integration test for agent: s000-hello-acp" + echo "๐Ÿณ Using image: ghcr.io/scaleapi/scale-agentex-python/tutorial-agents/00_sync-000_hello_acp:latest" + + # Start the agent container + + docker run -d --name agent-test-s000-hello-acp \ + -e AGENT_NAME=s000-hello-acp \ + -e ACP_URL=http://agent-test-s000-hello-acp:8000 \ + -e ACP_PORT=8000 \ + -e ACP_TYPE=sync \ + -e AGENTEX_BASE_URL=http://agentex:5003 \ + -e AGENTEX_API_BASE_URL=http://agentex:5003 \ + -p 8000:8000 \ + --network agentex-network \ + ghcr.io/scaleapi/scale-agentex-python/tutorial-agents/00_sync-000_hello_acp:latest + + echo "โณ Waiting for agent to start..." + sleep 10 + + # Check for "Application startup complete" log message + echo "๐Ÿ” Waiting for 'Application startup complete' log message..." + TIMEOUT=60 + ELAPSED=0 + + while [ $ELAPSED -lt $TIMEOUT ]; do + if docker logs agent-test-s000-hello-acp 2>&1 | grep -q "Application startup complete"; then + echo "โœ… Agent application has started successfully" + break + fi + + echo "โณ Still waiting for startup... (${ELAPSED}s/${TIMEOUT}s)" + sleep 2 + ELAPSED=$((ELAPSED + 2)) + done + + if [ $ELAPSED -ge $TIMEOUT ]; then + echo "โŒ Timeout waiting for 'Application startup complete' message" + echo "๐Ÿ“‹ Container logs:" + docker logs agent-test-s000-hello-acp + exit 1 + fi + + - name: Run agent tests with retry + run: | + echo "๐Ÿงช Running pytest tests against the agent..." + + echo "๐Ÿ”— Testing connectivity from agentex container to agent..." + echo "๐Ÿ“ก From agentex container, try to reach agent:" + docker exec agentex curl -v http://agent-test-s000-hello-acp:8000 + echo "๐Ÿฅ From agentex container, try to reach agent health endpoint:" + docker exec agentex curl -v http://agent-test-s000-hello-acp:8000/health + + echo "๐Ÿ”— Testing connectivity from agent container to agentex..." + echo "๐Ÿ“ก From agent container, try to reach agentex:" + docker exec agent-test-s000-hello-acp curl -v http://agentex:5003 + echo "๐Ÿฅ From agent container, try to reach agentex health endpoint:" + docker exec agent-test-s000-hello-acp curl -v http://agentex:5003/health + + echo "๐Ÿ”— Testing basic network connectivity (ping)..." + echo "๐Ÿ“ Ping from agentex to agent:" + docker exec agentex ping -c 3 agent-test-s000-hello-acp + echo "๐Ÿ“ Ping from agent to agentex:" + docker exec agent-test-s000-hello-acp ping -c 3 agentex + MAX_ATTEMPTS=2 + ATTEMPT=1 + SUCCESS=false + + while [ $ATTEMPT -le $MAX_ATTEMPTS ] && [ "$SUCCESS" = false ]; do + echo "๐Ÿ“ Test attempt $ATTEMPT/$MAX_ATTEMPTS" + + if docker exec agent-test-s000-hello-acp pytest tests/test_agent.py -v; then + echo "โœ… Tests passed on attempt $ATTEMPT!" + SUCCESS=true + else + echo "โŒ Tests failed on attempt $ATTEMPT" + if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then + echo "โณ Waiting 5 seconds before retry..." + sleep 5 + fi + fi + + ATTEMPT=$((ATTEMPT + 1)) + done + + if [ "$SUCCESS" = false ]; then + echo "โŒ All $MAX_ATTEMPTS test attempts failed" + exit 1 + fi + + echo "๐ŸŽ‰ Agent tests completed successfully!" + + - name: Show agent logs + if: always() + run: | + echo "๐Ÿ“‹ Agent logs for s000-hello-acp:" + docker logs agent-test-s000-hello-acp || echo "No logs available" + + - name: Show AgentEx server logs + if: always() + run: | + echo "๐Ÿ“‹ AgentEx server logs:" + docker logs agentex || echo "No AgentEx server logs available" + + - name: Cleanup agent container + if: always() + run: | + echo "๐Ÿงน Cleaning up agent container..." + docker stop agent-test-s000-hello-acp || true + docker rm agent-test-s000-hello-acp || true + + - name: Cleanup services + if: always() + working-directory: ./agentex + run: | + echo "๐Ÿงน Cleaning up services..." + docker compose -f docker-compose.yml -f docker-compose.host-access.yml down + docker system prune -f diff --git a/agentex/Makefile b/agentex/Makefile index b94353b..fbedf74 100644 --- a/agentex/Makefile +++ b/agentex/Makefile @@ -53,6 +53,14 @@ dev-wipe: ## Stop dev server and wipe DB @echo "Stopping dev server and wiping DB" docker compose down -v +dev-test: install-dev ## Start development server with host access for testing + @echo "๐Ÿš€ Starting development server with host access for testing..." + docker compose -f docker-compose.yml -f docker-compose.host-access.yml up --build + +dev-test-stop: ## Stop development server with host access configuration + @echo "Stopping dev test server with host access configuration" + docker compose -f docker-compose.yml -f docker-compose.host-access.yml down + # Database Commands # diff --git a/agentex/docker-compose.host-access.yml b/agentex/docker-compose.host-access.yml new file mode 100644 index 0000000..55033ce --- /dev/null +++ b/agentex/docker-compose.host-access.yml @@ -0,0 +1,10 @@ +# docker-compose.host-access.yml +# Override file to add host access when needed +# Usage: docker-compose -f docker-compose.yml -f docker-compose.host-access.yml up +# docker-compose.host-access.yml +services: + agentex: + networks: + agentex-network: + aliases: + - localhost # Make agentex reachable as localhost