|
| 1 | +name: Agent E2E |
| 2 | + |
| 3 | +# Runs the agent e2e suites (e2e/) against the released Agentspan |
| 4 | +# server JAR — a full Conductor server with the agent runtime baked in. |
| 5 | +# tests/integration/ai stays manual-only (same as upstream Agentspan, |
| 6 | +# which never ran its tests/integration in CI): run it locally against |
| 7 | +# a live server with `pytest tests/integration/ai`. |
| 8 | +# |
| 9 | +# These tests call real LLMs via the OPENAI_API_KEY / ANTHROPIC_API_KEY |
| 10 | +# repo secrets. Fork PRs cannot see repo secrets, so for them the run |
| 11 | +# fails at the silently-empty guard rather than passing vacuously. |
| 12 | + |
| 13 | +on: [pull_request, workflow_dispatch] |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: agent-e2e-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +env: |
| 20 | + AGENTSPAN_VERSION: "0.4.0" # pinned server/CLI release — bump deliberately |
| 21 | + |
| 22 | +jobs: |
| 23 | + agent-e2e: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + timeout-minutes: 45 |
| 26 | + env: |
| 27 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 28 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 29 | + AGENTSPAN_SERVER_URL: http://localhost:8080/api |
| 30 | + AGENTSPAN_CLI_PATH: ${{ github.workspace }}/agentspan |
| 31 | + steps: |
| 32 | + - name: Checkout code |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Set up Python |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: '3.12' |
| 39 | + cache: 'pip' |
| 40 | + |
| 41 | + - name: Set up Java |
| 42 | + uses: actions/setup-java@v4 |
| 43 | + with: |
| 44 | + distribution: temurin |
| 45 | + java-version: '21' |
| 46 | + |
| 47 | + - name: Cache server JAR |
| 48 | + id: jar_cache |
| 49 | + uses: actions/cache@v4 |
| 50 | + with: |
| 51 | + path: agentspan-server.jar |
| 52 | + key: agentspan-server-${{ env.AGENTSPAN_VERSION }} |
| 53 | + |
| 54 | + - name: Download server JAR from release |
| 55 | + if: steps.jar_cache.outputs.cache-hit != 'true' |
| 56 | + env: |
| 57 | + GH_TOKEN: ${{ github.token }} |
| 58 | + run: | |
| 59 | + gh release download "v${AGENTSPAN_VERSION}" --repo agentspan-ai/agentspan \ |
| 60 | + --pattern "agentspan-server-${AGENTSPAN_VERSION}.jar" --output agentspan-server.jar |
| 61 | +
|
| 62 | + - name: Download CLI binary from release |
| 63 | + env: |
| 64 | + GH_TOKEN: ${{ github.token }} |
| 65 | + run: | |
| 66 | + gh release download "v${AGENTSPAN_VERSION}" --repo agentspan-ai/agentspan \ |
| 67 | + --pattern "agentspan_linux_amd64" --output agentspan |
| 68 | + chmod +x agentspan |
| 69 | +
|
| 70 | + - name: Install SDK + test deps |
| 71 | + run: | |
| 72 | + python -m pip install --upgrade pip |
| 73 | + pip install -e '.[agents]' |
| 74 | + pip install pytest pytest-asyncio pytest-xdist pytest-rerunfailures mcp-testkit |
| 75 | +
|
| 76 | + - name: Start mcp-testkit |
| 77 | + run: | |
| 78 | + mcp-testkit --transport http --port 3001 & |
| 79 | + sleep 2 |
| 80 | +
|
| 81 | + - name: Start server |
| 82 | + run: | |
| 83 | + java -jar agentspan-server.jar --server.port=8080 > server.log 2>&1 & |
| 84 | +
|
| 85 | + - name: Wait for server health |
| 86 | + run: | |
| 87 | + for i in $(seq 1 45); do |
| 88 | + if curl -sf http://localhost:8080/health | grep -q '"healthy"[[:space:]]*:[[:space:]]*true'; then |
| 89 | + echo "server healthy after ~$((i*2))s"; exit 0 |
| 90 | + fi |
| 91 | + sleep 2 |
| 92 | + done |
| 93 | + echo "::error::server failed to become healthy within 90s" |
| 94 | + tail -100 server.log |
| 95 | + exit 1 |
| 96 | +
|
| 97 | + - name: Run e2e suites |
| 98 | + run: | |
| 99 | + mkdir -p results |
| 100 | + pytest e2e/ -v --tb=short -n 3 --dist=loadgroup \ |
| 101 | + --junitxml=results/junit-e2e.xml |
| 102 | +
|
| 103 | + # e2e/conftest.py pytest.skip()s the whole session when the server is |
| 104 | + # unreachable — without this guard a boot failure after the health gate |
| 105 | + # (or a future gate regression) would yield a green job that ran nothing. |
| 106 | + - name: Guard against silently-empty runs |
| 107 | + if: always() |
| 108 | + run: | |
| 109 | + python - <<'EOF' |
| 110 | + import glob |
| 111 | + import sys |
| 112 | + import xml.etree.ElementTree as ET |
| 113 | +
|
| 114 | + total = executed = 0 |
| 115 | + for path in glob.glob("results/junit-*.xml"): |
| 116 | + root = ET.parse(path).getroot() |
| 117 | + for suite in root.iter("testsuite"): |
| 118 | + t = int(suite.get("tests", 0)) |
| 119 | + sk = int(suite.get("skipped", 0)) |
| 120 | + total += t |
| 121 | + executed += t - sk |
| 122 | + print(f"executed {executed}/{total} tests") |
| 123 | + sys.exit(0 if executed > 0 else 1) |
| 124 | + EOF |
| 125 | +
|
| 126 | + - name: Generate HTML report |
| 127 | + if: always() |
| 128 | + run: | |
| 129 | + python e2e/report_generator.py results/junit-e2e.xml results/report.html || true |
| 130 | +
|
| 131 | + - name: Upload results |
| 132 | + if: always() |
| 133 | + uses: actions/upload-artifact@v4 |
| 134 | + with: |
| 135 | + name: agent-e2e-results |
| 136 | + path: | |
| 137 | + results/ |
| 138 | + server.log |
| 139 | + retention-days: 14 |
0 commit comments