|
| 1 | +# Python Compatibility Testing Workflow |
| 2 | +# |
| 3 | +# Tests Python package build compatibility across: |
| 4 | +# - Operating Systems: Ubuntu, macOS, Windows |
| 5 | +# - Python Versions: 3.9, 3.10, 3.11, 3.12, 3.13 |
| 6 | +# |
| 7 | +# Validates that the package can be built and installed correctly |
| 8 | +# on all supported platforms and Python versions. |
| 9 | + |
| 10 | +name: Python Compatibility Check |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +on: |
| 17 | + workflow_dispatch: |
| 18 | + push: |
| 19 | + pull_request: |
| 20 | + |
| 21 | +env: |
| 22 | + # Change this to invalidate existing cache. |
| 23 | + CACHE_PREFIX: v0 |
| 24 | + PYTHON_PATH: ./ |
| 25 | + |
| 26 | +permissions: |
| 27 | + contents: read |
| 28 | + |
| 29 | +jobs: |
| 30 | + checks: |
| 31 | + name: Python ${{ matrix.python }} - ${{ matrix.os }} - ${{ matrix.task.name }} |
| 32 | + runs-on: ${{ matrix.os }} |
| 33 | + timeout-minutes: 30 |
| 34 | + strategy: |
| 35 | + fail-fast: false |
| 36 | + matrix: |
| 37 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 38 | + python: ['3.9', '3.10', '3.11', '3.12', '3.13'] |
| 39 | + task: |
| 40 | + - name: Build |
| 41 | + run: | |
| 42 | + pip list |
| 43 | + pip install twine |
| 44 | + pip install --upgrade setuptools wheel |
| 45 | + pip list |
| 46 | + python setup.py check |
| 47 | + python setup.py bdist_wheel sdist |
| 48 | + twine check ./dist/* |
| 49 | +
|
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v3 |
| 52 | + |
| 53 | + - name: Setup Python |
| 54 | + uses: actions/setup-python@v3 |
| 55 | + with: |
| 56 | + python-version: ${{ matrix.python }} |
| 57 | + |
| 58 | + - name: Install prerequisites |
| 59 | + run: | |
| 60 | + python -m pip install --upgrade pip setuptools wheel |
| 61 | +
|
| 62 | + - name: Set build variables |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_ENV |
| 66 | +
|
| 67 | + - name: Test dependency wheels availability - Unix/Linux/macOS |
| 68 | + if: runner.os != 'Windows' |
| 69 | + run: | |
| 70 | + python -m venv .venv-deps-test |
| 71 | + . .venv-deps-test/bin/activate |
| 72 | + # Try installing with wheel-only first to catch dependency conflicts early |
| 73 | + pip install --only-binary=:all: -r requirements.txt || { |
| 74 | + echo "Warning: Some dependencies may not have wheels available" |
| 75 | + echo "Attempting installation with source packages allowed..." |
| 76 | + pip install -r requirements.txt |
| 77 | + } |
| 78 | + deactivate |
| 79 | + rm -rf .venv-deps-test |
| 80 | + shell: bash |
| 81 | + |
| 82 | + - name: Test dependency wheels availability - Windows |
| 83 | + if: runner.os == 'Windows' |
| 84 | + run: | |
| 85 | + python -m venv .venv-deps-test |
| 86 | + .venv-deps-test\Scripts\Activate.ps1 |
| 87 | + # Try installing with wheel-only first to catch dependency conflicts early |
| 88 | + pip install --only-binary=:all: -r requirements.txt |
| 89 | + if ($LASTEXITCODE -ne 0) { |
| 90 | + Write-Host "Warning: Some dependencies may not have wheels available" |
| 91 | + Write-Host "Attempting installation with source packages allowed..." |
| 92 | + pip install -r requirements.txt |
| 93 | + } |
| 94 | + deactivate |
| 95 | + Remove-Item -Recurse -Force .venv-deps-test |
| 96 | + shell: pwsh |
| 97 | + |
| 98 | + - name: Setup virtual environment - Unix/Linux/macOS |
| 99 | + if: runner.os != 'Windows' |
| 100 | + run: | |
| 101 | + python -m venv .venv |
| 102 | + . .venv/bin/activate |
| 103 | + pip install -e .[dev] |
| 104 | + shell: bash |
| 105 | + |
| 106 | + - name: Setup virtual environment - Windows |
| 107 | + if: runner.os == 'Windows' |
| 108 | + run: | |
| 109 | + python -m venv .venv |
| 110 | + .venv\Scripts\Activate.ps1 |
| 111 | + pip install -e .[dev] |
| 112 | + shell: pwsh |
| 113 | + |
| 114 | + - name: Show environment info - Unix/Linux/macOS |
| 115 | + if: runner.os != 'Windows' |
| 116 | + run: | |
| 117 | + . .venv/bin/activate |
| 118 | + which python |
| 119 | + python --version |
| 120 | + pip freeze |
| 121 | + # Node.js version info - uncomment if you need to verify Node.js/npm/pnpm versions |
| 122 | + # which node |
| 123 | + # node --version |
| 124 | + # npm --version |
| 125 | + # pnpm --version |
| 126 | + shell: bash |
| 127 | + |
| 128 | + - name: Show environment info - Windows |
| 129 | + if: runner.os == 'Windows' |
| 130 | + run: | |
| 131 | + .venv\Scripts\Activate.ps1 |
| 132 | + Get-Command python |
| 133 | + python --version |
| 134 | + pip freeze |
| 135 | + # Node.js version info - uncomment if you need to verify Node.js/npm/pnpm versions |
| 136 | + # Get-Command node |
| 137 | + # node --version |
| 138 | + # npm --version |
| 139 | + # pnpm --version |
| 140 | + shell: pwsh |
| 141 | + |
| 142 | + # Web build steps - tests TypeScript/web components compilation and bundling |
| 143 | + # Uncomment if you need to verify that web components work with your Python package changes |
| 144 | + # - name: Build Web |
| 145 | + # run: | |
| 146 | + # pnpm build:typespec |
| 147 | + # pnpm build:web |
| 148 | + # pnpm bundle |
| 149 | + # env: |
| 150 | + # CI: false |
| 151 | + |
| 152 | + # TypeSpec emitter testing - tests the TypeSpec-to-code generation functionality |
| 153 | + # Uncomment if you need to verify TypeSpec emitter compatibility with your Python changes |
| 154 | + # - name: Test Typespec-aaz Emitter |
| 155 | + # run: | |
| 156 | + # pnpm test-aaz-emitter |
| 157 | + |
| 158 | + - name: ${{ matrix.task.name }} - Unix/Linux/macOS |
| 159 | + if: runner.os != 'Windows' |
| 160 | + run: | |
| 161 | + . .venv/bin/activate |
| 162 | + ${{ matrix.task.run }} |
| 163 | + shell: bash |
| 164 | + |
| 165 | + - name: ${{ matrix.task.name }} - Windows |
| 166 | + if: runner.os == 'Windows' |
| 167 | + run: | |
| 168 | + .venv\Scripts\Activate.ps1 |
| 169 | + ${{ matrix.task.run }} |
| 170 | + shell: pwsh |
| 171 | + |
0 commit comments