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