|
| 1 | +name: Test Custom Version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + secrets: |
| 6 | + UIPATH_URL: |
| 7 | + required: true |
| 8 | + UIPATH_CLIENT_ID: |
| 9 | + required: true |
| 10 | + UIPATH_CLIENT_SECRET: |
| 11 | + required: true |
| 12 | + pull_request: |
| 13 | + types: [opened, synchronize, labeled, unlabeled] |
| 14 | + |
| 15 | +jobs: |
| 16 | + test-core-dev-version: |
| 17 | + name: Test Core Dev Version |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + if: contains(github.event.pull_request.labels.*.name, 'test-core-dev-version') |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + python-version: ["3.11", "3.12", "3.13"] |
| 23 | + os: [ubuntu-latest, windows-latest] |
| 24 | + |
| 25 | + permissions: |
| 26 | + contents: read |
| 27 | + pull-requests: read |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Extract version from PR |
| 34 | + id: extract-version |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + # Extract version from PR title only |
| 38 | + PR_TITLE="${{ github.event.pull_request.title }}" |
| 39 | +
|
| 40 | + # Search for version pattern in title (any x.y.z.dev version) |
| 41 | + VERSION=$(echo "$PR_TITLE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+' | head -1) |
| 42 | +
|
| 43 | + if [ -z "$VERSION" ]; then |
| 44 | + echo "No version found in PR title. Please include version in title like: 2.0.65.dev1004030443" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | +
|
| 48 | + echo "Extracted version: $VERSION" |
| 49 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 50 | +
|
| 51 | + - name: Setup uv |
| 52 | + uses: astral-sh/setup-uv@v5 |
| 53 | + with: |
| 54 | + enable-cache: true |
| 55 | + |
| 56 | + - name: Setup Python |
| 57 | + uses: actions/setup-python@v5 |
| 58 | + with: |
| 59 | + python-version: ${{ matrix.python-version }} |
| 60 | + |
| 61 | + - name: Modify pyproject.toml for custom UiPath version |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + # Backup original pyproject.toml |
| 65 | + cp pyproject.toml pyproject.toml.backup |
| 66 | +
|
| 67 | + # Update the uipath dependency to the custom version |
| 68 | + sed -i 's|"uipath>=.*"|"uipath==${{ steps.extract-version.outputs.version }}"|' pyproject.toml |
| 69 | +
|
| 70 | +
|
| 71 | +
|
| 72 | + # Add or update [tool.uv.sources] section if it doesn't exist |
| 73 | + if ! grep -q "\[tool\.uv\.sources\]" pyproject.toml; then |
| 74 | + echo "" >> pyproject.toml |
| 75 | + echo "[tool.uv.sources]" >> pyproject.toml |
| 76 | + echo 'uipath = { index = "testpypi" }' >> pyproject.toml |
| 77 | + else |
| 78 | + # Update existing sources if needed |
| 79 | + if ! grep -q 'uipath = { index = "testpypi" }' pyproject.toml; then |
| 80 | + sed -i '/\[tool\.uv\.sources\]/a uipath = { index = "testpypi" }' pyproject.toml |
| 81 | + fi |
| 82 | + fi |
| 83 | +
|
| 84 | + echo "Modified pyproject.toml to use UiPath version ${{ steps.extract-version.outputs.version }} from testpypi" |
| 85 | + echo "=== Modified pyproject.toml content ===" |
| 86 | + grep -A5 -B5 "uipath\|testpypi" pyproject.toml || true |
| 87 | +
|
| 88 | + - name: Install dependencies with specific UiPath version |
| 89 | + run: uv sync --all-extras |
| 90 | + |
| 91 | + - name: Run all tests |
| 92 | + run: uv run pytest |
| 93 | + env: |
| 94 | + UIPATH_URL: ${{ secrets.UIPATH_URL }} |
| 95 | + UIPATH_CLIENT_ID: ${{ secrets.UIPATH_CLIENT_ID }} |
| 96 | + UIPATH_CLIENT_SECRET: ${{ secrets.UIPATH_CLIENT_SECRET }} |
| 97 | + |
| 98 | + - name: Restore original pyproject.toml |
| 99 | + if: always() |
| 100 | + shell: bash |
| 101 | + run: | |
| 102 | + mv pyproject.toml.backup pyproject.toml |
0 commit comments