|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# Based on the `dist:python:sdist`/`dist:python:wheel` jobs of |
| 5 | +# https://gitlab.matrix.org/matrix-org/olm/-/blob/3.2.16/python/.gitlab-ci.yml |
| 6 | +name: Build python-olm 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/python-olm.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-python-olm.yml' |
| 19 | + - 'docs/packages/python-olm.yaml' |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + paths: |
| 23 | + - '.github/workflows/build-python-olm.yml' |
| 24 | + - 'docs/packages/python-olm.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: python-olm |
| 41 | + version: ${{ inputs.version }} |
| 42 | + |
| 43 | + build_sdist: |
| 44 | + needs: [setup] |
| 45 | + if: needs.setup.outputs.versions != '[]' |
| 46 | + name: Build python-olm ${{ matrix.version }} sdist |
| 47 | + runs-on: ubuntu-latest |
| 48 | + strategy: |
| 49 | + fail-fast: false |
| 50 | + matrix: |
| 51 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 52 | + |
| 53 | + env: |
| 54 | + PYTHON_OLM_VERSION: ${{ matrix.version }} |
| 55 | + |
| 56 | + steps: |
| 57 | + # olm is hosted on gitlab.matrix.org, which actions/checkout cannot reach. |
| 58 | + - name: Checkout olm ${{ env.PYTHON_OLM_VERSION }} |
| 59 | + run: | |
| 60 | + git clone --depth 1 --branch "${{ env.PYTHON_OLM_VERSION }}" \ |
| 61 | + https://gitlab.matrix.org/matrix-org/olm.git olm-src |
| 62 | +
|
| 63 | + - name: Checkout python-wheels |
| 64 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 65 | + with: |
| 66 | + path: python-wheels |
| 67 | + persist-credentials: false |
| 68 | + |
| 69 | + - name: Patch olm source |
| 70 | + working-directory: olm-src |
| 71 | + run: | |
| 72 | + git apply ../python-wheels/patches/python-olm/${{ env.PYTHON_OLM_VERSION }}/00*.patch |
| 73 | +
|
| 74 | + - name: setup uv |
| 75 | + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 |
| 76 | + with: |
| 77 | + python-version: '3.12' |
| 78 | + activate-environment: true |
| 79 | + enable-cache: false |
| 80 | + |
| 81 | + # The cffi hook runs olm_build.py, and so libolm's cmake build, even for |
| 82 | + # an sdist; libolm asks for cmake 3.4, below the floor of cmake 4. |
| 83 | + - name: Build sdist |
| 84 | + working-directory: olm-src/python |
| 85 | + env: |
| 86 | + CMAKE_POLICY_VERSION_MINIMUM: '3.5' |
| 87 | + run: | |
| 88 | + uv pip install build |
| 89 | + ./make_sdist.sh |
| 90 | +
|
| 91 | + - name: Upload sdist artifact |
| 92 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 93 | + with: |
| 94 | + name: python-olm-${{ env.PYTHON_OLM_VERSION }}-sdist |
| 95 | + path: olm-src/python/dist/*.tar.gz |
| 96 | + if-no-files-found: error |
| 97 | + |
| 98 | + build_wheels: |
| 99 | + needs: [setup, build_sdist] |
| 100 | + if: needs.setup.outputs.versions != '[]' |
| 101 | + name: Build python-olm ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 |
| 102 | + runs-on: ubuntu-24.04-riscv |
| 103 | + timeout-minutes: 120 |
| 104 | + strategy: |
| 105 | + fail-fast: false |
| 106 | + matrix: |
| 107 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 108 | + python: ["cp312", "cp313", "cp314", "cp314t"] |
| 109 | + |
| 110 | + env: |
| 111 | + PYTHON_OLM_VERSION: ${{ matrix.version }} |
| 112 | + |
| 113 | + steps: |
| 114 | + # The sdist ships no tests; the suite only exists in the git tree. |
| 115 | + - name: Checkout olm ${{ env.PYTHON_OLM_VERSION }} tests |
| 116 | + run: | |
| 117 | + git clone --depth 1 --branch "${{ env.PYTHON_OLM_VERSION }}" \ |
| 118 | + https://gitlab.matrix.org/matrix-org/olm.git olm-src |
| 119 | + mv olm-src/python/tests tests |
| 120 | +
|
| 121 | + - name: Fetch sdist artifact |
| 122 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 123 | + with: |
| 124 | + name: python-olm-${{ env.PYTHON_OLM_VERSION }}-sdist |
| 125 | + path: dist |
| 126 | + |
| 127 | + - id: sdist_dir |
| 128 | + run: | |
| 129 | + tar zxf dist/*.tar.gz -C dist |
| 130 | + echo "path=$(echo dist/python_olm-*/)" >> "$GITHUB_OUTPUT" |
| 131 | +
|
| 132 | + - name: Build wheels |
| 133 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 134 | + with: |
| 135 | + package-dir: ${{ steps.sdist_dir.outputs.path }} |
| 136 | + output-dir: wheelhouse/ |
| 137 | + env: |
| 138 | + CIBW_ARCHS: riscv64 |
| 139 | + CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64 |
| 140 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 141 | + # cffi has no riscv64 wheel on PyPI. |
| 142 | + CIBW_ENVIRONMENT: >- |
| 143 | + PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ |
| 144 | + CMAKE_POLICY_VERSION_MINIMUM=3.5 |
| 145 | + CIBW_TEST_REQUIRES: pytest pytest-benchmark aspectlib |
| 146 | + CIBW_TEST_SOURCES: tests |
| 147 | + CIBW_TEST_COMMAND: python -m pytest tests --benchmark-disable |
| 148 | + |
| 149 | + - name: Store wheels |
| 150 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 151 | + with: |
| 152 | + name: python-olm-${{ env.PYTHON_OLM_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 153 | + path: wheelhouse/*.whl |
| 154 | + if-no-files-found: error |
| 155 | + |
| 156 | + publish: |
| 157 | + name: Publish python-olm ${{ 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: python-olm-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments