-
Notifications
You must be signed in to change notification settings - Fork 23
284 lines (249 loc) · 10.2 KB
/
test-uipath-integrations.yml
File metadata and controls
284 lines (249 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
name: uipath - Test Integrations
on:
pull_request:
types: [ opened, synchronize, reopened, labeled ]
jobs:
build-wheels:
runs-on: ubuntu-latest
permissions:
contents: read
if: contains(github.event.pull_request.labels.*.name, 'test:uipath-integrations')
steps:
- name: Checkout uipath-python
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v5
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build uipath-core package
working-directory: packages/uipath-core
run: uv build
- name: Build uipath-platform package
working-directory: packages/uipath-platform
run: uv build
- name: Build uipath package
working-directory: packages/uipath
run: uv build
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: uipath-wheels
path: packages/*/dist/*.whl
discover-packages:
needs: [build-wheels]
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
packages: ${{ steps.discover.outputs.packages }}
steps:
- name: Checkout uipath-integrations-python
uses: actions/checkout@v4
with:
repository: 'UiPath/uipath-integrations-python'
path: 'uipath-integrations-python'
- name: Discover packages
id: discover
working-directory: uipath-integrations-python
run: |
# Find every package directory under packages/ that has a pyproject.toml
package_dirs=$(find packages -maxdepth 2 -name pyproject.toml -printf '%h\n' | sed 's|^packages/||' | sort)
echo "Found integration packages:"
echo "$package_dirs"
packages_json=$(echo "$package_dirs" | jq -R -s -c 'split("\n")[:-1]')
echo "packages=$packages_json" >> $GITHUB_OUTPUT
test-package:
needs: [build-wheels, discover-packages]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.discover-packages.outputs.packages) }}
python-version: [ "3.11", "3.12", "3.13" ]
os: [ ubuntu-latest, windows-latest ]
name: "${{ matrix.package }} / py${{ matrix.python-version }} / ${{ matrix.os }}"
permissions:
contents: read
steps:
- name: Setup uv
uses: astral-sh/setup-uv@v5
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download wheels
uses: actions/download-artifact@v4
with:
name: uipath-wheels
path: wheels
- name: Checkout uipath-integrations-python
uses: actions/checkout@v4
with:
repository: 'UiPath/uipath-integrations-python'
path: 'uipath-integrations-python'
- name: Update uipath packages
shell: bash
working-directory: uipath-integrations-python/packages/${{ matrix.package }}
run: |
uv add ../../../wheels/uipath-core/dist/*.whl --dev
uv add ../../../wheels/uipath-platform/dist/*.whl --dev
uv add ../../../wheels/uipath/dist/*.whl --dev
- name: Install dependencies and run tests
shell: bash
working-directory: uipath-integrations-python/packages/${{ matrix.package }}
run: |
uv sync
if [ -d tests ]; then
uv run pytest
else
echo "No tests directory found in ${{ matrix.package }}, skipping pytest"
fi
discover-testcases:
needs: [test-package, discover-packages]
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
matrix: ${{ steps.discover.outputs.matrix }}
has_testcases: ${{ steps.discover.outputs.has_testcases }}
steps:
- name: Checkout uipath-integrations-python
uses: actions/checkout@v4
with:
repository: 'UiPath/uipath-integrations-python'
path: 'uipath-integrations-python'
- name: Discover testcases across packages
id: discover
working-directory: uipath-integrations-python
run: |
# For each package with a testcases/ directory, list its testcase folders
# and emit one matrix entry per (package, testcase) pair.
entries="[]"
for pkg_dir in packages/*/; do
pkg=$(basename "$pkg_dir")
tc_dir="$pkg_dir/testcases"
if [ ! -d "$tc_dir" ]; then
continue
fi
testcases=$(find "$tc_dir" -maxdepth 1 -type d -name "*-*" -printf '%f\n' | sort)
if [ -z "$testcases" ]; then
continue
fi
for tc in $testcases; do
entries=$(echo "$entries" | jq --arg p "$pkg" --arg t "$tc" '. + [{package: $p, testcase: $t}]')
done
done
echo "Discovered testcase matrix:"
echo "$entries" | jq .
count=$(echo "$entries" | jq 'length')
if [ "$count" -eq 0 ]; then
echo "has_testcases=false" >> $GITHUB_OUTPUT
echo "matrix=[]" >> $GITHUB_OUTPUT
else
echo "has_testcases=true" >> $GITHUB_OUTPUT
echo "matrix=$(echo "$entries" | jq -c .)" >> $GITHUB_OUTPUT
fi
run-integration-tests:
needs: [build-wheels, discover-testcases]
if: needs.discover-testcases.outputs.has_testcases == 'true'
runs-on: ubuntu-latest
container:
image: ghcr.io/astral-sh/uv:python3.12-bookworm
env:
UIPATH_JOB_KEY: "3a03d5cb-fa21-4021-894d-a8e2eda0afe0"
UIPATH_TRACING_ENABLED: false
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.discover-testcases.outputs.matrix) }}
environment: [alpha, staging] # temporary disable [cloud]
name: "${{ matrix.package }} / ${{ matrix.testcase }} / ${{ matrix.environment }}"
steps:
- name: Download wheels
uses: actions/download-artifact@v4
with:
name: uipath-wheels
path: wheels
- name: Checkout uipath-integrations-python
uses: actions/checkout@v4
with:
repository: 'UiPath/uipath-integrations-python'
path: 'uipath-integrations-python'
- name: Update uipath packages
shell: bash
working-directory: uipath-integrations-python/packages/${{ matrix.package }}
run: |
uv add ../../../wheels/uipath-core/dist/*.whl
uv add ../../../wheels/uipath-platform/dist/*.whl
uv add ../../../wheels/uipath/dist/*.whl
- name: Install dependencies
working-directory: uipath-integrations-python/packages/${{ matrix.package }}
run: uv sync
- name: Run testcase
env:
CLIENT_ID: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_CLIENT_ID || matrix.environment == 'staging' && secrets.STAGING_TEST_CLIENT_ID || matrix.environment == 'cloud' && secrets.CLOUD_TEST_CLIENT_ID }}
CLIENT_SECRET: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_CLIENT_SECRET || matrix.environment == 'staging' && secrets.STAGING_TEST_CLIENT_SECRET || matrix.environment == 'cloud' && secrets.CLOUD_TEST_CLIENT_SECRET }}
BASE_URL: ${{ matrix.environment == 'alpha' && secrets.ALPHA_BASE_URL || matrix.environment == 'staging' && secrets.STAGING_BASE_URL || matrix.environment == 'cloud' && secrets.CLOUD_BASE_URL }}
UV_PYTHON: "3.12"
working-directory: uipath-integrations-python/packages/${{ matrix.package }}/testcases/${{ matrix.testcase }}
run: |
echo "Package: ${{ matrix.package }}"
echo "Testcase: ${{ matrix.testcase }}"
echo "Environment: ${{ matrix.environment }}"
bash run.sh
bash ../common/validate_output.sh
notify-on-failure:
needs: [test-package, run-integration-tests]
if: always() && contains(github.event.pull_request.labels.*.name, 'test:uipath-integrations') && (needs.test-package.result == 'failure' || needs.run-integration-tests.result == 'failure')
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const marker = '<!-- cross-test-failure:uipath-integrations -->';
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const body = [
marker,
'## :rotating_light: **Heads up: `uipath-integrations` cross-tests are FAILING** :rotating_light:',
'',
'Your changes may break one or more integrations in **[`uipath-integrations-python`](https://github.com/UiPath/uipath-integrations-python)**:',
'',
'- `uipath-openai-agents`',
'- `uipath-google-adk`',
'- `uipath-agent-framework`',
'- `uipath-llamaindex`',
'- `uipath-pydantic-ai`',
'',
'> :warning: **These checks are NOT enforced by branch protection rules.** Please review the failures before merging.',
'',
`**:mag: [Inspect the failed run →](${runUrl})**`,
].join('\n');
// Delete any prior failure comments for this workflow so the new
// one always lands at the bottom of the PR conversation.
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
for (const c of comments) {
if (c.body && c.body.includes(marker)) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: c.id,
});
}
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});