|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `linux`/`linux-arm` jobs of |
| 5 | +# https://github.com/j178/prek/blob/v0.5.2/.github/workflows/build-release-binaries.yml |
| 6 | +name: Build prek wheels (riscv64) |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'prek version to build (git tag without the leading v, e.g. 0.5.2)' |
| 13 | + required: true |
| 14 | + default: '0.5.2' |
| 15 | + pull_request: |
| 16 | + paths: |
| 17 | + - '.github/workflows/build-prek.yml' |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ inputs.version || '0.5.2' }}-${{ github.head_ref || github.run_id }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read # to fetch code (actions/checkout) |
| 25 | + |
| 26 | +env: |
| 27 | + # `inputs.version` is empty on pull_request events; default to 0.5.2 there. |
| 28 | + PREK_VERSION: ${{ inputs.version || '0.5.2' }} |
| 29 | + |
| 30 | +jobs: |
| 31 | + setup: |
| 32 | + uses: $/.github/workflows/_setup.yml |
| 33 | + |
| 34 | + build_wheel: |
| 35 | + needs: [setup] |
| 36 | + name: Build prek ${{ inputs.version || '0.5.2' }} manylinux_riscv64 |
| 37 | + runs-on: ubuntu-24.04-riscv |
| 38 | + timeout-minutes: 360 |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout prek v${{ env.PREK_VERSION }} |
| 42 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 43 | + with: |
| 44 | + repository: j178/prek |
| 45 | + ref: v${{ env.PREK_VERSION }} |
| 46 | + persist-credentials: false |
| 47 | + |
| 48 | + # `[tool.maturin] bindings = "bin"`: the wheel is one compiled executable |
| 49 | + # with no ABI tag, so a single native build covers every interpreter. |
| 50 | + # self-update matches the feature set upstream's own published PyPI |
| 51 | + # wheels are built with (build-release-binaries.yml's linux/linux-arm jobs). |
| 52 | + - name: Build wheel |
| 53 | + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 |
| 54 | + with: |
| 55 | + maturin-version: v1.14.1 |
| 56 | + command: build |
| 57 | + target: riscv64gc-unknown-linux-gnu |
| 58 | + args: --release --locked --out dist --features self-update |
| 59 | + manylinux: '2_39' |
| 60 | + before-script-linux: git config --global --add safe.directory "*" |
| 61 | + |
| 62 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 63 | + with: |
| 64 | + name: prek-${{ env.PREK_VERSION }}-manylinux_riscv64 |
| 65 | + path: dist/*.whl |
| 66 | + if-no-files-found: error |
| 67 | + |
| 68 | + test_wheel: |
| 69 | + name: Test prek ${{ inputs.version || '0.5.2' }} on Python ${{ matrix.python-version }} |
| 70 | + needs: [setup, build_wheel] |
| 71 | + runs-on: ubuntu-24.04-riscv |
| 72 | + timeout-minutes: 30 |
| 73 | + env: |
| 74 | + # Without this uv would reuse the runner image's system CPython for 3.12 |
| 75 | + # and download a standalone build for the others. |
| 76 | + UV_PYTHON_PREFERENCE: only-managed |
| 77 | + strategy: |
| 78 | + fail-fast: false |
| 79 | + matrix: |
| 80 | + # This repo's default interpreter matrix (gotcha in workflow-anatomy.md); |
| 81 | + # the wheel is interpreter-agnostic (bindings = "bin"), so every |
| 82 | + # interpreter -- including free-threaded -- exercises the same binary. |
| 83 | + python-version: ['3.12', '3.13', '3.14', '3.14t'] |
| 84 | + |
| 85 | + steps: |
| 86 | + - name: Checkout prek v${{ env.PREK_VERSION }} |
| 87 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 88 | + with: |
| 89 | + repository: j178/prek |
| 90 | + ref: v${{ env.PREK_VERSION }} |
| 91 | + persist-credentials: false |
| 92 | + |
| 93 | + - name: Download wheel |
| 94 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 95 | + with: |
| 96 | + name: prek-${{ env.PREK_VERSION }}-manylinux_riscv64 |
| 97 | + |
| 98 | + - name: Install Python |
| 99 | + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 |
| 100 | + with: |
| 101 | + python-version: ${{ matrix.python-version }} |
| 102 | + activate-environment: true |
| 103 | + enable-cache: false |
| 104 | + |
| 105 | + - name: Install wheel |
| 106 | + run: uv pip install --reinstall --no-index --find-links . prek |
| 107 | + |
| 108 | + # No pytest suite ships for the wheel; crates/prek's tests are Rust |
| 109 | + # integration tests run by upstream's own cargo nextest. `--version` |
| 110 | + # mirrors upstream's own dev-binary smoke check; `prek run --all-files` |
| 111 | + # against the builtin-hooks sample config mirrors what the published |
| 112 | + # `prek-action` runs, with no network fetch of a hooks repo needed. |
| 113 | + - name: Test wheel |
| 114 | + run: | |
| 115 | + set -euo pipefail |
| 116 | + prek --version |
| 117 | + python -m prek --version |
| 118 | +
|
| 119 | + work=$(mktemp -d) |
| 120 | + cd "$work" |
| 121 | + git init -q |
| 122 | + git config user.email test@example.com |
| 123 | + git config user.name test |
| 124 | + prek sample-config -f --format toml |
| 125 | + git add -A |
| 126 | + git commit -q -m init |
| 127 | + printf 'trailing whitespace \nno newline at end' > bad.txt |
| 128 | + git add -A |
| 129 | +
|
| 130 | + # First run applies fixes and exits non-zero (pre-commit convention). |
| 131 | + prek run --all-files || true |
| 132 | + git diff --stat bad.txt |
| 133 | + # Second run is clean. |
| 134 | + prek run --all-files |
| 135 | +
|
| 136 | + publish: |
| 137 | + name: Publish prek ${{ inputs.version || '0.5.2' }} |
| 138 | + needs: [setup, build_wheel, test_wheel] |
| 139 | + permissions: |
| 140 | + contents: write |
| 141 | + pull-requests: write |
| 142 | + uses: $/.github/workflows/_publish-wheel.yml |
| 143 | + with: |
| 144 | + artifact-pattern: prek-${{ inputs.version || '0.5.2' }}-manylinux_riscv64 |
0 commit comments