-
Notifications
You must be signed in to change notification settings - Fork 9
136 lines (114 loc) · 4.4 KB
/
test-custom-version.yml
File metadata and controls
136 lines (114 loc) · 4.4 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
name: Test Custom Version
on:
workflow_call:
secrets:
UIPATH_URL:
required: true
UIPATH_CLIENT_ID:
required: true
UIPATH_CLIENT_SECRET:
required: true
pull_request:
types: [opened, synchronize, labeled, unlabeled]
paths:
- 'packages/**'
- '.github/workflows/test-custom-version.yml'
- '.github/scripts/detect_changed_packages.py'
permissions:
contents: read
pull-requests: read
jobs:
detect-changed-packages:
if: contains(github.event.pull_request.labels.*.name, 'test-core-dev-version')
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.detect.outputs.packages }}
count: ${{ steps.detect.outputs.count }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Detect changed packages
id: detect
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: python .github/scripts/detect_changed_packages.py
test-core-dev-version:
name: Test ${{ matrix.package }} - Custom Version
needs: detect-changed-packages
if: contains(github.event.pull_request.labels.*.name, 'test-core-dev-version') && needs.detect-changed-packages.outputs.count > 0
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: packages/${{ matrix.package }}
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.detect-changed-packages.outputs.packages) }}
python-version: ["3.11", "3.12", "3.13"]
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract version from PR
id: extract-version
shell: bash
run: |
# Extract version from PR title only
PR_TITLE="${{ github.event.pull_request.title }}"
# Search for version pattern in title (any x.y.z.dev version)
VERSION=$(echo "$PR_TITLE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+' | head -1)
if [ -z "$VERSION" ]; then
echo "No version found in PR title. Please include version in title like: 2.0.65.dev1004030443"
exit 1
fi
echo "Extracted version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Modify pyproject.toml for custom UiPath version
shell: bash
run: |
# Backup original pyproject.toml
cp pyproject.toml pyproject.toml.backup
# Update the uipath dependency to the custom version
sed -i 's|"uipath>=.*"|"uipath==${{ steps.extract-version.outputs.version }}"|' pyproject.toml
# Add or update [tool.uv.sources] section if it doesn't exist
if ! grep -q "\[tool\.uv\.sources\]" pyproject.toml; then
echo "" >> pyproject.toml
echo "[tool.uv.sources]" >> pyproject.toml
echo 'uipath = { index = "testpypi" }' >> pyproject.toml
else
# Update existing sources if needed
if ! grep -q 'uipath = { index = "testpypi" }' pyproject.toml; then
sed -i '/\[tool\.uv\.sources\]/a uipath = { index = "testpypi" }' pyproject.toml
fi
fi
echo "Modified pyproject.toml to use UiPath version ${{ steps.extract-version.outputs.version }} from testpypi"
echo "=== Modified pyproject.toml content ==="
grep -A5 -B5 "uipath\|testpypi" pyproject.toml || true
- name: Install dependencies with specific UiPath version
run: uv sync --all-extras --python ${{ matrix.python-version }}
- name: Run all tests
run: uv run pytest
env:
UIPATH_URL: ${{ secrets.UIPATH_URL }}
UIPATH_CLIENT_ID: ${{ secrets.UIPATH_CLIENT_ID }}
UIPATH_CLIENT_SECRET: ${{ secrets.UIPATH_CLIENT_SECRET }}
- name: Restore original pyproject.toml
if: always()
shell: bash
run: mv pyproject.toml.backup pyproject.toml