Skip to content

Commit 1e7562b

Browse files
committed
fix(tests): added tests for auth on cloud and changed structure of yml
1 parent 72ed309 commit 1e7562b

File tree

15 files changed

+363
-178
lines changed

15 files changed

+363
-178
lines changed

.github/workflows/integration_tests.yml

Lines changed: 139 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,150 @@ jobs:
1313
contents: read
1414
pull-requests: write
1515

16-
strategy:
17-
matrix:
18-
include:
19-
- build-dir: company-research-agent
20-
- build-dir: simple-local-mcp
21-
- build-dir: ticket-classification
22-
- build-dir: multi-agent-supervisor-researcher-coder
23-
2416
steps:
2517
- name: Checkout code
2618
uses: actions/checkout@v4
2719

2820
- name: Set up Docker Buildx
2921
uses: docker/setup-buildx-action@v3
3022

31-
- name: Build Docker image (${{ matrix.build-dir }})
23+
- name: Build common Docker image
24+
run: |
25+
echo "Building common Docker image at $(date)"
26+
docker build -f testcases/Dockerfile \
27+
-t uipath-langchain-testbase:latest \
28+
.
29+
echo "Common Docker image built at $(date)"
30+
31+
- name: Set jobs variable
32+
run: |
33+
echo "Discovering testcase folders..."
34+
35+
# Find all testcase folders (excluding common folders like README, etc.)
36+
testcase_dirs=$(find testcases -maxdepth 1 -type d -name "*-*" | sed 's|testcases/||' | sort)
37+
38+
echo "Found testcase directories:"
39+
echo "$testcase_dirs"
40+
41+
# Generate jobs array as a single line with space-separated values
42+
jobs_list=""
43+
for testcase in $testcase_dirs; do
44+
# Add all 4 combinations for each testcase
45+
jobs_list="${jobs_list} ${testcase}:true:alpha"
46+
jobs_list="${jobs_list} ${testcase}:false:alpha"
47+
jobs_list="${jobs_list} ${testcase}:true:cloud"
48+
jobs_list="${jobs_list} ${testcase}:false:cloud"
49+
done
50+
51+
echo "Generated jobs list:"
52+
echo "$jobs_list"
53+
54+
# Save to GITHUB_ENV as a simple variable
55+
echo "JOBS_LIST=$jobs_list" >> $GITHUB_ENV
56+
57+
- name: Run testcases
58+
run: |
59+
# Convert the jobs list back to an array
60+
read -a jobs <<< "$JOBS_LIST"
61+
62+
echo "=== STARTING TESTCASE EXECUTION ==="
63+
echo "Total testcases to run: ${#jobs[@]}"
64+
echo "Alpha environment with UiPathAzureChatOpenAI: $(echo "${jobs[@]}" | tr ' ' '\n' | grep ':true:alpha' | wc -l)"
65+
echo "Alpha environment with UiPathChat: $(echo "${jobs[@]}" | tr ' ' '\n' | grep ':false:alpha' | wc -l)"
66+
echo "Cloud environment with UiPathAzureChatOpenAI: $(echo "${jobs[@]}" | tr ' ' '\n' | grep ':true:cloud' | wc -l)"
67+
echo "Cloud environment with UiPathChat: $(echo "${jobs[@]}" | tr ' ' '\n' | grep ':false:cloud' | wc -l)"
68+
echo "======================================="
69+
70+
for job in "${jobs[@]}"; do
71+
IFS=":" read -r testcase use_azure_chat environment <<< "$job"
72+
llm=$([ "$use_azure_chat" = "true" ] && echo "UiPathAzureChatOpenAI" || echo "UiPathChat")
73+
log_file="run_${testcase}_${llm}_${environment}.log"
74+
75+
# Set environment-specific credentials
76+
if [ "$environment" = "alpha" ]; then
77+
CLIENT_ID_VAR='${{ secrets.ALPHA_TEST_CLIENT_ID }}'
78+
CLIENT_SECRET_VAR='${{ secrets.ALPHA_TEST_CLIENT_SECRET }}'
79+
BASE_URL_VAR='${{ secrets.ALPHA_BASE_URL }}'
80+
else
81+
CLIENT_ID_VAR='${{ secrets.CLOUD_TEST_CLIENT_ID }}'
82+
CLIENT_SECRET_VAR='${{ secrets.CLOUD_TEST_CLIENT_SECRET }}'
83+
BASE_URL_VAR='${{ secrets.CLOUD_BASE_URL }}'
84+
fi
85+
86+
(
87+
echo "[$(date)] STARTING: $testcase ($llm) [$environment]"
88+
89+
# Create log file with header
90+
{
91+
echo "========================================"
92+
echo "TESTCASE: $testcase"
93+
echo "LLM: $llm"
94+
echo "ENVIRONMENT: $environment"
95+
echo "USE_AZURE_CHAT: $use_azure_chat"
96+
echo "STARTED_AT: $(date)"
97+
echo "========================================"
98+
echo ""
99+
} > "$log_file"
100+
101+
# Run the testcase and append to log file
102+
docker run --rm \
103+
-e CLIENT_ID="$CLIENT_ID_VAR" \
104+
-e CLIENT_SECRET="$CLIENT_SECRET_VAR" \
105+
-e BASE_URL="$BASE_URL_VAR" \
106+
-e USE_AZURE_CHAT="$use_azure_chat" \
107+
uipath-langchain-testbase:latest \
108+
bash /app/testcases/$testcase/run.sh >> "$log_file" 2>&1
109+
110+
# Capture the exit code immediately
111+
exit_code=$?
112+
113+
# Add completion status to log file
114+
if [ $exit_code -eq 0 ]; then
115+
echo "[$(date)] SUCCESS: $testcase ($llm) [$environment]"
116+
{
117+
echo ""
118+
echo "========================================"
119+
echo "COMPLETED_AT: $(date)"
120+
echo "STATUS: SUCCESS"
121+
echo "========================================"
122+
} >> "$log_file"
123+
else
124+
echo "[$(date)] FAILED: $testcase ($llm) [$environment]"
125+
{
126+
echo ""
127+
echo "========================================"
128+
echo "COMPLETED_AT: $(date)"
129+
echo "STATUS: FAILED"
130+
echo "EXIT_CODE: $exit_code"
131+
echo "========================================"
132+
} >> "$log_file"
133+
fi
134+
) &
135+
done
136+
137+
wait
138+
echo "All testcases execution completed."
139+
140+
- name: Display all testcase logs
32141
run: |
33-
docker build -f testcases/${{ matrix.build-dir }}/Dockerfile \
34-
-t ${{ matrix.build-dir }}:test \
35-
--build-arg CLIENT_ID="${{ secrets.ALPHA_TEST_CLIENT_ID }}" \
36-
--build-arg CLIENT_SECRET="${{ secrets.ALPHA_TEST_CLIENT_SECRET }}" \
37-
--build-arg BASE_URL="${{ secrets.ALPHA_BASE_URL }}" \
38-
.
142+
# Convert the jobs list back to an array
143+
read -a jobs <<< "$JOBS_LIST"
144+
145+
for job in "${jobs[@]}"; do
146+
IFS=":" read -r testcase use_azure_chat environment <<< "$job"
147+
llm=$([ "$use_azure_chat" = "true" ] && echo "UiPathAzureChatOpenAI" || echo "UiPathChat")
148+
log_file="run_${testcase}_${llm}_${environment}.log"
149+
150+
# Create a collapsible group for each testcase log
151+
echo "::group::${testcase^^} (${llm}) ${environment^^} LOG"
152+
echo "Log file: $log_file"
153+
154+
if [ -f "$log_file" ]; then
155+
cat "$log_file"
156+
else
157+
echo "ERROR: Log file not found!"
158+
fi
159+
160+
echo "::endgroup::"
161+
echo ""
162+
done

testcases/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm
2+
3+
WORKDIR /app
4+
5+
COPY . .
6+
7+
# Install dependencies for all testcases
8+
RUN uv sync
9+
10+
11+
# Set environment variables for runtime
12+
ENV TAVILY_API_KEY=${TAVILY_API_KEY:-""}
13+
ENV UIPATH_TENANT_ID=${UIPATH_TENANT_ID:-""}
14+
ENV UIPATH_JOB_KEY=3a03d5cb-fa21-4021-894d-a8e2eda0afe0
15+
16+
CMD ["bash"]

testcases/company-research-agent/Dockerfile

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# Authenticate with UiPath
4+
echo "Authenticating with UiPath..."
5+
uv run uipath auth --client-id="$CLIENT_ID" --client-secret="$CLIENT_SECRET" --base-url="$BASE_URL"
6+
7+
cd /app/testcases/company-research-agent
8+
9+
# Sync dependencies for this specific testcase
10+
echo "Syncing dependencies..."
11+
uv sync
12+
13+
# Pack the agent
14+
echo "Packing agent..."
15+
uv run uipath pack
16+
17+
# Run the agent
18+
echo "Running agent with $CHAT_MODE mode..."
19+
echo "Input from input.json file"
20+
uv run uipath run agent --file input.json
21+
22+
# Print the output file
23+
echo "Printing output file..."
24+
if [ -f "__uipath/output.json" ]; then
25+
echo "=== OUTPUT FILE CONTENT ==="
26+
cat __uipath/output.json
27+
echo "=== END OUTPUT FILE CONTENT ==="
28+
else
29+
echo "ERROR: __uipath/output.json not found!"
30+
echo "Checking directory contents:"
31+
ls -la
32+
if [ -d "__uipath" ]; then
33+
echo "Contents of __uipath directory:"
34+
ls -la __uipath/
35+
else
36+
echo "__uipath directory does not exist!"
37+
fi
38+
fi
39+
40+
# Validate output
41+
echo "Validating output..."
42+
python src/assert.py
43+
44+
echo "Testcase completed successfully."

testcases/company-research-agent/src/graph.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from langgraph.prebuilt import create_react_agent
88
from pydantic import BaseModel
99

10-
from uipath_langchain.chat import UiPathAzureChatOpenAI
10+
from uipath_langchain.chat import UiPathAzureChatOpenAI, UiPathChat
1111

1212
# Configuration constants
1313
MAX_SEARCH_RESULTS = 5
@@ -46,11 +46,11 @@ def get_search_tool() -> Union[TavilySearchResults, DuckDuckGoSearchResults]:
4646
"""
4747

4848

49-
def create_llm() -> UiPathAzureChatOpenAI:
50-
"""Create and configure the language model."""
51-
return UiPathAzureChatOpenAI(model=DEFAULT_MODEL)
52-
# Alternative model option:
53-
# return ChatAnthropic(model=ALTERNATIVE_MODEL)
49+
def create_llm() -> Union[UiPathAzureChatOpenAI, UiPathChat]:
50+
"""Create and configure the language model based on an environment variable."""
51+
if os.getenv("USE_AZURE_CHAT", "false").lower() == "true":
52+
return UiPathAzureChatOpenAI(model=DEFAULT_MODEL)
53+
return UiPathChat(model=DEFAULT_MODEL)
5454

5555

5656
def create_research_agent():

testcases/company-research-agent/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testcases/multi-agent-supervisor-researcher-coder/Dockerfile

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# Authenticate with UiPath
4+
echo "Authenticating with UiPath..."
5+
uv run uipath auth --client-id="$CLIENT_ID" --client-secret="$CLIENT_SECRET" --base-url="$BASE_URL"
6+
7+
cd /app/testcases/multi-agent-supervisor-researcher-coder
8+
9+
# Sync dependencies for this specific testcase
10+
echo "Syncing dependencies..."
11+
uv sync
12+
13+
# Pack the agent
14+
echo "Packing agent..."
15+
uv run uipath pack
16+
17+
# Run the agent
18+
echo "Running agent with $CHAT_MODE mode..."
19+
echo "Input from input.json file"
20+
uv run uipath run agent --file input.json
21+
22+
# Print the output file
23+
echo "Printing output file..."
24+
if [ -f "__uipath/output.json" ]; then
25+
echo "=== OUTPUT FILE CONTENT ==="
26+
cat __uipath/output.json
27+
echo "=== END OUTPUT FILE CONTENT ==="
28+
else
29+
echo "ERROR: __uipath/output.json not found!"
30+
echo "Checking directory contents:"
31+
ls -la
32+
if [ -d "__uipath" ]; then
33+
echo "Contents of __uipath directory:"
34+
ls -la __uipath/
35+
else
36+
echo "__uipath directory does not exist!"
37+
fi
38+
fi
39+
40+
# Validate output
41+
echo "Validating output..."
42+
python src/assert.py
43+
44+
echo "Testcase completed successfully."

0 commit comments

Comments
 (0)