Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Integration testing

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

permissions:
contents: read
pull-requests: write
actions: read

jobs:
discover-testcases:
runs-on: ubuntu-latest
outputs:
testcases: ${{ steps.discover.outputs.testcases }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Discover testcases
id: discover
run: |
# Find all testcase folders (excluding common folders like README, etc.)
testcase_dirs=$(find testcases -maxdepth 1 -type d -name "*-*" | sed 's|testcases/||' | sort)

echo "Found testcase directories:"
echo "$testcase_dirs"

# Convert to JSON array for matrix
testcases_json=$(echo "$testcase_dirs" | jq -R -s -c 'split("\n")[:-1]')
echo "testcases=$testcases_json" >> $GITHUB_OUTPUT

integration-tests:
needs: [discover-testcases]
runs-on: ubuntu-latest
container:
image: ghcr.io/astral-sh/uv:python3.12-bookworm
strategy:
fail-fast: false
matrix:
testcase: ${{ fromJson(needs.discover-testcases.outputs.testcases) }}
environment: [alpha]

name: "${{ matrix.testcase }} / ${{ matrix.environment }}"

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: uv sync

- name: Run testcase
env:
UIPATH_TENANT_ID: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TENANT_ID || secrets.CLOUD_TENANT_ID }}
UIPATH_FOLDER_KEY: ${{ matrix.environment == 'alpha' && secrets.ALPHA_FOLDER_KEY || secrets.CLOUD_FOLDER_KEY }}
PAT_TOKEN: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_PAT_TOKEN || secrets.CLOUD_TEST_PAT_TOKEN }}
CLIENT_ID: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_CLIENT_ID || secrets.CLOUD_TEST_CLIENT_ID }}
CLIENT_SECRET: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_CLIENT_SECRET || secrets.CLOUD_TEST_CLIENT_SECRET }}
BASE_URL: ${{ matrix.environment == 'alpha' && secrets.ALPHA_BASE_URL || secrets.CLOUD_BASE_URL }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_RUN_ID: ${{ github.run_number }}
working-directory: testcases/${{ matrix.testcase }}
run: |
echo "Running testcase: ${{ matrix.testcase }}"
echo "Environment: ${{ matrix.environment }}"
echo "Working directory: $(pwd)"

# Execute the testcase run script directly
bash run.sh
9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dev = [
[tool.ruff]
line-length = 88
indent-width = 4
exclude = ["testcases/**"]

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

[tool.mypy]
plugins = [
"pydantic.mypy"
]
exclude = [
"samples/.*"
]
plugins = ["pydantic.mypy"]
exclude = ["samples/.*", "testcases/.*"]

follow_imports = "silent"
warn_redundant_casts = true
Expand Down
9 changes: 9 additions & 0 deletions testcases/ground-to-cloud/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"servers": {
"mathmcp-PRNUMBER": {
"transport": "stdio",
"command": "python",
"args": ["server.py"]
}
}
}
14 changes: 14 additions & 0 deletions testcases/ground-to-cloud/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[project]
name = "mathmcp"
version = "0.0.1"
description = "Description for mathmcp project"
authors = [{ name = "John Doe", email = "[email protected]" }]
dependencies = [
"mcp>=1.11.0",
"retry>=0.9.2",
"uipath-mcp",
]
requires-python = ">=3.11"

[tool.uv.sources]
uipath-mcp = { path = "../../", editable = true }
60 changes: 60 additions & 0 deletions testcases/ground-to-cloud/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

cleanup() {
echo "Cleaning up..."
if [ ! -z "$MCP_PID" ]; then
echo "Stopping MCP server (PID: $MCP_PID)..."
kill $MCP_PID 2>/dev/null || true
wait $MCP_PID 2>/dev/null || true
fi
}

# Set trap to cleanup on script exit
trap cleanup EXIT

echo "Syncing dependencies..."
uv sync

echo "Authenticating with UiPath..."
uv run uipath auth --client-id="$CLIENT_ID" --client-secret="$CLIENT_SECRET" --base-url="$BASE_URL"

# Generate dynamic values
PR_NUMBER=${GITHUB_PR_NUMBER:-"local"}
UNIQUE_ID=$(cat /proc/sys/kernel/random/uuid)
MCP_SERVER_NAME="mathmcp-${PR_NUMBER}"

echo "Updating uipath.json with dynamic values... PR Number: $PR_NUMBER, MCP Server Name: $MCP_SERVER_NAME, Unique ID: $UNIQUE_ID"

# Remove empty tenantId line if exists
sed -i '/^UIPATH_TENANT_ID=[[:space:]]*$/d' .env

# Replace placeholders in uipath.json using sed
sed -i "s/PRNUMBER/$PR_NUMBER/g" mcp.json
sed -i "s/PRNUMBER/$PR_NUMBER/g" uipath.json
sed -i "s/163f06b8-31e6-4639-aa31-ae4a88968a92/$UNIQUE_ID/g" uipath.json

echo "Packing agent..."
uv run uipath pack

# uipath run will block, so we run it in the background
echo "Starting MCP server in background..."
uv run uipath run "$MCP_SERVER_NAME" > mcp_server_output.log 2>&1 &
MCP_PID=$!

echo "MCP server started with PID: $MCP_PID"
echo "Waiting a moment for server to initialize..."
sleep 20

echo "Running integration test..."
MCP_SERVER_NAME="$MCP_SERVER_NAME" uv run test.py

# Capture test exit code
TEST_EXIT_CODE=$?

echo "====== MCP Server Output ======"
cat mcp_server_output.log

echo "Test completed with exit code: $TEST_EXIT_CODE"

# Cleanup will happen automatically due to trap
exit $TEST_EXIT_CODE
Loading