|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `test-python-coverage`/`test-python` jobs of |
| 5 | +# https://github.com/pydantic/monty/blob/v0.0.21/.github/workflows/ci.yml |
| 6 | +name: Build pydantic-monty-client wheels (riscv64) |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'pydantic-monty-client version to build (git tag, e.g. v0.0.21)' |
| 13 | + required: true |
| 14 | + default: 'v0.0.21' |
| 15 | + pull_request: |
| 16 | + paths: |
| 17 | + - '.github/workflows/build-pydantic-monty-client.yml' |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ inputs.version || 'v0.0.21' }}-${{ github.head_ref || github.run_id }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read # to fetch code (actions/checkout) |
| 25 | + |
| 26 | +env: |
| 27 | + # `inputs.version` is empty on pull_request events; default to v0.0.21 there. |
| 28 | + MONTY_VERSION: ${{ inputs.version || 'v0.0.21' }} |
| 29 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 30 | + |
| 31 | +jobs: |
| 32 | + setup: |
| 33 | + uses: $/.github/workflows/_setup.yml |
| 34 | + |
| 35 | + build_wheels: |
| 36 | + needs: [setup] |
| 37 | + name: Build pydantic-monty-client ${{ inputs.version || 'v0.0.21' }} ${{ matrix.python }}-manylinux_riscv64 |
| 38 | + runs-on: ubuntu-24.04-riscv |
| 39 | + timeout-minutes: 360 |
| 40 | + strategy: |
| 41 | + fail-fast: false |
| 42 | + matrix: |
| 43 | + # No abi3 feature on pyo3 in Cargo.toml, so upstream ships one wheel |
| 44 | + # per interpreter (matches PyPI's cp3xx-cp3xx tags). |
| 45 | + python: ["cp312", "cp313", "cp314", "cp314t"] |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Checkout monty ${{ env.MONTY_VERSION }} |
| 49 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 50 | + with: |
| 51 | + repository: pydantic/monty |
| 52 | + ref: ${{ env.MONTY_VERSION }} |
| 53 | + persist-credentials: false |
| 54 | + |
| 55 | + # `crates/monty-python`'s pyproject.toml has no `license-files`, so |
| 56 | + # maturin's default LICEN[CS]E* glob only looks next to it -- the repo's |
| 57 | + # actual LICENSE lives at the workspace root (gotcha 146). Upstream's own |
| 58 | + # published wheel has the same gap (no LICENSE in its dist-info); copy it |
| 59 | + # in so ours doesn't. |
| 60 | + - name: Copy LICENSE next to the crate's pyproject.toml |
| 61 | + run: cp LICENSE crates/monty-python/LICENSE |
| 62 | + |
| 63 | + - name: Build wheels |
| 64 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 65 | + with: |
| 66 | + package-dir: crates/monty-python |
| 67 | + output-dir: wheelhouse/ |
| 68 | + env: |
| 69 | + CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64 |
| 70 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 71 | + # monty ships no [tool.cibuildwheel]: install the Rust toolchain, |
| 72 | + # then build the `monty` worker binary the test suite spawns as a |
| 73 | + # subprocess (mirrors upstream's own `maturin develop -m |
| 74 | + # crates/monty-runtime/Cargo.toml` step ahead of `pytest`). |
| 75 | + CIBW_BEFORE_ALL_LINUX: >- |
| 76 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && |
| 77 | + PATH="$PATH:$HOME/.cargo/bin" cargo build --release --locked -p monty-runtime && |
| 78 | + cp target/release/monty /usr/local/bin/monty |
| 79 | + # `tests/test_threading.py` skips itself under `'CI' in os.environ` |
| 80 | + # (its own comment: GitHub-hosted runners have one CPU) -- cibuildwheel |
| 81 | + # does not forward the host's `CI` var into the container, so without |
| 82 | + # this the timing-sensitive module runs and flakes on a shared runner. |
| 83 | + CIBW_ENVIRONMENT_LINUX: PATH="$PATH:$HOME/.cargo/bin" CI=true |
| 84 | + CIBW_TEST_REQUIRES: >- |
| 85 | + anyio>=4.0 dirty-equals>=0.11 inline-snapshot>=0.31.1 |
| 86 | + pytest>=9.0.2 pytest-pretty>=1.3.0 |
| 87 | + CIBW_TEST_SOURCES: crates/monty-python/tests crates/monty-python/pyproject.toml |
| 88 | + # test_readme_examples.py needs `ruff` (via pytest-examples) and |
| 89 | + # test_websocket.py needs `websockets`; neither has a riscv64 wheel |
| 90 | + # on this registry and porting them is out of scope here. |
| 91 | + CIBW_TEST_COMMAND: >- |
| 92 | + python -c "import pydantic_monty._monty as n; assert n.__file__.endswith('.so'), n.__file__" && |
| 93 | + python -m pytest -v crates/monty-python/tests |
| 94 | + --ignore=crates/monty-python/tests/test_readme_examples.py |
| 95 | + --ignore=crates/monty-python/tests/test_websocket.py |
| 96 | +
|
| 97 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 98 | + with: |
| 99 | + name: pydantic-monty-client-${{ env.MONTY_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 100 | + path: wheelhouse/*.whl |
| 101 | + if-no-files-found: error |
| 102 | + |
| 103 | + publish: |
| 104 | + name: Publish pydantic-monty-client ${{ inputs.version || 'v0.0.21' }} |
| 105 | + needs: [setup, build_wheels] |
| 106 | + permissions: |
| 107 | + contents: write |
| 108 | + pull-requests: write |
| 109 | + uses: $/.github/workflows/_publish-wheel.yml |
| 110 | + with: |
| 111 | + artifact-pattern: pydantic-monty-client-${{ inputs.version || 'v0.0.21' }}-*-manylinux_riscv64 |
0 commit comments