Skip to content

Merge pull request #148 from ermakov-oleg/support-custom-types #647

Merge pull request #148 from ermakov-oleg/support-custom-types

Merge pull request #148 from ermakov-oleg/support-custom-types #647

Workflow file for this run

name: CI
on:
push:
tags:
- '**'
branches:
- main
- master
pull_request:
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
include:
- os: macos-latest
target: universal2-apple-darwin
name: Build on ${{ matrix.os}} ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
id: python
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: ${{ runner.os }}-python-${{ matrix.python-version }}-uv
- name: Install rust stable
id: rust-toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools
- uses: PyO3/maturin-action@v1
with:
manylinux: auto
target: ${{ matrix.target }}
rust-toolchain: stable
sccache: 'true'
args: >
--release
--sdist
--interpreter ${{ matrix.python-version }}
--out pgo-wheel
env:
RUSTFLAGS: "-Cprofile-generate=${{ github.workspace }}/target/profdata"
- name: Get rust host
run: echo RUST_HOST=$(rustc -Vv | grep host | cut -d ' ' -f 2) >> "$GITHUB_ENV"
shell: bash
- name: Generate pgo data
run: |
pip install -U uv
uv pip install -r requirements/bench.txt --python ${{ steps.python.outputs.python-path }}
uv pip install serpyco_rs --no-index --no-deps --find-links pgo-wheel --force-reinstall --python ${{ steps.python.outputs.python-path }}
# Install package deps
uv pip install serpyco_rs --find-links pgo-wheel --python ${{ steps.python.outputs.python-path }}
pytest bench -k "not mashumaro and not marshmallow and not pydantic"
rustup run stable bash -c 'echo LLVM_PROFDATA=$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/${{ env.RUST_HOST }}/bin/llvm-profdata >> "$GITHUB_ENV"'
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Merge pgo data
run: ${{ env.LLVM_PROFDATA }} merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/target/profdata
- name: Build pgo-optimized wheel
uses: PyO3/maturin-action@v1
with:
manylinux: auto
rust-toolchain: stable
command: build
target: ${{ matrix.target }}
sccache: 'true'
args: >
--release
--sdist
--interpreter ${{ matrix.python-version }}
--out dist
env:
RUSTFLAGS: "-Cprofile-use=${{ github.workspace }}/merged.profdata"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
linux-cross:
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- target: aarch64-unknown-linux-gnu
arch: aarch64
# and https://github.com/gnzlbg/jemallocator/issues/170#issuecomment-1503228963
maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16
- target: armv7-unknown-linux-gnueabihf
arch: armv7
- target: s390x-unknown-linux-gnu
arch: s390x
- target: powerpc64le-unknown-linux-gnu
arch: ppc64le
- target: powerpc64-unknown-linux-gnu
arch: ppc64
steps:
- uses: actions/checkout@v4
- name: "Build wheels"
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
manylinux: auto
docker-options: ${{ matrix.platform.maturin_docker_options }}
args: --release --sdist -o dist --interpreter 3.9 3.10 3.11 3.12
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
test:
needs: [ build ]
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: ["3.9", "3.10", "3.11", "3.12"]
name: Test on ${{ matrix.os}} ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v2
with:
name: wheels
path: wheels
- name: install dependencies
run: |
# https://github.com/astral-sh/uv/issues/2450
python -m pip install --upgrade pip nox uv==0.1.18
- name: tests
run: nox -s test
env:
CI: true
- name: lint
run: nox -s lint
env:
CI: true
- name: check types
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
run: nox -s type_check
env:
CI: true
benchmark:
needs: [ build ]
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
name: Benchmark on ${{ matrix.os}}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- uses: actions/download-artifact@v2
with:
name: wheels
path: wheels
- name: install dependencies
run: |
# https://github.com/astral-sh/uv/issues/2450
python -m pip install --upgrade pip nox uv==0.1.18
nox -s bench --no-venv --install-only
- name: bench
run: nox -s bench --no-venv --no-install
env:
CI: true
test_rc_leaks:
name: Test reference count leaks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: deadsnakes/action@v3.1.0
with:
python-version: 3.11
debug: true
- run: python3.11 --version --version && which python3.11 && python3.11 -c "import sys; print(sys.gettotalrefcount())"
- uses: PyO3/maturin-action@v1
with:
command: build
args: --release --sdist -o wheels
- name: install dependencies
run: |
# https://github.com/astral-sh/uv/issues/2450
python -m pip install --upgrade pip nox uv==0.1.18
nox -s test_rc_leaks --no-venv --install-only
- name: tests
run: nox -s test_rc_leaks --no-venv --no-install
benchmark-codespeed:
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: ubuntu-latest-python-3.12-uv
- name: set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12
cache: 'pip'
cache-dependency-path: |
requirements/*.txt
- uses: actions/download-artifact@v2
with:
name: wheels
path: wheels
- name: install dependencies
run: |
# https://github.com/astral-sh/uv/issues/2450
python -m pip install --upgrade pip nox uv==0.1.18
nox -s bench_codespeed --no-venv --install-only
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: nox -s bench_codespeed --no-venv --no-install
env:
CI: true
fmt:
name: rustfmt
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- run: cargo fmt --all -- --check
clippy:
name: clippy
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- run: cargo clippy --all-targets --all-features -- -D warnings
release:
name: release
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags')
needs: [ build, linux-cross, test ]
steps:
- uses: actions/download-artifact@v2
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --skip-existing *