|
| 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/k9securityio/cedar-py/blob/v4.8.7/.github/workflows/CI.yml |
| 6 | +name: Build cedarpy 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/cedarpy.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-cedarpy.yml' |
| 19 | + - 'docs/packages/cedarpy.yaml' |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + paths: |
| 23 | + - '.github/workflows/build-cedarpy.yml' |
| 24 | + - 'docs/packages/cedarpy.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: cedarpy |
| 38 | + version: ${{ inputs.version }} |
| 39 | + |
| 40 | + build_wheels: |
| 41 | + needs: [setup] |
| 42 | + if: needs.setup.outputs.versions != '[]' |
| 43 | + name: Build cedarpy ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 |
| 44 | + runs-on: ubuntu-24.04-riscv |
| 45 | + timeout-minutes: 180 |
| 46 | + strategy: |
| 47 | + fail-fast: false |
| 48 | + matrix: |
| 49 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 50 | + # cedarpy's pyo3 dependency has a plain `features = |
| 51 | + # ["pyo3/extension-module"]` (no abi3-pyNN), so every interpreter |
| 52 | + # needs its own build. pp311 is dropped: PyPy has no riscv64 port. |
| 53 | + python: ['cp39', 'cp310', 'cp311', 'cp312', 'cp313', 'cp314', 'cp314t'] |
| 54 | + |
| 55 | + env: |
| 56 | + CEDARPY_VERSION: ${{ matrix.version }} |
| 57 | + # Without this uv would reuse the runner image's system CPython for 3.12 |
| 58 | + # and download a standalone build for the others. |
| 59 | + UV_PYTHON_PREFERENCE: only-managed |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Checkout cedarpy v${{ env.CEDARPY_VERSION }} |
| 63 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 64 | + with: |
| 65 | + repository: k9securityio/cedar-py |
| 66 | + ref: v${{ env.CEDARPY_VERSION }} |
| 67 | + submodules: 'true' |
| 68 | + persist-credentials: false |
| 69 | + |
| 70 | + - name: Determine target interpreter |
| 71 | + id: interp |
| 72 | + run: | |
| 73 | + v="${{ matrix.python }}" |
| 74 | + v="${v#cp}" |
| 75 | + echo "value=python${v:0:1}.${v:1}" >> "$GITHUB_OUTPUT" |
| 76 | +
|
| 77 | + - name: Build wheel |
| 78 | + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 |
| 79 | + with: |
| 80 | + target: riscv64gc-unknown-linux-gnu |
| 81 | + args: --release --strip -i ${{ steps.interp.outputs.value }} --out dist |
| 82 | + manylinux: '2_39' |
| 83 | + |
| 84 | + - name: Install Python |
| 85 | + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 |
| 86 | + with: |
| 87 | + python-version: ${{ steps.interp.outputs.value }} |
| 88 | + activate-environment: true |
| 89 | + enable-cache: false |
| 90 | + |
| 91 | + # Mirrors upstream's own "unit tests (x86_64)" step (CI.yml): install |
| 92 | + # from the just-built wheel with the public index disabled, then run |
| 93 | + # its own test suite unmodified. |
| 94 | + - name: Unit tests |
| 95 | + run: | |
| 96 | + uv pip install cedarpy --no-index --find-links dist --force-reinstall |
| 97 | + if [ "${{ matrix.python }}" = "cp39" ]; then |
| 98 | + # pyproject.toml's own dev extra declares "pytest >= 9.0.3", whose own |
| 99 | + # floor is Python>=3.10 - a dev-tooling requirement above cedarpy's cp39 |
| 100 | + # runtime floor. Upstream's own CI never hits this: maturin's |
| 101 | + # `--find-interpreter` builds a wheel per interpreter found, but a single |
| 102 | + # fixed 3.13 venv (from actions/setup-python) is the only one ever |
| 103 | + # pip-installed and pytest-run, so a cp39 wheel is never actually |
| 104 | + # exercised upstream either. Install a pre-9.0 pytest instead of the |
| 105 | + # pinned lockfile line so cp39's own wheel gets tested here too. |
| 106 | + uv pip install -r requirements.txt |
| 107 | + uv pip install 'pytest<9' pytest-benchmark 'parameterized==0.9.0' |
| 108 | + else |
| 109 | + uv pip install -r requirements.txt -r requirements.dev.txt |
| 110 | + fi |
| 111 | + pytest |
| 112 | +
|
| 113 | + # Mirrors upstream's own "integration tests (x86_64)" step (CI.yml). |
| 114 | + - name: Integration tests |
| 115 | + run: make integration-tests |
| 116 | + |
| 117 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 118 | + with: |
| 119 | + name: cedarpy-${{ env.CEDARPY_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 120 | + path: dist/*.whl |
| 121 | + if-no-files-found: error |
| 122 | + |
| 123 | + publish: |
| 124 | + name: Publish cedarpy ${{ matrix.version }} |
| 125 | + needs: [setup, build_wheels] |
| 126 | + if: needs.setup.outputs.versions != '[]' |
| 127 | + strategy: |
| 128 | + fail-fast: false |
| 129 | + matrix: |
| 130 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 131 | + permissions: |
| 132 | + contents: write |
| 133 | + pull-requests: write |
| 134 | + uses: $/.github/workflows/_publish-wheel.yml |
| 135 | + secrets: |
| 136 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 137 | + with: |
| 138 | + artifact-pattern: cedarpy-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments