Skip to content

Commit 0e33eab

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

File tree

7 files changed

+686
-0
lines changed

7 files changed

+686
-0
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+
env:
42+
UIPATH_JOB_KEY: "3a03d5cb-fa21-4021-894d-a8e2eda0afe0"
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
testcase: ${{ fromJson(needs.discover-testcases.outputs.testcases) }}
47+
environment: [alpha]
48+
49+
name: "${{ matrix.testcase }} / ${{ matrix.environment }}"
50+
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v4
54+
55+
- name: Install dependencies
56+
run: uv sync
57+
58+
- name: Run testcase
59+
env:
60+
UIPATH_TENANT_ID: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TENANT_ID || secrets.CLOUD_TENANT_ID }}
61+
UIPATH_FOLDER_KEY: ${{ matrix.environment == 'alpha' && secrets.ALPHA_FOLDER_KEY || secrets.CLOUD_FOLDER_KEY }}
62+
PAT_TOKEN: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_PAT_TOKEN || secrets.CLOUD_TEST_PAT_TOKEN }}
63+
CLIENT_ID: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_CLIENT_ID || secrets.CLOUD_TEST_CLIENT_ID }}
64+
CLIENT_SECRET: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_CLIENT_SECRET || secrets.CLOUD_TEST_CLIENT_SECRET }}
65+
BASE_URL: ${{ matrix.environment == 'alpha' && secrets.ALPHA_BASE_URL || secrets.CLOUD_BASE_URL }}
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

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": {
4+
"transport": "stdio",
5+
"command": "python",
6+
"args": ["server.py"]
7+
}
8+
}
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
"uipath-mcp",
9+
]
10+
requires-python = ">=3.11"
11+
12+
[tool.uv.sources]
13+
uipath-mcp = { path = "../../", editable = true }

testcases/ground-to-cloud/run.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
# Remove empty tenantId line if exists
22+
sed -i '/^UIPATH_TENANT_ID=[[:space:]]*$/d' .env
23+
24+
# # Now overwrite just the ACCESS_TOKEN with PAT_TOKEN
25+
# if [ -n "$PAT_TOKEN" ]; then
26+
# # Use sed to replace only the active UIPATH_ACCESS_TOKEN line (not commented ones)
27+
# sed -i "s|^UIPATH_ACCESS_TOKEN=.*|UIPATH_ACCESS_TOKEN=$PAT_TOKEN|" .env
28+
# else
29+
# echo "Warning: PAT_TOKEN environment variable is not set!"
30+
# fi
31+
32+
echo "Packing agent..."
33+
uv run uipath pack
34+
35+
echo "Starting MCP server in background..."
36+
uv run uipath run mathmcp > mcp_server_output.log 2>&1 &
37+
MCP_PID=$!
38+
39+
echo "MCP server started with PID: $MCP_PID"
40+
echo "Waiting a moment for server to initialize..."
41+
sleep 5
42+
43+
echo "Running integration test..."
44+
uv run test.py
45+
46+
# Capture test exit code
47+
TEST_EXIT_CODE=$?
48+
49+
echo ""
50+
echo "=== MCP Server Output ==="
51+
cat mcp_server_output.log
52+
53+
echo "Test completed with exit code: $TEST_EXIT_CODE"
54+
# Cleanup will happen automatically due to trap
55+
exit $TEST_EXIT_CODE

0 commit comments

Comments
 (0)