|
| 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/reflex-dev/ruff-format/blob/v0.5.4/.github/workflows/CI.yml |
| 6 | +name: Build ruff-format 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/ruff-format.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-ruff-format.yml' |
| 19 | + - 'docs/packages/ruff-format.yaml' |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + paths: |
| 23 | + - '.github/workflows/build-ruff-format.yml' |
| 24 | + - 'docs/packages/ruff-format.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 | +env: |
| 34 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 35 | + |
| 36 | +jobs: |
| 37 | + setup: |
| 38 | + uses: $/.github/workflows/_setup.yml |
| 39 | + with: |
| 40 | + package: ruff-format |
| 41 | + version: ${{ inputs.version }} |
| 42 | + |
| 43 | + build_wheels: |
| 44 | + needs: [setup] |
| 45 | + if: needs.setup.outputs.versions != '[]' |
| 46 | + name: Build ruff-format ${{ matrix.version }} ${{ matrix.tag }}-manylinux_riscv64 |
| 47 | + runs-on: ubuntu-24.04-riscv |
| 48 | + timeout-minutes: 90 |
| 49 | + strategy: |
| 50 | + fail-fast: false |
| 51 | + matrix: |
| 52 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 53 | + # tag is a real matrix dimension (not just an include-only key) so |
| 54 | + # the two legs below update their own combination instead of |
| 55 | + # collapsing into one (gotcha 402). |
| 56 | + tag: [cp38-abi3, cp314t] |
| 57 | + include: |
| 58 | + # pyo3's abi3-py38 feature is on unconditionally (Cargo.toml), so one |
| 59 | + # abi3 wheel serves every GIL-ful interpreter; pyo3 disables abi3 |
| 60 | + # under Py_GIL_DISABLED, giving the free-threaded build its own |
| 61 | + # wheel (matches the cp38-abi3 + cp314-cp314t split upstream |
| 62 | + # publishes). cp38 isn't in the manylinux_2_39_riscv64 image (it |
| 63 | + # ships cp39-cp315), so the abi3 wheel is built on cp39 instead. |
| 64 | + - tag: cp38-abi3 |
| 65 | + build: >- |
| 66 | + cp39-manylinux_riscv64 cp310-manylinux_riscv64 |
| 67 | + cp311-manylinux_riscv64 cp312-manylinux_riscv64 |
| 68 | + cp313-manylinux_riscv64 cp314-manylinux_riscv64 |
| 69 | + - tag: cp314t |
| 70 | + build: cp314t-manylinux_riscv64 |
| 71 | + |
| 72 | + env: |
| 73 | + RUFF_FORMAT_VERSION: ${{ matrix.version }} |
| 74 | + |
| 75 | + steps: |
| 76 | + - name: Checkout ruff-format v${{ env.RUFF_FORMAT_VERSION }} |
| 77 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 78 | + with: |
| 79 | + repository: reflex-dev/ruff-format |
| 80 | + ref: v${{ env.RUFF_FORMAT_VERSION }} |
| 81 | + persist-credentials: false |
| 82 | + |
| 83 | + - name: Build wheels |
| 84 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 85 | + with: |
| 86 | + output-dir: wheelhouse/ |
| 87 | + env: |
| 88 | + # musllinux is dropped: rustup.rs ships no riscv64 musl toolchain. |
| 89 | + CIBW_BUILD: ${{ matrix.build }} |
| 90 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 91 | + # ruff-format ships no [tool.cibuildwheel], so the Rust toolchain |
| 92 | + # its maturin backend needs is installed in-container here. |
| 93 | + CIBW_BEFORE_ALL_LINUX: >- |
| 94 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 95 | + CIBW_ENVIRONMENT_LINUX: PATH="$PATH:$HOME/.cargo/bin" |
| 96 | + # Upstream ships no test suite at all; exercise the three bound |
| 97 | + # functions against known-good outputs (verified against the |
| 98 | + # upstream ruff CLI) instead of an import-only smoke test. |
| 99 | + # ruff-format is a pure-Rust maturin project (no python-source in |
| 100 | + # pyproject.toml), so maturin wraps the extension in a generated |
| 101 | + # ruff_format/__init__.py ("from .ruff_format import *") rather than |
| 102 | + # shipping it as a flat top-level .so (gotcha 308) - probe the |
| 103 | + # compiled submodule via sys.modules, not the package's own |
| 104 | + # __file__, which is the shim. |
| 105 | + CIBW_TEST_COMMAND: >- |
| 106 | + python -c "import ruff_format as m, importlib.metadata as md, sys; |
| 107 | + assert sys.modules['ruff_format.ruff_format'].__file__.endswith('.so'), sys.modules['ruff_format.ruff_format'].__file__; |
| 108 | + assert any(str(p).endswith('licenses/LICENSE') for p in md.files('ruff-format')); |
| 109 | + assert m.is_valid_syntax('x = 1'); |
| 110 | + assert not m.is_valid_syntax('def f(:'); |
| 111 | + m.parse_code('x = 1'); |
| 112 | + assert m.format_string('def hello( x,y, z ):\n print( x+y+z )\n') == 'def hello(x, y, z):\n print(x + y + z)\n'; |
| 113 | + assert m.format_string('result = some_function_name(argument_one, argument_two, argument_three, argument_four)\n') == 'result = some_function_name(\n argument_one, argument_two, argument_three, argument_four\n)\n'; |
| 114 | + assert m.format_string('result = some_function_name(argument_one, argument_two, argument_three, argument_four)\n', line_width=120) == 'result = some_function_name(argument_one, argument_two, argument_three, argument_four)\n'" |
| 115 | +
|
| 116 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 117 | + with: |
| 118 | + name: ruff-format-${{ env.RUFF_FORMAT_VERSION }}-${{ matrix.tag }}-manylinux_riscv64 |
| 119 | + path: wheelhouse/*.whl |
| 120 | + if-no-files-found: error |
| 121 | + |
| 122 | + publish: |
| 123 | + name: Publish ruff-format ${{ matrix.version }} |
| 124 | + needs: [setup, build_wheels] |
| 125 | + if: needs.setup.outputs.versions != '[]' |
| 126 | + strategy: |
| 127 | + fail-fast: false |
| 128 | + matrix: |
| 129 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 130 | + permissions: |
| 131 | + contents: write |
| 132 | + pull-requests: write |
| 133 | + uses: $/.github/workflows/_publish-wheel.yml |
| 134 | + secrets: |
| 135 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 136 | + with: |
| 137 | + artifact-pattern: ruff-format-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments