|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on upstream's documented wheel build: |
| 5 | +# https://github.com/couchbase/couchbase-python-client/blob/4.6.3/BUILDING.md |
| 6 | +name: Build couchbase wheels (riscv64) |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'Version glob to (re)build; empty builds every version of docs/packages/couchbase.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-couchbase.yml' |
| 19 | + - 'docs/packages/couchbase.yaml' |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + paths: |
| 23 | + - '.github/workflows/build-couchbase.yml' |
| 24 | + - 'docs/packages/couchbase.yaml' |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 28 | + cancel-in-progress: true |
| 29 | + |
| 30 | +permissions: |
| 31 | + contents: read # to fetch code (actions/checkout) |
| 32 | + |
| 33 | +env: |
| 34 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 35 | + |
| 36 | +jobs: |
| 37 | + setup: |
| 38 | + uses: $/.github/workflows/_setup.yml |
| 39 | + with: |
| 40 | + package: couchbase |
| 41 | + version: ${{ inputs.version }} |
| 42 | + |
| 43 | + build_sdist: |
| 44 | + needs: [setup] |
| 45 | + if: needs.setup.outputs.versions != '[]' |
| 46 | + name: Build couchbase ${{ matrix.version }} sdist |
| 47 | + runs-on: ubuntu-latest |
| 48 | + strategy: |
| 49 | + fail-fast: false |
| 50 | + matrix: |
| 51 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 52 | + env: |
| 53 | + COUCHBASE_VERSION: ${{ matrix.version }} |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Checkout couchbase ${{ env.COUCHBASE_VERSION }} |
| 57 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 58 | + with: |
| 59 | + repository: couchbase/couchbase-python-client |
| 60 | + ref: ${{ env.COUCHBASE_VERSION }} |
| 61 | + submodules: recursive |
| 62 | + persist-credentials: false |
| 63 | + |
| 64 | + - name: Install Python |
| 65 | + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 |
| 66 | + with: |
| 67 | + python-version: '3.12' |
| 68 | + activate-environment: true |
| 69 | + enable-cache: false |
| 70 | + |
| 71 | + # configure_ext populates deps/couchbase-cxx-cache, which MANIFEST.in bundles |
| 72 | + # into the sdist; without it the riscv job would have to fetch the C++ core's |
| 73 | + # dependencies from inside the build container. |
| 74 | + - name: Build sdist |
| 75 | + run: | |
| 76 | + uv pip install build setuptools twine wheel |
| 77 | + PYCBC_SET_CPM_CACHE=ON PYCBC_USE_OPENSSL=OFF python setup.py configure_ext |
| 78 | + python setup.py sdist |
| 79 | + twine check dist/* |
| 80 | + env: |
| 81 | + CMAKE_POLICY_VERSION_MINIMUM: '3.5' |
| 82 | + |
| 83 | + - name: Upload sdist artifact |
| 84 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 85 | + with: |
| 86 | + name: couchbase-${{ env.COUCHBASE_VERSION }}-sdist |
| 87 | + path: dist/*.tar.gz |
| 88 | + if-no-files-found: error |
| 89 | + |
| 90 | + build_wheels: |
| 91 | + needs: [setup, build_sdist] |
| 92 | + if: needs.setup.outputs.versions != '[]' |
| 93 | + name: Build couchbase ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 |
| 94 | + runs-on: ubuntu-24.04-riscv |
| 95 | + timeout-minutes: 1440 |
| 96 | + strategy: |
| 97 | + fail-fast: false |
| 98 | + matrix: |
| 99 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 100 | + python: ["cp312", "cp313", "cp314", "cp314t"] |
| 101 | + env: |
| 102 | + COUCHBASE_VERSION: ${{ matrix.version }} |
| 103 | + |
| 104 | + steps: |
| 105 | + - name: Checkout python-wheels |
| 106 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 107 | + with: |
| 108 | + path: python-wheels |
| 109 | + persist-credentials: false |
| 110 | + |
| 111 | + - name: Download sdist |
| 112 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 113 | + with: |
| 114 | + name: couchbase-${{ env.COUCHBASE_VERSION }}-sdist |
| 115 | + path: dist/ |
| 116 | + |
| 117 | + # The patches reach files the git checkout does not have in a patchable |
| 118 | + # shape: one lives in the CPM cache only the sdist carries, the other |
| 119 | + # inside the couchbase-cxx-client submodule. |
| 120 | + - name: Extract and patch couchbase source |
| 121 | + run: | |
| 122 | + mkdir couchbase-src |
| 123 | + tar zxf dist/couchbase-*.tar.gz -C couchbase-src --strip-components=1 |
| 124 | + git apply --directory=couchbase-src python-wheels/patches/couchbase/"${COUCHBASE_VERSION}"/00*.patch |
| 125 | +
|
| 126 | + - name: Build wheels |
| 127 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 128 | + with: |
| 129 | + package-dir: couchbase-src |
| 130 | + output-dir: wheelhouse/ |
| 131 | + only: ${{ matrix.python }}-manylinux_riscv64 |
| 132 | + env: |
| 133 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 134 | + # PYCBC_USE_OPENSSL=OFF is how upstream builds its own wheels: the C++ core |
| 135 | + # statically links the vendored BoringSSL instead of the image's OpenSSL. |
| 136 | + # CMAKE_POLICY_VERSION_MINIMUM covers the vendored GSL's cmake_minimum_required. |
| 137 | + CIBW_ENVIRONMENT: >- |
| 138 | + PYCBC_USE_OPENSSL=OFF |
| 139 | + PYCBC_CMAKE_PARALLEL_THREADS=$(nproc) |
| 140 | + CMAKE_POLICY_VERSION_MINIMUM=3.5 |
| 141 | + PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ |
| 142 | + CIBW_TEST_REQUIRES: pytest |
| 143 | + # Upstream's own suite needs a live Couchbase Server, which has no riscv64 |
| 144 | + # build, so this drives the C++ core directly instead: a bootstrap against an |
| 145 | + # unroutable address has to surface as a Couchbase error, not a crash. |
| 146 | + CIBW_TEST_COMMAND: >- |
| 147 | + python -c "import importlib.metadata as m; f=[str(p) for p in m.files('couchbase')]; assert any(s.endswith('licenses/LICENSE') for s in f), f; import couchbase; from couchbase.logic.pycbc_core import _core; assert _core.__file__.endswith('.so'), _core.__file__; md = couchbase.get_metadata(); assert md['version'], md; assert 'BoringSSL' in md['openssl_runtime'], md; print(md['version'], md['openssl_runtime'])" && |
| 148 | + python -c "import pytest; from datetime import timedelta; from couchbase.auth import PasswordAuthenticator; from couchbase.cluster import Cluster; from couchbase.exceptions import CouchbaseException; from couchbase.options import ClusterOptions, ClusterTimeoutOptions; opts = ClusterOptions(PasswordAuthenticator('u', 'p'), timeout_options=ClusterTimeoutOptions(bootstrap_timeout=timedelta(seconds=15), resolve_timeout=timedelta(seconds=5))); pytest.raises(CouchbaseException, lambda: Cluster.connect('couchbase://192.0.2.1', opts).ping()); print('bootstrap failure surfaced as CouchbaseException')" |
| 149 | +
|
| 150 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 151 | + with: |
| 152 | + name: couchbase-${{ env.COUCHBASE_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 153 | + path: wheelhouse/*.whl |
| 154 | + if-no-files-found: error |
| 155 | + |
| 156 | + publish: |
| 157 | + name: Publish couchbase ${{ matrix.version }} |
| 158 | + needs: [setup, build_wheels] |
| 159 | + if: needs.setup.outputs.versions != '[]' |
| 160 | + strategy: |
| 161 | + fail-fast: false |
| 162 | + matrix: |
| 163 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 164 | + permissions: |
| 165 | + contents: write |
| 166 | + pull-requests: write |
| 167 | + uses: $/.github/workflows/_publish-wheel.yml |
| 168 | + secrets: |
| 169 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 170 | + with: |
| 171 | + artifact-pattern: couchbase-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments