|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `linux` job of |
| 5 | +# https://github.com/messense/rjieba-py/blob/v0.2.1/.github/workflows/CI.yml |
| 6 | +name: Build rjieba wheels (riscv64) |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'rjieba version to build (git tag without the leading v, e.g. 0.2.1)' |
| 13 | + required: true |
| 14 | + default: '0.2.1' |
| 15 | + pull_request: |
| 16 | + paths: |
| 17 | + - '.github/workflows/build-rjieba.yml' |
| 18 | + - 'patches/rjieba/**' |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ inputs.version || '0.2.1' }}-${{ github.head_ref || github.run_id }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +permissions: |
| 25 | + contents: read # to fetch code (actions/checkout) |
| 26 | + |
| 27 | +env: |
| 28 | + # `inputs.version` is empty on pull_request events; default to 0.2.1 there. |
| 29 | + RJIEBA_VERSION: ${{ inputs.version || '0.2.1' }} |
| 30 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 31 | + |
| 32 | +jobs: |
| 33 | + setup: |
| 34 | + uses: $/.github/workflows/_setup.yml |
| 35 | + |
| 36 | + build_wheels: |
| 37 | + needs: [setup] |
| 38 | + name: Build rjieba ${{ inputs.version || '0.2.1' }} ${{ matrix.tag }}-manylinux_riscv64 |
| 39 | + runs-on: ubuntu-24.04-riscv |
| 40 | + timeout-minutes: 60 |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + include: |
| 45 | + # pyo3's abi3-py38 feature (Cargo.toml) gives one wheel for every |
| 46 | + # GIL-ful interpreter; free-threaded builds disable abi3 and get |
| 47 | + # their own (upstream's CI.yml builds them as a separate maturin |
| 48 | + # pass with `-i python3.14t` for the same reason). |
| 49 | + - tag: cp38-abi3 |
| 50 | + # Built on cp312 -- the oldest interpreter in our matrix -- and |
| 51 | + # re-tested on cp313/cp314 via find_compatible_wheel. |
| 52 | + build: >- |
| 53 | + cp312-manylinux_riscv64 cp313-manylinux_riscv64 |
| 54 | + cp314-manylinux_riscv64 |
| 55 | + - tag: cp314t |
| 56 | + build: cp314t-manylinux_riscv64 |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Checkout rjieba v${{ env.RJIEBA_VERSION }} |
| 60 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 61 | + with: |
| 62 | + repository: messense/rjieba-py |
| 63 | + ref: v${{ env.RJIEBA_VERSION }} |
| 64 | + persist-credentials: false |
| 65 | + |
| 66 | + - name: Checkout python-wheels |
| 67 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 68 | + with: |
| 69 | + path: python-wheels |
| 70 | + persist-credentials: false |
| 71 | + |
| 72 | + - name: Patch rjieba source |
| 73 | + run: git apply python-wheels/patches/rjieba/${{ env.RJIEBA_VERSION }}/*.patch |
| 74 | + |
| 75 | + - name: Build and test wheel |
| 76 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 77 | + with: |
| 78 | + output-dir: wheelhouse/ |
| 79 | + env: |
| 80 | + # musllinux is dropped: rustup.rs ships no riscv64 musl toolchain. |
| 81 | + CIBW_BUILD: ${{ matrix.build }} |
| 82 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 83 | + # rjieba ships no [tool.cibuildwheel], so the Rust toolchain its |
| 84 | + # maturin backend needs is installed in-container here. |
| 85 | + CIBW_BEFORE_ALL_LINUX: >- |
| 86 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 87 | + CIBW_ENVIRONMENT_LINUX: PATH="$PATH:$HOME/.cargo/bin" |
| 88 | + CIBW_TEST_REQUIRES: pytest |
| 89 | + CIBW_TEST_SOURCES: tests |
| 90 | + CIBW_TEST_COMMAND: >- |
| 91 | + python -c "import rjieba; assert rjieba.rjieba.__file__.endswith('.so'), rjieba.rjieba.__file__" && |
| 92 | + python -m pytest -v tests |
| 93 | +
|
| 94 | + - name: Check the licence made it into the wheel |
| 95 | + run: | |
| 96 | + python3 - wheelhouse/*.whl <<'EOF' |
| 97 | + import sys, zipfile |
| 98 | + for whl in sys.argv[1:]: |
| 99 | + names = zipfile.ZipFile(whl).namelist() |
| 100 | + assert any(n.endswith("dist-info/licenses/LICENSE") for n in names), names |
| 101 | + print(whl, "ok") |
| 102 | + EOF |
| 103 | +
|
| 104 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 105 | + with: |
| 106 | + name: rjieba-${{ env.RJIEBA_VERSION }}-${{ matrix.tag }}-manylinux_riscv64 |
| 107 | + path: wheelhouse/*.whl |
| 108 | + if-no-files-found: error |
| 109 | + |
| 110 | + publish: |
| 111 | + name: Publish rjieba ${{ inputs.version || '0.2.1' }} |
| 112 | + needs: [setup, build_wheels] |
| 113 | + permissions: |
| 114 | + contents: write |
| 115 | + pull-requests: write |
| 116 | + uses: $/.github/workflows/_publish-wheel.yml |
| 117 | + with: |
| 118 | + artifact-pattern: rjieba-${{ inputs.version || '0.2.1' }}-*-manylinux_riscv64 |
0 commit comments