@@ -286,10 +286,25 @@ jobs:
286
286
jobs : ${{ toJSON(needs) }}
287
287
allowed-failures : coverage
288
288
289
+ build-sdist :
290
+ name : build sdist
291
+ runs-on : ubuntu-latest
292
+ steps :
293
+ - uses : actions/checkout@v3
294
+ - uses : PyO3/maturin-action@v1
295
+ with :
296
+ command : sdist
297
+ args : --out dist
298
+ rust-toolchain : stable
299
+ - uses : actions/upload-artifact@v3
300
+ with :
301
+ name : pypi_files
302
+ path : dist
303
+
289
304
build :
290
305
name : build on ${{ matrix.platform || matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
291
306
# only run on push to main and on release
292
- if : " success() && ( startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')) "
307
+ if : startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')
293
308
strategy :
294
309
fail-fast : false
295
310
matrix :
@@ -344,6 +359,11 @@ jobs:
344
359
container : messense/manylinux_2_24-cross:s390x
345
360
interpreter : 3.7 3.8 3.9 3.10 3.11
346
361
exclude :
362
+ # Optimized PGO builds for manylinux follow a different matrix, maybe in future
363
+ # maturin-action can support this automatically
364
+ - os : ubuntu
365
+ target : x86_64
366
+ manylinux : auto
347
367
# Windows on arm64 only supports Python 3.11+
348
368
- os : windows
349
369
target : aarch64
@@ -363,14 +383,6 @@ jobs:
363
383
# generate self-schema now, so we don't have to do so inside docker in maturin build
364
384
- run : python generate_self_schema.py
365
385
366
- - name : build sdist
367
- if : ${{ matrix.os == 'ubuntu' && matrix.target == 'x86_64' && matrix.manylinux == 'auto' }}
368
- uses : PyO3/maturin-action@v1
369
- with :
370
- command : sdist
371
- args : --out dist
372
- rust-toolchain : stable
373
-
374
386
- name : build wheels
375
387
uses : PyO3/maturin-action@v1
376
388
with :
@@ -390,8 +402,83 @@ jobs:
390
402
name : pypi_files
391
403
path : dist
392
404
405
+ build-pgo :
406
+ name : build pgo-optimized on ${{ matrix.platform || matrix.os }} (${{ matrix.interpreter}} - ${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
407
+ # only run on push to main and on release
408
+ if : startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')
409
+ strategy :
410
+ fail-fast : false
411
+ matrix :
412
+ os : [ubuntu]
413
+ platform : [linux]
414
+ target : [x86_64]
415
+ manylinux : [auto]
416
+ interpreter : ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7", "pypy3.8", "pypy3.9"]
417
+
418
+ runs-on : ${{ matrix.os }}-latest
419
+ steps :
420
+ - uses : actions/checkout@v3
421
+
422
+ - name : set up python
423
+ uses : actions/setup-python@v4
424
+ with :
425
+ python-version : ${{ matrix.interpreter }}
426
+ architecture : ${{ matrix.python-architecture || 'x64' }}
427
+
428
+ - name : install rust stable
429
+ id : rust-toolchain
430
+ uses : dtolnay/rust-toolchain@stable
431
+ with :
432
+ components : llvm-tools
433
+
434
+ - run : pip install -U 'black>=22.3.0,<23' typing_extensions
435
+
436
+ # generate self-schema now, so we don't have to do so inside docker in maturin build
437
+ - run : python generate_self_schema.py
438
+
439
+ - name : build initial wheel
440
+ uses : PyO3/maturin-action@v1
441
+ with :
442
+ target : ${{ matrix.target }}
443
+ manylinux : ${{ matrix.manylinux || 'auto' }}
444
+ args : >
445
+ --release
446
+ --out pgo-wheel
447
+ --interpreter ${{ matrix.interpreter }}
448
+ -- -Cprofile-generate=${{ github.workspace }}/profdata
449
+ rust-toolchain : stable
450
+ docker-options : -e CI
451
+
452
+ - name : generate pgo data
453
+ run : |
454
+ pip install -U pip
455
+ pip install -r tests/requirements.txt
456
+ pip install pydantic-core --no-index --no-deps --find-links pgo-wheel --force-reinstall
457
+ pytest
458
+ rustup run stable bash -c '$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata'
459
+
460
+ - name : build pgo-optimized wheel
461
+ uses : PyO3/maturin-action@v1
462
+ with :
463
+ target : ${{ matrix.target }}
464
+ manylinux : ${{ matrix.manylinux || 'auto' }}
465
+ args : >
466
+ --release
467
+ --out dist
468
+ --interpreter ${{ matrix.interpreter }}
469
+ -- -Cprofile-use=${{ github.workspace }}/merged.profdata
470
+ rust-toolchain : stable
471
+ docker-options : -e CI
472
+
473
+ - run : ${{ matrix.ls || 'ls -lh' }} dist/
474
+
475
+ - uses : actions/upload-artifact@v3
476
+ with :
477
+ name : pypi_files
478
+ path : dist
479
+
393
480
inspect-pypi-assets :
394
- needs : [build]
481
+ needs : [build, build-sdist, build-pgo ]
395
482
runs-on : ubuntu-latest
396
483
397
484
steps :
@@ -473,7 +560,7 @@ jobs:
473
560
474
561
test-builds-os :
475
562
name : test build on ${{ matrix.os }}
476
- needs : [build]
563
+ needs : [build, build-pgo ]
477
564
478
565
strategy :
479
566
fail-fast : false
@@ -501,8 +588,8 @@ jobs:
501
588
- run : pytest --ignore=tests/test_docstrings.py
502
589
503
590
release :
504
- needs : [test-builds-arch, test-builds-os, check]
505
- if : " success() && startsWith(github.ref, 'refs/tags/')"
591
+ needs : [test-builds-arch, test-builds-os, build-sdist, check]
592
+ if : success() && startsWith(github.ref, 'refs/tags/')
506
593
runs-on : ubuntu-latest
507
594
508
595
steps :
0 commit comments