Skip to content

Commit ff06f0f

Browse files
iscai-msftCopilot
andcommitted
ci: add Python-specific integration workflow for branded emitter testing
Create python-integration.yml that triggers on http-client-python changes and runs the full typespec-azure branded Python e2e test suite: - Build & Regenerate - Mock API Tests - Type Checking (mypy, pyright) - Lint & Format (pylint, lint:extra, format:extra:check) - Docs Validation (apiview, sphinx) The workflow checks out Azure/typespec-azure, patches the core submodule to the PR commit, builds and packs http-client-python locally, then overrides typespec-python's dependency to use the PR version instead of the published npm version. This ensures tests validate the actual PR changes, not the last release. Reuses typespec-azure's composite actions for environment consistency. external-integration.yml is unchanged — http-client-python stays in paths-ignore since this dedicated workflow provides full Python coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d05ce00 commit ff06f0f

2 files changed

Lines changed: 273 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: internal
3+
packages:
4+
- "@typespec/http-client-python"
5+
---
6+
7+
Add Python-specific integration workflow to test branded emitter (typespec-python) when unbranded emitter changes are made
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
name: Python Integration
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
paths:
7+
- "packages/http-client-python/**"
8+
- ".github/workflows/python-integration.yml"
9+
# Allow manual triggering
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
build:
21+
name: "Build & Regenerate"
22+
runs-on: ubuntu-latest
23+
if: |
24+
!startsWith(github.head_ref, 'dependabot/') &&
25+
!startsWith(github.head_ref, 'publish/') &&
26+
!startsWith(github.head_ref, 'backmerge/') &&
27+
!startsWith(github.head_ref, 'revert-')
28+
steps:
29+
- name: Checkout Azure/typespec-azure repo
30+
uses: actions/checkout@v6
31+
with:
32+
repository: Azure/typespec-azure
33+
submodules: recursive
34+
35+
- name: Update core submodule to PR commit
36+
if: github.event_name == 'pull_request'
37+
run: |
38+
cd core
39+
git remote add pr https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
40+
git fetch pr ${{ github.event.pull_request.head.sha }}
41+
git checkout ${{ github.event.pull_request.head.sha }}
42+
43+
- uses: ./.github/actions/setup
44+
45+
- uses: ./.github/actions/setup-python
46+
47+
- name: Build and pack http-client-python from PR
48+
run: |
49+
cd core/packages/http-client-python
50+
npm run build
51+
npm pack
52+
53+
- name: Override http-client-python with PR version
54+
run: |
55+
HCP_TGZ=$(ls core/packages/http-client-python/typespec-http-client-python-*.tgz)
56+
node -e "
57+
const pkg = require('./packages/typespec-python/package.json');
58+
const fs = require('fs');
59+
pkg.dependencies['@typespec/http-client-python'] = 'file:../../${process.argv[1]}';
60+
fs.writeFileSync('./packages/typespec-python/package.json', JSON.stringify(pkg, null, 2) + '\n');
61+
" "$HCP_TGZ"
62+
63+
- name: Install dependencies
64+
run: pnpm install --no-frozen-lockfile
65+
66+
- name: Build
67+
run: pnpm turbo run --filter "@azure-tools/typespec-python..." build
68+
69+
- name: Prepare Python environment
70+
run: pnpm run prepare
71+
working-directory: packages/typespec-python
72+
73+
- name: Regenerate
74+
run: pnpm run regenerate
75+
working-directory: packages/typespec-python
76+
77+
- name: Pre-build wheels
78+
working-directory: packages/typespec-python
79+
run: |
80+
venv/bin/python tests/install_packages.py build azure tests
81+
venv/bin/python tests/install_packages.py build unbranded tests
82+
83+
- name: Upload generated artifacts
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: python-generated
87+
path: |
88+
packages/typespec-python/tests/generated
89+
packages/typespec-python/tests/.wheels
90+
packages/typespec-python/dist
91+
packages/typespec-python/package.json
92+
core/packages/http-client-python/typespec-http-client-python-*.tgz
93+
core/packages/spector/dist
94+
core/packages/http-specs/dist
95+
packages/azure-http-specs/dist
96+
retention-days: 1
97+
98+
test:
99+
name: "Mock API Tests"
100+
needs: build
101+
runs-on: ubuntu-latest
102+
steps:
103+
- uses: actions/checkout@v6
104+
with:
105+
repository: Azure/typespec-azure
106+
submodules: recursive
107+
108+
- name: Update core submodule to PR commit
109+
if: github.event_name == 'pull_request'
110+
run: |
111+
cd core
112+
git remote add pr https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
113+
git fetch pr ${{ github.event.pull_request.head.sha }}
114+
git checkout ${{ github.event.pull_request.head.sha }}
115+
116+
- uses: ./.github/actions/setup
117+
118+
- uses: ./.github/actions/setup-python
119+
120+
- name: Download generated artifacts
121+
uses: actions/download-artifact@v4
122+
with:
123+
name: python-generated
124+
path: .
125+
126+
- name: Install dependencies
127+
run: pnpm install --no-frozen-lockfile
128+
129+
- name: Build spector and specs
130+
run: |
131+
pnpm turbo run --filter "@typespec/spector..." build
132+
pnpm --filter "@typespec/http-specs" exec tsc -p ./tsconfig.build.json
133+
pnpm --filter "@azure-tools/azure-http-specs" exec tsc -p ./tsconfig.build.json
134+
135+
- name: Prepare Python environment
136+
run: pnpm run prepare
137+
working-directory: packages/typespec-python
138+
139+
- name: Test
140+
run: pnpm run test:python:e2e
141+
working-directory: packages/typespec-python
142+
143+
typecheck:
144+
name: "Type Checking"
145+
needs: build
146+
runs-on: ubuntu-latest
147+
steps:
148+
- uses: actions/checkout@v6
149+
with:
150+
repository: Azure/typespec-azure
151+
submodules: recursive
152+
153+
- name: Update core submodule to PR commit
154+
if: github.event_name == 'pull_request'
155+
run: |
156+
cd core
157+
git remote add pr https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
158+
git fetch pr ${{ github.event.pull_request.head.sha }}
159+
git checkout ${{ github.event.pull_request.head.sha }}
160+
161+
- uses: ./.github/actions/setup
162+
163+
- uses: ./.github/actions/setup-python
164+
165+
- name: Download generated artifacts
166+
uses: actions/download-artifact@v4
167+
with:
168+
name: python-generated
169+
path: .
170+
171+
- name: Install dependencies
172+
run: pnpm install --filter "@azure-tools/typespec-python..."
173+
174+
- name: Prepare Python environment
175+
run: pnpm run prepare
176+
working-directory: packages/typespec-python
177+
178+
- name: Mypy & Pyright
179+
run: pnpm run test:python:e2e --env mypy,pyright
180+
working-directory: packages/typespec-python
181+
182+
lint:
183+
name: "Lint & Format"
184+
needs: build
185+
runs-on: ubuntu-latest
186+
steps:
187+
- uses: actions/checkout@v6
188+
with:
189+
repository: Azure/typespec-azure
190+
submodules: recursive
191+
192+
- name: Update core submodule to PR commit
193+
if: github.event_name == 'pull_request'
194+
run: |
195+
cd core
196+
git remote add pr https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
197+
git fetch pr ${{ github.event.pull_request.head.sha }}
198+
git checkout ${{ github.event.pull_request.head.sha }}
199+
200+
- uses: ./.github/actions/setup
201+
202+
- uses: ./.github/actions/setup-python
203+
204+
- name: Download generated artifacts
205+
uses: actions/download-artifact@v4
206+
with:
207+
name: python-generated
208+
path: .
209+
210+
- name: Install dependencies
211+
run: pnpm install --filter "@azure-tools/typespec-python..."
212+
213+
- name: Prepare Python environment
214+
run: pnpm run prepare
215+
working-directory: packages/typespec-python
216+
217+
- name: Pylint
218+
run: pnpm run test:python:e2e --env lint
219+
working-directory: packages/typespec-python
220+
221+
- name: Lint (extra)
222+
run: pnpm run lint:extra
223+
working-directory: packages/typespec-python
224+
225+
- name: Format check (extra)
226+
run: pnpm run format:extra:check
227+
working-directory: packages/typespec-python
228+
229+
docs:
230+
name: "Docs Validation"
231+
needs: build
232+
runs-on: ubuntu-latest
233+
steps:
234+
- uses: actions/checkout@v6
235+
with:
236+
repository: Azure/typespec-azure
237+
submodules: recursive
238+
239+
- name: Update core submodule to PR commit
240+
if: github.event_name == 'pull_request'
241+
run: |
242+
cd core
243+
git remote add pr https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
244+
git fetch pr ${{ github.event.pull_request.head.sha }}
245+
git checkout ${{ github.event.pull_request.head.sha }}
246+
247+
- uses: ./.github/actions/setup
248+
249+
- uses: ./.github/actions/setup-python
250+
251+
- name: Download generated artifacts
252+
uses: actions/download-artifact@v4
253+
with:
254+
name: python-generated
255+
path: .
256+
257+
- name: Install dependencies
258+
run: pnpm install --filter "@azure-tools/typespec-python..."
259+
260+
- name: Prepare Python environment
261+
run: pnpm run prepare
262+
working-directory: packages/typespec-python
263+
264+
- name: API View & Sphinx
265+
run: pnpm run test:python:e2e --env apiview,sphinx
266+
working-directory: packages/typespec-python

0 commit comments

Comments
 (0)