|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `build_wheels` job of |
| 5 | +# https://github.com/cmusphinx/pocketsphinx/blob/v5.1.1/.github/workflows/release.yml |
| 6 | +# and the `python-tests` job of |
| 7 | +# https://github.com/cmusphinx/pocketsphinx/blob/v5.1.1/.github/workflows/tests.yml |
| 8 | +name: Build pocketsphinx wheels (riscv64) |
| 9 | + |
| 10 | +on: |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + version: |
| 14 | + description: 'Version glob to (re)build; empty builds every version of docs/packages/pocketsphinx.yaml not released yet' |
| 15 | + required: false |
| 16 | + default: '' |
| 17 | + pull_request: |
| 18 | + branches: [main] |
| 19 | + paths: |
| 20 | + - '.github/workflows/build-pocketsphinx.yml' |
| 21 | + - 'docs/packages/pocketsphinx.yaml' |
| 22 | + push: |
| 23 | + branches: [main] |
| 24 | + paths: |
| 25 | + - '.github/workflows/build-pocketsphinx.yml' |
| 26 | + - 'docs/packages/pocketsphinx.yaml' |
| 27 | + |
| 28 | +concurrency: |
| 29 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 30 | + cancel-in-progress: true |
| 31 | + |
| 32 | +permissions: |
| 33 | + contents: read # to fetch code (actions/checkout) |
| 34 | + |
| 35 | +env: |
| 36 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 37 | + |
| 38 | +jobs: |
| 39 | + setup: |
| 40 | + uses: $/.github/workflows/_setup.yml |
| 41 | + with: |
| 42 | + package: pocketsphinx |
| 43 | + version: ${{ inputs.version }} |
| 44 | + |
| 45 | + build_wheels: |
| 46 | + needs: [setup] |
| 47 | + if: needs.setup.outputs.versions != '[]' |
| 48 | + name: Build pocketsphinx ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 |
| 49 | + runs-on: ubuntu-24.04-riscv |
| 50 | + timeout-minutes: 180 |
| 51 | + strategy: |
| 52 | + fail-fast: false |
| 53 | + matrix: |
| 54 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 55 | + python: ["cp312", "cp313", "cp314"] |
| 56 | + |
| 57 | + env: |
| 58 | + POCKETSPHINX_VERSION: ${{ matrix.version }} |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Checkout pocketsphinx v${{ env.POCKETSPHINX_VERSION }} |
| 62 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 63 | + with: |
| 64 | + repository: cmusphinx/pocketsphinx |
| 65 | + ref: v${{ env.POCKETSPHINX_VERSION }} |
| 66 | + persist-credentials: false |
| 67 | + |
| 68 | + # MT19937, dtoa and yin are compiled in, but upstream's LICENSE omits their notices. |
| 69 | + - name: Stage the vendored sources' licences |
| 70 | + run: | |
| 71 | + set -euo pipefail |
| 72 | + sed -n '/Copyright (C) 1997 - 2002, Makoto Matsumoto/,/SUCH DAMAGE\./{s/^ //;p}' src/util/genrand.c > LICENSE.mt19937 |
| 73 | + sed -n '/The author of this software is David M. Gay/,/PARTICULAR PURPOSE\./{s/^ \* \{0,1\}//;p}' src/util/dtoa.c > LICENSE.dtoa |
| 74 | + sed -n '/Copyright (c) 2008 Beyond Access/,/SUCH DAMAGE\./{s/^ \* \{0,1\}//;p}' src/fe/yin.c > LICENSE.yin |
| 75 | + for f in LICENSE.mt19937 LICENSE.dtoa LICENSE.yin; do |
| 76 | + test "$(wc -l < "$f")" -gt 10 |
| 77 | + done |
| 78 | + head -n 3 LICENSE.mt19937 LICENSE.dtoa LICENSE.yin |
| 79 | +
|
| 80 | + - name: Build wheels |
| 81 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 82 | + with: |
| 83 | + output-dir: wheelhouse/ |
| 84 | + only: ${{ matrix.python }}-manylinux_riscv64 |
| 85 | + env: |
| 86 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 87 | + CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ |
| 88 | + CIBW_TEST_REQUIRES: pytest memory_profiler |
| 89 | + CIBW_TEST_COMMAND: pytest {project} |
| 90 | + |
| 91 | + - name: Check wheel contents |
| 92 | + run: | |
| 93 | + python3 - wheelhouse/*.whl <<'EOF' |
| 94 | + import sys, zipfile |
| 95 | + names = zipfile.ZipFile(sys.argv[1]).namelist() |
| 96 | + exts = [n for n in names if n.endswith(".so")] |
| 97 | + assert len(exts) == 1 and exts[0].startswith("pocketsphinx/_pocketsphinx.cpython-"), exts |
| 98 | + assert exts[0].endswith("-riscv64-linux-gnu.so"), exts |
| 99 | + assert "pocketsphinx/model/en-us/en-us.lm.bin" in names, names |
| 100 | + licences = {n.split(".dist-info/licenses/", 1)[1] for n in names |
| 101 | + if ".dist-info/licenses/" in n and not n.endswith("/")} |
| 102 | + assert {"LICENSE", "LICENSE.dtoa", "LICENSE.mt19937", "LICENSE.yin"} <= licences, licences |
| 103 | + EOF |
| 104 | +
|
| 105 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 106 | + with: |
| 107 | + name: pocketsphinx-${{ env.POCKETSPHINX_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 108 | + path: wheelhouse/*.whl |
| 109 | + if-no-files-found: error |
| 110 | + |
| 111 | + publish: |
| 112 | + name: Publish pocketsphinx ${{ matrix.version }} |
| 113 | + needs: [setup, build_wheels] |
| 114 | + if: needs.setup.outputs.versions != '[]' |
| 115 | + strategy: |
| 116 | + fail-fast: false |
| 117 | + matrix: |
| 118 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 119 | + permissions: |
| 120 | + contents: write |
| 121 | + pull-requests: write |
| 122 | + uses: $/.github/workflows/_publish-wheel.yml |
| 123 | + secrets: |
| 124 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 125 | + with: |
| 126 | + artifact-pattern: pocketsphinx-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments