|
| 1 | +name: Python CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: "Build & Regenerate (Linux)" |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v7 |
| 15 | + |
| 16 | + - uses: ./.github/actions/setup |
| 17 | + |
| 18 | + - uses: actions/setup-python@v7 |
| 19 | + with: |
| 20 | + python-version: "3.12" |
| 21 | + |
| 22 | + - name: Install repo dependencies |
| 23 | + run: pnpm install |
| 24 | + |
| 25 | + - name: Setup http-client-python |
| 26 | + # Avoid npm lifecycle side effects and lockfile rewrites in CI; setup still runs build + generator install. |
| 27 | + run: | |
| 28 | + npm install --ignore-scripts --package-lock=false |
| 29 | + npm run setup |
| 30 | + working-directory: packages/http-client-python |
| 31 | + |
| 32 | + - name: Prepare Python environment |
| 33 | + # Run prepare.py directly so missing tox/dev dependencies fail the job instead of being swallowed by the npm wrapper. |
| 34 | + run: venv/bin/python eng/scripts/setup/prepare.py |
| 35 | + working-directory: packages/http-client-python |
| 36 | + |
| 37 | + - name: Regenerate |
| 38 | + run: npm run regenerate |
| 39 | + working-directory: packages/http-client-python |
| 40 | + |
| 41 | + - name: Pre-build wheels |
| 42 | + run: | |
| 43 | + venv/bin/python tests/install_packages.py build azure tests |
| 44 | + venv/bin/python tests/install_packages.py build unbranded tests |
| 45 | + working-directory: packages/http-client-python |
| 46 | + |
| 47 | + - name: Check for unstaged changes |
| 48 | + run: npm run check-unstaged |
| 49 | + working-directory: packages/http-client-python |
| 50 | + |
| 51 | + - name: Upload generated artifacts |
| 52 | + uses: actions/upload-artifact@v7 |
| 53 | + with: |
| 54 | + name: python-generated |
| 55 | + include-hidden-files: true |
| 56 | + path: | |
| 57 | + packages/http-client-python/tests/generated |
| 58 | + packages/http-client-python/tests/.wheels |
| 59 | + packages/http-client-python/dist |
| 60 | + packages/http-client-python/generator/dist |
| 61 | + retention-days: 1 |
| 62 | + |
| 63 | + test: |
| 64 | + name: "Mock API Tests" |
| 65 | + needs: build |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v7 |
| 69 | + |
| 70 | + - uses: ./.github/actions/setup |
| 71 | + |
| 72 | + - uses: actions/setup-python@v7 |
| 73 | + with: |
| 74 | + python-version: "3.12" |
| 75 | + |
| 76 | + - name: Download generated artifacts |
| 77 | + uses: actions/download-artifact@v8 |
| 78 | + with: |
| 79 | + name: python-generated |
| 80 | + path: packages/http-client-python |
| 81 | + |
| 82 | + - name: Install repo dependencies |
| 83 | + run: pnpm install |
| 84 | + |
| 85 | + - name: Setup http-client-python |
| 86 | + # Generated artifacts come from the build job; downstream jobs only need the Python package installed and test tools prepared. |
| 87 | + run: | |
| 88 | + npm install --ignore-scripts --package-lock=false |
| 89 | + npm run install |
| 90 | + venv/bin/python eng/scripts/setup/prepare.py |
| 91 | + working-directory: packages/http-client-python |
| 92 | + |
| 93 | + - name: Test |
| 94 | + run: npm run test:generator -- --env=test |
| 95 | + working-directory: packages/http-client-python |
| 96 | + |
| 97 | + typecheck: |
| 98 | + name: "Type Checking" |
| 99 | + needs: build |
| 100 | + runs-on: ubuntu-latest |
| 101 | + steps: |
| 102 | + - uses: actions/checkout@v7 |
| 103 | + |
| 104 | + - uses: ./.github/actions/setup |
| 105 | + |
| 106 | + - uses: actions/setup-python@v7 |
| 107 | + with: |
| 108 | + python-version: "3.12" |
| 109 | + |
| 110 | + - name: Download generated artifacts |
| 111 | + uses: actions/download-artifact@v8 |
| 112 | + with: |
| 113 | + name: python-generated |
| 114 | + path: packages/http-client-python |
| 115 | + |
| 116 | + - name: Install repo dependencies |
| 117 | + run: pnpm install |
| 118 | + |
| 119 | + - name: Setup http-client-python |
| 120 | + # Generated artifacts come from the build job; downstream jobs only need the Python package installed and test tools prepared. |
| 121 | + run: | |
| 122 | + npm install --ignore-scripts --package-lock=false |
| 123 | + npm run install |
| 124 | + venv/bin/python eng/scripts/setup/prepare.py |
| 125 | + working-directory: packages/http-client-python |
| 126 | + |
| 127 | + - name: Mypy & Pyright |
| 128 | + run: npm run test:generator -- --env=mypy,pyright |
| 129 | + working-directory: packages/http-client-python |
| 130 | + |
| 131 | + lint: |
| 132 | + name: "Lint & Format" |
| 133 | + needs: build |
| 134 | + runs-on: ubuntu-latest |
| 135 | + steps: |
| 136 | + - uses: actions/checkout@v7 |
| 137 | + |
| 138 | + - uses: ./.github/actions/setup |
| 139 | + |
| 140 | + - uses: actions/setup-python@v7 |
| 141 | + with: |
| 142 | + python-version: "3.12" |
| 143 | + |
| 144 | + - name: Download generated artifacts |
| 145 | + uses: actions/download-artifact@v8 |
| 146 | + with: |
| 147 | + name: python-generated |
| 148 | + path: packages/http-client-python |
| 149 | + |
| 150 | + - name: Install repo dependencies |
| 151 | + run: pnpm install |
| 152 | + |
| 153 | + - name: Setup http-client-python |
| 154 | + # Generated artifacts come from the build job; downstream jobs only need the Python package installed and test tools prepared. |
| 155 | + run: | |
| 156 | + npm install --ignore-scripts --package-lock=false |
| 157 | + npm run install |
| 158 | + venv/bin/python eng/scripts/setup/prepare.py |
| 159 | + working-directory: packages/http-client-python |
| 160 | + |
| 161 | + - name: Pylint |
| 162 | + run: npm run test:generator -- --env=lint |
| 163 | + working-directory: packages/http-client-python |
| 164 | + |
| 165 | + - name: Lint source |
| 166 | + run: npm run lint |
| 167 | + working-directory: packages/http-client-python |
| 168 | + |
| 169 | + - name: Build TypeSpec Prettier plugin |
| 170 | + run: pnpm --filter "@typespec/prettier-plugin-typespec..." run build |
| 171 | + |
| 172 | + - name: Format check source |
| 173 | + run: npm run format:check |
| 174 | + working-directory: packages/http-client-python |
| 175 | + |
| 176 | + docs: |
| 177 | + name: "Docs Validation" |
| 178 | + needs: build |
| 179 | + runs-on: ubuntu-latest |
| 180 | + steps: |
| 181 | + - uses: actions/checkout@v7 |
| 182 | + |
| 183 | + - uses: ./.github/actions/setup |
| 184 | + |
| 185 | + - uses: actions/setup-python@v7 |
| 186 | + with: |
| 187 | + python-version: "3.12" |
| 188 | + |
| 189 | + - name: Download generated artifacts |
| 190 | + uses: actions/download-artifact@v8 |
| 191 | + with: |
| 192 | + name: python-generated |
| 193 | + path: packages/http-client-python |
| 194 | + |
| 195 | + - name: Install repo dependencies |
| 196 | + run: pnpm install |
| 197 | + |
| 198 | + - name: Setup http-client-python |
| 199 | + # Generated artifacts come from the build job; downstream jobs only need the Python package installed and test tools prepared. |
| 200 | + run: | |
| 201 | + npm install --ignore-scripts --package-lock=false |
| 202 | + npm run install |
| 203 | + venv/bin/python eng/scripts/setup/prepare.py |
| 204 | + working-directory: packages/http-client-python |
| 205 | + |
| 206 | + - name: API View & Sphinx |
| 207 | + run: npm run test:generator -- --env=apiview,sphinx |
| 208 | + working-directory: packages/http-client-python |
| 209 | + |
| 210 | + windows-test: |
| 211 | + name: "Build & Regenerate && Test (Windows)" |
| 212 | + runs-on: windows-latest |
| 213 | + steps: |
| 214 | + - name: Enable Git long paths |
| 215 | + run: git config --system core.longpaths true |
| 216 | + |
| 217 | + - uses: actions/checkout@v7 |
| 218 | + |
| 219 | + - uses: ./.github/actions/setup |
| 220 | + |
| 221 | + - uses: actions/setup-python@v7 |
| 222 | + with: |
| 223 | + python-version: "3.12" |
| 224 | + |
| 225 | + - name: Install repo dependencies |
| 226 | + run: pnpm install |
| 227 | + |
| 228 | + - name: Setup http-client-python |
| 229 | + # Windows validates build/regenerate/test in one job, so run the full setup instead of restoring Linux artifacts. |
| 230 | + run: | |
| 231 | + npm install --ignore-scripts --package-lock=false |
| 232 | + npm run setup |
| 233 | + .\venv\Scripts\python.exe eng\scripts\setup\prepare.py |
| 234 | + working-directory: packages/http-client-python |
| 235 | + |
| 236 | + - name: Regenerate |
| 237 | + run: npm run regenerate |
| 238 | + working-directory: packages/http-client-python |
| 239 | + |
| 240 | + - name: Test |
| 241 | + run: npm run test:generator -- --env=test |
| 242 | + working-directory: packages/http-client-python |
0 commit comments