Skip to content

Build protovalidate wheels (riscv64) #3

Build protovalidate wheels (riscv64)

Build protovalidate wheels (riscv64) #3

# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on the `ext-linux` job of
# https://github.com/bufbuild/protovalidate-py/blob/v2.0.0/.github/workflows/release.yaml
name: Build protovalidate wheels (riscv64)
on:
workflow_dispatch:
inputs:
version:
description: 'protovalidate version to build (git tag without the leading v, e.g. 2.0.0)'
required: true
default: '2.0.0'
pull_request:
paths:
- '.github/workflows/build-protovalidate.yml'
- 'patches/protovalidate/**'
concurrency:
group: ${{ github.workflow }}-${{ inputs.version || '2.0.0' }}-${{ 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 2.0.0 there.
PROTOVALIDATE_VERSION: ${{ inputs.version || '2.0.0' }}
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
jobs:
setup:
uses: $/.github/workflows/_setup.yml
build_wheels:
needs: [setup]
name: Build protovalidate ${{ inputs.version || '2.0.0' }} ${{ matrix.tag }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 360
strategy:
fail-fast: false
matrix:
include:
# [tool.maturin] features already lists pyo3/abi3-py310, so one
# abi3 wheel serves every GIL-ful interpreter; pyo3 disables abi3
# under Py_GIL_DISABLED, giving the free-threaded build its own
# wheel. Matches upstream's own `-i 3.10 -i 3.14t` maturin-action
# invocation.
- tag: cp310-abi3
build: >-
cp312-manylinux_riscv64 cp313-manylinux_riscv64
cp314-manylinux_riscv64
- tag: cp314t
build: cp314t-manylinux_riscv64
steps:
- name: Checkout protovalidate-py v${{ env.PROTOVALIDATE_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: bufbuild/protovalidate-py
ref: v${{ env.PROTOVALIDATE_VERSION }}
submodules: recursive
fetch-depth: 1
persist-credentials: false
- name: Checkout python-wheels
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: python-wheels
fetch-depth: 1
persist-credentials: false
- name: Patch source
run: git apply python-wheels/patches/protovalidate/${{ env.PROTOVALIDATE_VERSION }}/*.patch
- name: Build wheels
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
env:
CIBW_BUILD: ${{ matrix.build }}
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
# protovalidate ships no [tool.cibuildwheel], so the Rust toolchain
# its maturin backend needs is installed in-container here. `go` is
# also needed: test/conformance/test_conformance.py shells out to
# `go run github.com/bufbuild/protovalidate/tools/protovalidate-conformance`,
# which isn't present on the manylinux image otherwise.
CIBW_BEFORE_ALL_LINUX: >-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y &&
dnf -y install golang
CIBW_ENVIRONMENT_LINUX: PATH="$PATH:$HOME/.cargo/bin"
CIBW_TEST_REQUIRES: >-
pytest==9.1.1 pytest-benchmark==5.2.3 pydantic==2.13.4
protobuf>=6.31.0
# The `protovalidate` python package (protobuf-py, at repo root)
# would otherwise shadow the installed wheel's compiled extension.
CIBW_TEST_SOURCES: test pyproject.toml
# protobuf (Google's package, used for legacy conformance coverage)
# has no riscv64 wheel on public PyPI yet.
CIBW_TEST_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
CIBW_TEST_COMMAND: >-
python -c "import protovalidate._protovalidate as m; assert m.__file__.endswith('.so'), m.__file__" &&
python -m pytest test -v
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: protovalidate-${{ env.PROTOVALIDATE_VERSION }}-${{ matrix.tag }}-manylinux_riscv64
path: wheelhouse/*.whl
if-no-files-found: error
publish:
name: Publish protovalidate ${{ inputs.version || '2.0.0' }}
needs: [setup, build_wheels]
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
with:
artifact-pattern: protovalidate-${{ inputs.version || '2.0.0' }}-*-manylinux_riscv64