forked from pydantic/pydantic
-
Notifications
You must be signed in to change notification settings - Fork 0
414 lines (335 loc) · 9.95 KB
/
ci.yml
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
name: CI
on:
push:
branches:
- master
tags:
- '**'
pull_request: {}
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v3
with:
python-version: 3.9
- uses: actions/cache@v3
id: cache
with:
path: |
${{ env.pythonLocation }}
.mypy_cache
key: >
lint
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('tests/requirements-linting.txt') }}
- name: install
if: steps.cache.outputs.cache-hit != 'true'
run: |
make install-linting
pip freeze
- name: lint
run: make lint
- name: mypy
run: make mypy
- name: make history
run: python3 ./changes/make_history.py
- name: check dist
run: make check-dist
- name: install node for pyright
uses: actions/setup-node@v3
with:
node-version: '14'
- run: npm install -g pyright
- run: make pyright
docs-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v3
with:
python-version: 3.9
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: >
docs-build
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('setup.py') }}
${{ hashFiles('requirements.txt') }}
${{ hashFiles('docs/requirements.txt') }}
- name: install
if: steps.cache.outputs.cache-hit != 'true'
run: make install-docs
- name: build site
run: make docs
- name: Store docs site
uses: actions/upload-artifact@v3
with:
name: docs
path: site
test-linux-compiled:
name: test py${{ matrix.python-version }} on linux compiled
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
env:
PYTHON: ${{ matrix.python-version }}
OS: ubuntu
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: >
test-linux-compiled
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('setup.py') }}
${{ hashFiles('requirements.txt') }}
${{ hashFiles('tests/requirements-testing.txt') }}
- name: install
run: make install-testing
- name: compile
run: |
make build-trace
python -c "import sys, pydantic; print('compiled:', pydantic.compiled); sys.exit(0 if pydantic.compiled else 1)"
ls -alh
ls -alh pydantic/
- run: mkdir coverage
- name: test
run: make test
env:
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-compiled
CONTEXT: linux-py${{ matrix.python-version }}-compiled
- name: store coverage files
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
test-not-compiled:
name: test py${{ matrix.python-version }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: ['3.7', '3.8', '3.9', '3.10']
include:
- os: ubuntu
env:
PYTHON: ${{ matrix.python-version }}
OS: ${{ matrix.os }}
COMPILED: no
DEPS: yes
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: >
test-not-compiled
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('setup.py') }}
${{ hashFiles('requirements.txt') }}
${{ hashFiles('tests/requirements-testing.txt') }}
- name: install
run: make install-testing
- run: pip freeze
- run: mkdir coverage
- name: test with deps
run: make test
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-with-deps
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-with-deps
- name: uninstall deps
run: pip uninstall -y cython email-validator devtools python-dotenv
- name: test without deps
run: make test
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-without-deps
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-without-deps
- name: store coverage files
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
test-old-mypy:
name: test mypy v${{ matrix.mypy-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mypy-version: ['0.910', '0.921', '0.931', '0.942', '0.950']
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: install
run: |
make install-testing
pip freeze
- name: uninstall deps
run: pip uninstall -y mypy tomli toml
- name: install specific mypy version
run: pip install mypy==${{ matrix.mypy-version }}
- run: mkdir coverage
- name: run tests
run: pytest --cov=pydantic tests/mypy
env:
COVERAGE_FILE: coverage/.coverage.linux-py3.10-mypy${{ matrix.mypy-version }}
CONTEXT: linux-py3.10-mypy${{ matrix.mypy-version }}
- name: store coverage files
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
coverage-combine:
needs: [test-linux-compiled, test-not-compiled, test-old-mypy]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.8'
- name: get coverage files
uses: actions/download-artifact@v3
with:
name: coverage
path: coverage
- run: pip install coverage
- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --show-contexts
- name: Store coverage html
uses: actions/upload-artifact@v3
with:
name: coverage-html
path: htmlcov
test-fastapi:
name: test fastAPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: install
run: make install-testing
- name: test
run: make test-fastapi
build:
name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
needs: [lint, test-linux-compiled, test-not-compiled, test-old-mypy, test-fastapi]
if: "success() && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master')"
strategy:
fail-fast: false
matrix:
os: [ubuntu , macos , windows]
python-version: ['7', '8', '9', '10']
include:
- os: ubuntu
platform: linux
- os: windows
ls: dir
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v3
with:
python-version: '3.8'
- name: install
run: pip install -U twine setuptools wheel cibuildwheel
- name: build sdist
if: matrix.os == 'ubuntu' && matrix.python-version == '9'
run: python setup.py sdist bdist_wheel
env:
SKIP_CYTHON: 1
- name: build ${{ matrix.platform || matrix.os }} binaries
run: cibuildwheel --output-dir dist
env:
PIP: 'pip'
CIBW_BUILD: 'cp3${{ matrix.python-version }}-*'
CIBW_SKIP: '*-win32'
CIBW_PLATFORM: '${{ matrix.platform || matrix.os }}'
CIBW_BEFORE_BUILD: 'pip install -U cython'
CIBW_TEST_REQUIRES: 'pytest==6.2.5 pytest-mock==3.6.1'
CIBW_TEST_COMMAND: 'pytest {project}/tests'
CIBW_MANYLINUX_X86_64_IMAGE: 'manylinux2014'
CIBW_MANYLINUX_I686_IMAGE: 'manylinux2014'
CIBW_ARCHS_MACOS: 'x86_64 arm64'
CIBW_TEST_SKIP: '*-macosx_arm64' # see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2
# TODO build windows 32bit binaries
- name: list dist files
run: |
${{ matrix.ls || 'ls -lh' }} dist/
twine check dist/*
- name: Store dist artifacts
uses: actions/upload-artifact@v3
with:
name: pypi_files
path: dist
deploy:
name: Deploy
needs: build
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v3
with:
python-version: '3.8'
- name: get dist artifacts
uses: actions/download-artifact@v3
with:
name: pypi_files
path: dist
- name: get docs
uses: actions/download-artifact@v3
with:
name: docs
path: site
- name: install
run: |
make install-docs
pip install -U twine
- name: twine check
run: |
twine check dist/*
ls -lh dist
- name: check tag
run: ./tests/check_tag.py
- name: upload to pypi
run: twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_token }}
- name: publish docs
run: make publish-docs
env:
NETLIFY: ${{ secrets.netlify_token }}