|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `wheels` job of |
| 5 | +# https://github.com/gorules/zen/blob/python-v2.0.2/.github/workflows/python.yaml |
| 6 | +name: Build zen-engine 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/zen-engine.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-zen-engine.yml' |
| 19 | + - 'docs/packages/zen-engine.yaml' |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + paths: |
| 23 | + - '.github/workflows/build-zen-engine.yml' |
| 24 | + - 'docs/packages/zen-engine.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 | +jobs: |
| 34 | + setup: |
| 35 | + uses: $/.github/workflows/_setup.yml |
| 36 | + with: |
| 37 | + package: zen-engine |
| 38 | + version: ${{ inputs.version }} |
| 39 | + |
| 40 | + build_wheel: |
| 41 | + needs: [setup] |
| 42 | + if: needs.setup.outputs.versions != '[]' |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 47 | + name: Build zen-engine ${{ matrix.version }} cp38-abi3-manylinux_riscv64 |
| 48 | + runs-on: ubuntu-24.04-riscv |
| 49 | + timeout-minutes: 720 |
| 50 | + |
| 51 | + env: |
| 52 | + ZEN_ENGINE_VERSION: ${{ matrix.version }} |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: Checkout zen python-v${{ env.ZEN_ENGINE_VERSION }} |
| 56 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 57 | + with: |
| 58 | + repository: gorules/zen |
| 59 | + ref: python-v${{ env.ZEN_ENGINE_VERSION }} |
| 60 | + persist-credentials: false |
| 61 | + |
| 62 | + # rquickjs-sys ships no riscv64 bindings (bindgen, as upstream's s390x build), and passes |
| 63 | + # clang the rust triple riscv64gc-..., which clang rejects; the later --target wins. |
| 64 | + # A CLI --features replaces [tool.maturin] features, so pyo3/extension-module is restated. |
| 65 | + - name: Build wheel |
| 66 | + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 |
| 67 | + with: |
| 68 | + target: riscv64gc-unknown-linux-gnu |
| 69 | + args: --release --out dist --locked -m bindings/python/Cargo.toml --features pyo3/extension-module,zen-engine/bindgen |
| 70 | + manylinux: '2_39' |
| 71 | + before-script-linux: dnf install -y clang-devel |
| 72 | + docker-options: -e BINDGEN_EXTRA_CLANG_ARGS=--target=riscv64-unknown-linux-gnu |
| 73 | + |
| 74 | + - name: Verify the wheel ships the compiled extension |
| 75 | + run: | |
| 76 | + set -euo pipefail |
| 77 | + python3 - dist/*.whl <<'EOF' |
| 78 | + import sys, zipfile |
| 79 | + names = zipfile.ZipFile(sys.argv[1]).namelist() |
| 80 | + sos = [n for n in names if n.endswith(".so")] |
| 81 | + assert "zen/zen.abi3.so" in sos, sos |
| 82 | + assert any(n.endswith(".dist-info/licenses/LICENSE") for n in names), names |
| 83 | + print(sys.argv[1], "->", sos) |
| 84 | + EOF |
| 85 | +
|
| 86 | + - name: Install uv |
| 87 | + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 |
| 88 | + with: |
| 89 | + enable-cache: false |
| 90 | + |
| 91 | + # Upstream's CI never runs these; they are the binding's own suite. |
| 92 | + - name: Run test_sync.py and test_async.py |
| 93 | + working-directory: bindings/python |
| 94 | + run: | |
| 95 | + set -euo pipefail |
| 96 | + for py in 3.12 3.13 3.14; do |
| 97 | + venv="$RUNNER_TEMP/venv-$py" |
| 98 | + uv venv --python "$py" "$venv" |
| 99 | + uv pip install --python "$venv/bin/python" "$GITHUB_WORKSPACE"/dist/*.whl |
| 100 | + "$venv/bin/python" -m unittest -v test_sync test_async |
| 101 | + done |
| 102 | +
|
| 103 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 104 | + with: |
| 105 | + name: zen-engine-${{ env.ZEN_ENGINE_VERSION }}-cp38-abi3-manylinux_riscv64 |
| 106 | + path: dist/*.whl |
| 107 | + if-no-files-found: error |
| 108 | + |
| 109 | + publish: |
| 110 | + name: Publish zen-engine ${{ matrix.version }} |
| 111 | + needs: [setup, build_wheel] |
| 112 | + if: needs.setup.outputs.versions != '[]' |
| 113 | + strategy: |
| 114 | + fail-fast: false |
| 115 | + matrix: |
| 116 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 117 | + permissions: |
| 118 | + contents: write |
| 119 | + pull-requests: write |
| 120 | + uses: $/.github/workflows/_publish-wheel.yml |
| 121 | + secrets: |
| 122 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 123 | + with: |
| 124 | + artifact-pattern: zen-engine-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments