|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +name: Build grpcio-tools wheels (riscv64) |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: 'grpcio-tools version to build (git tag without leading v, e.g. 1.83.1)' |
| 11 | + required: true |
| 12 | + default: '1.83.1' |
| 13 | + pull_request: |
| 14 | + paths: |
| 15 | + - '.github/workflows/build-grpcio-tools.yml' |
| 16 | + - 'patches/grpcio-tools/**' |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: ${{ github.workflow }}-${{ inputs.version || '1.83.1' }}-${{ github.head_ref || github.run_id }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + |
| 25 | +env: |
| 26 | + GRPCIO_TOOLS_VERSION: ${{ inputs.version || '1.83.1' }} |
| 27 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 28 | + |
| 29 | +jobs: |
| 30 | + setup: |
| 31 | + uses: $/.github/workflows/_setup.yml |
| 32 | + |
| 33 | + build_wheels: |
| 34 | + needs: [setup] |
| 35 | + name: Build grpcio-tools ${{ inputs.version || '1.83.1' }} ${{ matrix.python }}-manylinux_riscv64 |
| 36 | + runs-on: ubuntu-24.04-riscv |
| 37 | + strategy: |
| 38 | + fail-fast: false |
| 39 | + matrix: |
| 40 | + # Mirrors build-grpcio.yml: grpcio-tools shares python_version.py's |
| 41 | + # supported-version list with grpcio and doesn't declare free-threaded |
| 42 | + # support either. |
| 43 | + python: ["cp312", "cp313", "cp314"] |
| 44 | + |
| 45 | + env: |
| 46 | + CCACHE_DIR: ${{ github.workspace }}/.ccache |
| 47 | + CCACHE_BASEDIR: "/project" |
| 48 | + CCACHE_COMPILERCHECK: "content" |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: Checkout grpc v${{ env.GRPCIO_TOOLS_VERSION }} |
| 52 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 53 | + with: |
| 54 | + repository: grpc/grpc |
| 55 | + ref: v${{ env.GRPCIO_TOOLS_VERSION }} |
| 56 | + submodules: true |
| 57 | + fetch-depth: 1 # grpc's submodules (protobuf, abseil-cpp, ...) are large; skip history |
| 58 | + persist-credentials: false |
| 59 | + |
| 60 | + # grpcio_tools' setup.py builds its protoc plugin against copies of |
| 61 | + # src/compiler, include/ and the protobuf/abseil-cpp submodules staged |
| 62 | + # under tools/distrib/python/grpcio_tools/ (grpc_root/, third_party/, |
| 63 | + # both gitignored). Upstream's own install_all_python_modules.sh runs |
| 64 | + # this same script (as ../make_grpcio_tools.py) before building. The |
| 65 | + # bazel query it also attempts (to regenerate protoc_lib_deps.py) fails |
| 66 | + # without bazel installed, but that failure is non-fatal - the script |
| 67 | + # falls back to the dependency list already committed for this tag. |
| 68 | + - name: Generate grpcio_tools build sources |
| 69 | + run: python3 tools/distrib/python/make_grpcio_tools.py |
| 70 | + |
| 71 | + # The compiled objects (protobuf/abseil-cpp sources) are identical |
| 72 | + # across cp312/cp313/cp314; share ccache across builds. |
| 73 | + - name: Restore compilation cache |
| 74 | + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 75 | + with: |
| 76 | + path: ${{ env.CCACHE_DIR }} |
| 77 | + key: ccache-wheels-grpcio-tools-v${{ env.GRPCIO_TOOLS_VERSION }}-manylinux_riscv64-${{ matrix.python }} |
| 78 | + restore-keys: | |
| 79 | + ccache-wheels-grpcio-tools-v${{ env.GRPCIO_TOOLS_VERSION }}-manylinux_riscv64- |
| 80 | +
|
| 81 | + - name: Build wheels |
| 82 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 83 | + with: |
| 84 | + package-dir: tools/distrib/python/grpcio_tools |
| 85 | + env: |
| 86 | + CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64 |
| 87 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 88 | + CIBW_BEFORE_ALL: | |
| 89 | + set -eux |
| 90 | + CCACHE_VERSION=4.13.6 |
| 91 | + curl -fsSL https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-$(uname -m)-musl-static.tar.gz | \ |
| 92 | + tar -xvzf - --strip-components 1 -C /usr/local/bin ccache-${CCACHE_VERSION}-linux-$(uname -m)-musl-static/ccache |
| 93 | + ccache --version |
| 94 | + ccache --zero-stats |
| 95 | + # The extension only needs Cython at build time (declared in |
| 96 | + # pyproject.toml's build-system.requires); unlike grpcio's own |
| 97 | + # setup.py, grpcio_tools' doesn't fall back to cythonizing |
| 98 | + # automatically - it requires this flag or it looks for a |
| 99 | + # pre-generated _protoc_compiler.cpp that doesn't exist in a fresh |
| 100 | + # checkout. Matches install_all_python_modules.sh. |
| 101 | + CIBW_ENVIRONMENT: GRPC_PYTHON_BUILD_WITH_CYTHON=1 PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ |
| 102 | + # Fail fast rather than fall back to a from-source grpcio build if |
| 103 | + # our registry doesn't yet carry a matching riscv64 wheel (same |
| 104 | + # reasoning as build-grpcio.yml's CIBW_TEST_ENVIRONMENT). |
| 105 | + CIBW_TEST_ENVIRONMENT: "PIP_ONLY_BINARY=:all:" |
| 106 | + CIBW_ENVIRONMENT_PASS_LINUX: >- |
| 107 | + CCACHE_BASEDIR |
| 108 | + CCACHE_COMPILERCHECK |
| 109 | + CIBW_CONTAINER_ENGINE: "docker; create_args: --volume ${{ env.CCACHE_DIR }}:/root/.ccache" |
| 110 | + CIBW_REPAIR_WHEEL_COMMAND: auditwheel repair --strip -w {dest_dir} {wheel} |
| 111 | + CIBW_TEST_REQUIRES: pytest |
| 112 | + CIBW_TEST_SOURCES: tools/distrib/python/grpcio_tools/grpc_tools/test |
| 113 | + # Mirrors upstream's own binary distribtest (test/distrib/python/test_packages.sh: |
| 114 | + # "$PYTHON" -m grpc_tools.protoc --help), plus grpc_tools' own unit |
| 115 | + # tests (grpc_tools/test/protoc_test.py) for real coverage of the |
| 116 | + # dynamic/static proto-compilation code paths. complicated_pb2 is |
| 117 | + # normally generated by Bazel's py_proto_library for the bazel test |
| 118 | + # target; reproduce that with a plain protoc invocation. |
| 119 | + CIBW_TEST_COMMAND: >- |
| 120 | + python -m grpc_tools.protoc --help && |
| 121 | + python -m grpc_tools.protoc |
| 122 | + -Itools/distrib/python/grpcio_tools/grpc_tools/test |
| 123 | + --python_out=tools/distrib/python/grpcio_tools/grpc_tools/test |
| 124 | + tools/distrib/python/grpcio_tools/grpc_tools/test/simplest.proto |
| 125 | + tools/distrib/python/grpcio_tools/grpc_tools/test/complicated.proto && |
| 126 | + python -m pytest tools/distrib/python/grpcio_tools/grpc_tools/test/protoc_test.py |
| 127 | +
|
| 128 | + - name: Save compilation cache |
| 129 | + if: always() && github.ref == 'refs/heads/main' |
| 130 | + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 131 | + with: |
| 132 | + path: ${{ env.CCACHE_DIR }} |
| 133 | + key: ccache-wheels-grpcio-tools-v${{ env.GRPCIO_TOOLS_VERSION }}-manylinux_riscv64-${{ matrix.python }} |
| 134 | + |
| 135 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 136 | + with: |
| 137 | + name: grpcio-tools-${{ env.GRPCIO_TOOLS_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 138 | + path: ./wheelhouse/*.whl |
| 139 | + if-no-files-found: error |
| 140 | + |
| 141 | + publish: |
| 142 | + name: Publish grpcio-tools ${{ inputs.version || '1.83.1' }} |
| 143 | + needs: [setup, build_wheels] |
| 144 | + permissions: |
| 145 | + contents: write |
| 146 | + pull-requests: write |
| 147 | + uses: $/.github/workflows/_publish-wheel.yml |
| 148 | + with: |
| 149 | + artifact-pattern: grpcio-tools-${{ inputs.version || '1.83.1' }}-*-manylinux_riscv64 |
0 commit comments