Skip to content

Commit 0211dd3

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 0211dd3

2 files changed

Lines changed: 274 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: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
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 install --ignore-scripts
51+
npm run build
52+
npm pack
53+
54+
- name: Override http-client-python with PR version
55+
run: |
56+
HCP_TGZ=$(ls core/packages/http-client-python/typespec-http-client-python-*.tgz)
57+
node -e '
58+
const pkg = require("./packages/typespec-python/package.json");
59+
const fs = require("fs");
60+
pkg.dependencies["@typespec/http-client-python"] = "file:../../" + process.argv[1];
61+
fs.writeFileSync("./packages/typespec-python/package.json", JSON.stringify(pkg, null, 2) + "\n");
62+
' "$HCP_TGZ"
63+
64+
- name: Install dependencies
65+
run: pnpm install --no-frozen-lockfile
66+
67+
- name: Build
68+
run: pnpm turbo run --filter "@azure-tools/typespec-python..." build
69+
70+
- name: Prepare Python environment
71+
run: pnpm run prepare
72+
working-directory: packages/typespec-python
73+
74+
- name: Regenerate
75+
run: pnpm run regenerate
76+
working-directory: packages/typespec-python
77+
78+
- name: Pre-build wheels
79+
working-directory: packages/typespec-python
80+
run: |
81+
venv/bin/python tests/install_packages.py build azure tests
82+
venv/bin/python tests/install_packages.py build unbranded tests
83+
84+
- name: Upload generated artifacts
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: python-generated
88+
path: |
89+
packages/typespec-python/tests/generated
90+
packages/typespec-python/tests/.wheels
91+
packages/typespec-python/dist
92+
packages/typespec-python/package.json
93+
core/packages/http-client-python/typespec-http-client-python-*.tgz
94+
core/packages/spector/dist
95+
core/packages/http-specs/dist
96+
packages/azure-http-specs/dist
97+
retention-days: 1
98+
99+
test:
100+
name: "Mock API Tests"
101+
needs: build
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v6
105+
with:
106+
repository: Azure/typespec-azure
107+
submodules: recursive
108+
109+
- name: Update core submodule to PR commit
110+
if: github.event_name == 'pull_request'
111+
run: |
112+
cd core
113+
git remote add pr https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
114+
git fetch pr ${{ github.event.pull_request.head.sha }}
115+
git checkout ${{ github.event.pull_request.head.sha }}
116+
117+
- uses: ./.github/actions/setup
118+
119+
- uses: ./.github/actions/setup-python
120+
121+
- name: Download generated artifacts
122+
uses: actions/download-artifact@v4
123+
with:
124+
name: python-generated
125+
path: .
126+
127+
- name: Install dependencies
128+
run: pnpm install --no-frozen-lockfile
129+
130+
- name: Build spector and specs
131+
run: |
132+
pnpm turbo run --filter "@typespec/spector..." build
133+
pnpm --filter "@typespec/http-specs" exec tsc -p ./tsconfig.build.json
134+
pnpm --filter "@azure-tools/azure-http-specs" exec tsc -p ./tsconfig.build.json
135+
136+
- name: Prepare Python environment
137+
run: pnpm run prepare
138+
working-directory: packages/typespec-python
139+
140+
- name: Test
141+
run: pnpm run test:python:e2e
142+
working-directory: packages/typespec-python
143+
144+
typecheck:
145+
name: "Type Checking"
146+
needs: build
147+
runs-on: ubuntu-latest
148+
steps:
149+
- uses: actions/checkout@v6
150+
with:
151+
repository: Azure/typespec-azure
152+
submodules: recursive
153+
154+
- name: Update core submodule to PR commit
155+
if: github.event_name == 'pull_request'
156+
run: |
157+
cd core
158+
git remote add pr https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
159+
git fetch pr ${{ github.event.pull_request.head.sha }}
160+
git checkout ${{ github.event.pull_request.head.sha }}
161+
162+
- uses: ./.github/actions/setup
163+
164+
- uses: ./.github/actions/setup-python
165+
166+
- name: Download generated artifacts
167+
uses: actions/download-artifact@v4
168+
with:
169+
name: python-generated
170+
path: .
171+
172+
- name: Install dependencies
173+
run: pnpm install --no-frozen-lockfile --filter "@azure-tools/typespec-python..."
174+
175+
- name: Prepare Python environment
176+
run: pnpm run prepare
177+
working-directory: packages/typespec-python
178+
179+
- name: Mypy & Pyright
180+
run: pnpm run test:python:e2e --env mypy,pyright
181+
working-directory: packages/typespec-python
182+
183+
lint:
184+
name: "Lint & Format"
185+
needs: build
186+
runs-on: ubuntu-latest
187+
steps:
188+
- uses: actions/checkout@v6
189+
with:
190+
repository: Azure/typespec-azure
191+
submodules: recursive
192+
193+
- name: Update core submodule to PR commit
194+
if: github.event_name == 'pull_request'
195+
run: |
196+
cd core
197+
git remote add pr https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
198+
git fetch pr ${{ github.event.pull_request.head.sha }}
199+
git checkout ${{ github.event.pull_request.head.sha }}
200+
201+
- uses: ./.github/actions/setup
202+
203+
- uses: ./.github/actions/setup-python
204+
205+
- name: Download generated artifacts
206+
uses: actions/download-artifact@v4
207+
with:
208+
name: python-generated
209+
path: .
210+
211+
- name: Install dependencies
212+
run: pnpm install --no-frozen-lockfile --filter "@azure-tools/typespec-python..."
213+
214+
- name: Prepare Python environment
215+
run: pnpm run prepare
216+
working-directory: packages/typespec-python
217+
218+
- name: Pylint
219+
run: pnpm run test:python:e2e --env lint
220+
working-directory: packages/typespec-python
221+
222+
- name: Lint (extra)
223+
run: pnpm run lint:extra
224+
working-directory: packages/typespec-python
225+
226+
- name: Format check (extra)
227+
run: pnpm run format:extra:check
228+
working-directory: packages/typespec-python
229+
230+
docs:
231+
name: "Docs Validation"
232+
needs: build
233+
runs-on: ubuntu-latest
234+
steps:
235+
- uses: actions/checkout@v6
236+
with:
237+
repository: Azure/typespec-azure
238+
submodules: recursive
239+
240+
- name: Update core submodule to PR commit
241+
if: github.event_name == 'pull_request'
242+
run: |
243+
cd core
244+
git remote add pr https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
245+
git fetch pr ${{ github.event.pull_request.head.sha }}
246+
git checkout ${{ github.event.pull_request.head.sha }}
247+
248+
- uses: ./.github/actions/setup
249+
250+
- uses: ./.github/actions/setup-python
251+
252+
- name: Download generated artifacts
253+
uses: actions/download-artifact@v4
254+
with:
255+
name: python-generated
256+
path: .
257+
258+
- name: Install dependencies
259+
run: pnpm install --no-frozen-lockfile --filter "@azure-tools/typespec-python..."
260+
261+
- name: Prepare Python environment
262+
run: pnpm run prepare
263+
working-directory: packages/typespec-python
264+
265+
- name: API View & Sphinx
266+
run: pnpm run test:python:e2e --env apiview,sphinx
267+
working-directory: packages/typespec-python

0 commit comments

Comments
 (0)