Skip to content

Commit 77f1c0e

Browse files
committed
feat(test): add basic integration tests
1 parent 5730f31 commit 77f1c0e

File tree

8 files changed

+699
-6
lines changed

8 files changed

+699
-6
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Integration testing
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
actions: read
13+
14+
jobs:
15+
discover-testcases:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
testcases: ${{ steps.discover.outputs.testcases }}
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Discover testcases
24+
id: discover
25+
run: |
26+
# Find all testcase folders (excluding common folders like README, etc.)
27+
testcase_dirs=$(find testcases -maxdepth 1 -type d -name "*-*" | sed 's|testcases/||' | sort)
28+
29+
echo "Found testcase directories:"
30+
echo "$testcase_dirs"
31+
32+
# Convert to JSON array for matrix
33+
testcases_json=$(echo "$testcase_dirs" | jq -R -s -c 'split("\n")[:-1]')
34+
echo "testcases=$testcases_json" >> $GITHUB_OUTPUT
35+
36+
integration-tests:
37+
needs: [discover-testcases]
38+
runs-on: ubuntu-latest
39+
container:
40+
image: ghcr.io/astral-sh/uv:python3.12-bookworm
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
testcase: ${{ fromJson(needs.discover-testcases.outputs.testcases) }}
45+
environment: [alpha]
46+
47+
name: "${{ matrix.testcase }} / ${{ matrix.environment }}"
48+
49+
steps:
50+
- name: Checkout code
51+
uses: actions/checkout@v4
52+
53+
- name: Install dependencies
54+
run: uv sync
55+
56+
- name: Run testcase
57+
env:
58+
UIPATH_TENANT_ID: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TENANT_ID || secrets.CLOUD_TENANT_ID }}
59+
UIPATH_FOLDER_KEY: ${{ matrix.environment == 'alpha' && secrets.ALPHA_FOLDER_KEY || secrets.CLOUD_FOLDER_KEY }}
60+
PAT_TOKEN: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_PAT_TOKEN || secrets.CLOUD_TEST_PAT_TOKEN }}
61+
CLIENT_ID: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_CLIENT_ID || secrets.CLOUD_TEST_CLIENT_ID }}
62+
CLIENT_SECRET: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_CLIENT_SECRET || secrets.CLOUD_TEST_CLIENT_SECRET }}
63+
BASE_URL: ${{ matrix.environment == 'alpha' && secrets.ALPHA_BASE_URL || secrets.CLOUD_BASE_URL }}
64+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
65+
GITHUB_RUN_ID: ${{ github.run_number }}
66+
working-directory: testcases/${{ matrix.testcase }}
67+
run: |
68+
echo "Running testcase: ${{ matrix.testcase }}"
69+
echo "Environment: ${{ matrix.environment }}"
70+
echo "Working directory: $(pwd)"
71+
72+
# Execute the testcase run script directly
73+
bash run.sh

pyproject.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dev = [
4747
[tool.ruff]
4848
line-length = 88
4949
indent-width = 4
50+
exclude = ["testcases/**"]
5051

5152
[tool.ruff.lint]
5253
select = ["E", "F", "B", "I"]
@@ -61,12 +62,8 @@ skip-magic-trailing-comma = false
6162
line-ending = "auto"
6263

6364
[tool.mypy]
64-
plugins = [
65-
"pydantic.mypy"
66-
]
67-
exclude = [
68-
"samples/.*"
69-
]
65+
plugins = ["pydantic.mypy"]
66+
exclude = ["samples/.*", "testcases/.*"]
7067

7168
follow_imports = "silent"
7269
warn_redundant_casts = true

testcases/ground-to-cloud/mcp.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"servers": {
3+
"mathmcp-PRNUMBER": {
4+
"transport": "stdio",
5+
"command": "python",
6+
"args": ["server.py"]
7+
}
8+
}
9+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[project]
2+
name = "mathmcp"
3+
version = "0.0.1"
4+
description = "Description for mathmcp project"
5+
authors = [{ name = "John Doe", email = "[email protected]" }]
6+
dependencies = [
7+
"mcp>=1.11.0",
8+
"retry>=0.9.2",
9+
"uipath-mcp",
10+
]
11+
requires-python = ">=3.11"
12+
13+
[tool.uv.sources]
14+
uipath-mcp = { path = "../../", editable = true }

testcases/ground-to-cloud/run.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
cleanup() {
4+
echo "Cleaning up..."
5+
if [ ! -z "$MCP_PID" ]; then
6+
echo "Stopping MCP server (PID: $MCP_PID)..."
7+
kill $MCP_PID 2>/dev/null || true
8+
wait $MCP_PID 2>/dev/null || true
9+
fi
10+
}
11+
12+
# Set trap to cleanup on script exit
13+
trap cleanup EXIT
14+
15+
echo "Syncing dependencies..."
16+
uv sync
17+
18+
echo "Authenticating with UiPath..."
19+
uv run uipath auth --client-id="$CLIENT_ID" --client-secret="$CLIENT_SECRET" --base-url="$BASE_URL"
20+
21+
# Generate dynamic values
22+
PR_NUMBER=${GITHUB_PR_NUMBER:-"local"}
23+
UNIQUE_ID=$(cat /proc/sys/kernel/random/uuid)
24+
MCP_SERVER_NAME="mathmcp-${PR_NUMBER}"
25+
26+
echo "Updating uipath.json with dynamic values... PR Number: $PR_NUMBER, MCP Server Name: $MCP_SERVER_NAME, Unique ID: $UNIQUE_ID"
27+
28+
# Remove empty tenantId line if exists
29+
sed -i '/^UIPATH_TENANT_ID=[[:space:]]*$/d' .env
30+
31+
# Replace placeholders in uipath.json using sed
32+
sed -i "s/PRNUMBER/$PR_NUMBER/g" mcp.json
33+
sed -i "s/PRNUMBER/$PR_NUMBER/g" uipath.json
34+
sed -i "s/163f06b8-31e6-4639-aa31-ae4a88968a92/$UNIQUE_ID/g" uipath.json
35+
36+
echo "Packing agent..."
37+
uv run uipath pack
38+
39+
# uipath run will block, so we run it in the background
40+
echo "Starting MCP server in background..."
41+
uv run uipath run "$MCP_SERVER_NAME" > mcp_server_output.log 2>&1 &
42+
MCP_PID=$!
43+
44+
echo "MCP server started with PID: $MCP_PID"
45+
echo "Waiting a moment for server to initialize..."
46+
sleep 20
47+
48+
echo "Running integration test..."
49+
MCP_SERVER_NAME="$MCP_SERVER_NAME" uv run test.py
50+
51+
# Capture test exit code
52+
TEST_EXIT_CODE=$?
53+
54+
echo "====== MCP Server Output ======"
55+
cat mcp_server_output.log
56+
57+
echo "Test completed with exit code: $TEST_EXIT_CODE"
58+
59+
# Cleanup will happen automatically due to trap
60+
exit $TEST_EXIT_CODE

0 commit comments

Comments
 (0)