From 1159eea177aa63bae2ee7eaec8d2163ca9d80640 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 10 Sep 2026 06:38:05 +0200 Subject: [PATCH] pydantic-monty-client: add build-pydantic-monty-client.yml for riscv64 wheels --- .../workflows/build-pydantic-monty-client.yml | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .github/workflows/build-pydantic-monty-client.yml diff --git a/.github/workflows/build-pydantic-monty-client.yml b/.github/workflows/build-pydantic-monty-client.yml new file mode 100644 index 000000000..eee0a22bf --- /dev/null +++ b/.github/workflows/build-pydantic-monty-client.yml @@ -0,0 +1,111 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on the `test-python-coverage`/`test-python` jobs of +# https://github.com/pydantic/monty/blob/v0.0.21/.github/workflows/ci.yml +name: Build pydantic-monty-client wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'pydantic-monty-client version to build (git tag, e.g. v0.0.21)' + required: true + default: 'v0.0.21' + pull_request: + paths: + - '.github/workflows/build-pydantic-monty-client.yml' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || 'v0.0.21' }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + # `inputs.version` is empty on pull_request events; default to v0.0.21 there. + MONTY_VERSION: ${{ inputs.version || 'v0.0.21' }} + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + + build_wheels: + needs: [setup] + name: Build pydantic-monty-client ${{ inputs.version || 'v0.0.21' }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 360 + strategy: + fail-fast: false + matrix: + # No abi3 feature on pyo3 in Cargo.toml, so upstream ships one wheel + # per interpreter (matches PyPI's cp3xx-cp3xx tags). + python: ["cp312", "cp313", "cp314", "cp314t"] + + steps: + - name: Checkout monty ${{ env.MONTY_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: pydantic/monty + ref: ${{ env.MONTY_VERSION }} + persist-credentials: false + + # `crates/monty-python`'s pyproject.toml has no `license-files`, so + # maturin's default LICEN[CS]E* glob only looks next to it -- the repo's + # actual LICENSE lives at the workspace root (gotcha 146). Upstream's own + # published wheel has the same gap (no LICENSE in its dist-info); copy it + # in so ours doesn't. + - name: Copy LICENSE next to the crate's pyproject.toml + run: cp LICENSE crates/monty-python/LICENSE + + - name: Build wheels + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + package-dir: crates/monty-python + output-dir: wheelhouse/ + env: + CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64 + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # monty ships no [tool.cibuildwheel]: install the Rust toolchain, + # then build the `monty` worker binary the test suite spawns as a + # subprocess (mirrors upstream's own `maturin develop -m + # crates/monty-runtime/Cargo.toml` step ahead of `pytest`). + CIBW_BEFORE_ALL_LINUX: >- + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && + PATH="$PATH:$HOME/.cargo/bin" cargo build --release --locked -p monty-runtime && + cp target/release/monty /usr/local/bin/monty + # `tests/test_threading.py` skips itself under `'CI' in os.environ` + # (its own comment: GitHub-hosted runners have one CPU) -- cibuildwheel + # does not forward the host's `CI` var into the container, so without + # this the timing-sensitive module runs and flakes on a shared runner. + CIBW_ENVIRONMENT_LINUX: PATH="$PATH:$HOME/.cargo/bin" CI=true + CIBW_TEST_REQUIRES: >- + anyio>=4.0 dirty-equals>=0.11 inline-snapshot>=0.31.1 + pytest>=9.0.2 pytest-pretty>=1.3.0 + CIBW_TEST_SOURCES: crates/monty-python/tests crates/monty-python/pyproject.toml + # test_readme_examples.py needs `ruff` (via pytest-examples) and + # test_websocket.py needs `websockets`; neither has a riscv64 wheel + # on this registry and porting them is out of scope here. + CIBW_TEST_COMMAND: >- + python -c "import pydantic_monty._monty as n; assert n.__file__.endswith('.so'), n.__file__" && + python -m pytest -v crates/monty-python/tests + --ignore=crates/monty-python/tests/test_readme_examples.py + --ignore=crates/monty-python/tests/test_websocket.py + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: pydantic-monty-client-${{ env.MONTY_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish pydantic-monty-client ${{ inputs.version || 'v0.0.21' }} + needs: [setup, build_wheels] + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + with: + artifact-pattern: pydantic-monty-client-${{ inputs.version || 'v0.0.21' }}-*-manylinux_riscv64