Skip to content

Commit 9efbf7b

Browse files
committed
add pgo builds for release artifacts on ubuntu
1 parent 1abdc80 commit 9efbf7b

File tree

1 file changed

+100
-13
lines changed

1 file changed

+100
-13
lines changed

.github/workflows/ci.yml

Lines changed: 100 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,25 @@ jobs:
286286
jobs: ${{ toJSON(needs) }}
287287
allowed-failures: coverage
288288

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+
289304
build:
290305
name: build on ${{ matrix.platform || matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
291306
# 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')
293308
strategy:
294309
fail-fast: false
295310
matrix:
@@ -344,6 +359,11 @@ jobs:
344359
container: messense/manylinux_2_24-cross:s390x
345360
interpreter: 3.7 3.8 3.9 3.10 3.11
346361
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
347367
# Windows on arm64 only supports Python 3.11+
348368
- os: windows
349369
target: aarch64
@@ -363,14 +383,6 @@ jobs:
363383
# generate self-schema now, so we don't have to do so inside docker in maturin build
364384
- run: python generate_self_schema.py
365385

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-
374386
- name: build wheels
375387
uses: PyO3/maturin-action@v1
376388
with:
@@ -390,8 +402,83 @@ jobs:
390402
name: pypi_files
391403
path: dist
392404

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+
393480
inspect-pypi-assets:
394-
needs: [build]
481+
needs: [build, build-sdist, build-pgo]
395482
runs-on: ubuntu-latest
396483

397484
steps:
@@ -473,7 +560,7 @@ jobs:
473560
474561
test-builds-os:
475562
name: test build on ${{ matrix.os }}
476-
needs: [build]
563+
needs: [build, build-pgo]
477564

478565
strategy:
479566
fail-fast: false
@@ -501,8 +588,8 @@ jobs:
501588
- run: pytest --ignore=tests/test_docstrings.py
502589

503590
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/')
506593
runs-on: ubuntu-latest
507594

508595
steps:

0 commit comments

Comments
 (0)