|
| 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/sbdchd/squawk/blob/v2.63.0/.github/workflows/python.yml |
| 6 | +name: Build squawk-cli 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/squawk-cli.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-squawk-cli.yml' |
| 19 | + - 'docs/packages/squawk-cli.yaml' |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + paths: |
| 23 | + - '.github/workflows/build-squawk-cli.yml' |
| 24 | + - 'docs/packages/squawk-cli.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: squawk-cli |
| 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 squawk-cli ${{ matrix.version }} manylinux_riscv64 |
| 48 | + runs-on: ubuntu-24.04-riscv |
| 49 | + timeout-minutes: 1440 |
| 50 | + |
| 51 | + env: |
| 52 | + SQUAWK_CLI_VERSION: ${{ matrix.version }} |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: Checkout squawk v${{ env.SQUAWK_CLI_VERSION }} |
| 56 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 57 | + with: |
| 58 | + repository: sbdchd/squawk |
| 59 | + ref: v${{ env.SQUAWK_CLI_VERSION }} |
| 60 | + persist-credentials: false |
| 61 | + |
| 62 | + # `[tool.maturin] bindings = "bin"`: the wheel is one compiled executable |
| 63 | + # with no ABI tag, so a single native build covers every interpreter. |
| 64 | + # `maturin-version` left unset because upstream's v1.7.1 pin predates |
| 65 | + # maturin's riscv64 release assets (gotcha 344). |
| 66 | + - name: Build wheel |
| 67 | + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 |
| 68 | + with: |
| 69 | + command: build |
| 70 | + target: riscv64gc-unknown-linux-gnu |
| 71 | + working-directory: crates/squawk |
| 72 | + args: --release --locked --out dist |
| 73 | + manylinux: '2_39' |
| 74 | + # `perl-core` replaces upstream's `perl-IPC-Cmd`: Rocky 10 also lacks |
| 75 | + # FindBin, which openssl-src's vendored OpenSSL build needs. |
| 76 | + before-script-linux: | |
| 77 | + git config --global --add safe.directory "*" |
| 78 | + dnf -y install perl-core |
| 79 | +
|
| 80 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 81 | + with: |
| 82 | + name: squawk-cli-${{ env.SQUAWK_CLI_VERSION }}-manylinux_riscv64 |
| 83 | + path: crates/squawk/dist/*.whl |
| 84 | + if-no-files-found: error |
| 85 | + |
| 86 | + test_wheel: |
| 87 | + name: Test squawk-cli ${{ matrix.version }} on Python ${{ matrix.python-version }} |
| 88 | + needs: [setup, build_wheel] |
| 89 | + if: needs.setup.outputs.versions != '[]' |
| 90 | + runs-on: ubuntu-24.04-riscv |
| 91 | + timeout-minutes: 30 |
| 92 | + env: |
| 93 | + SQUAWK_CLI_VERSION: ${{ matrix.version }} |
| 94 | + # Without this uv would reuse the runner image's system CPython for 3.12 |
| 95 | + # and download a standalone build for the others. |
| 96 | + UV_PYTHON_PREFERENCE: only-managed |
| 97 | + strategy: |
| 98 | + fail-fast: false |
| 99 | + matrix: |
| 100 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 101 | + # This repo's default interpreter matrix; the wheel is |
| 102 | + # interpreter-agnostic (bindings = "bin"), so every interpreter -- |
| 103 | + # including free-threaded -- exercises the same binary. |
| 104 | + python-version: ['3.12', '3.13', '3.14', '3.14t'] |
| 105 | + |
| 106 | + steps: |
| 107 | + - name: Download wheel |
| 108 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 109 | + with: |
| 110 | + name: squawk-cli-${{ env.SQUAWK_CLI_VERSION }}-manylinux_riscv64 |
| 111 | + |
| 112 | + - name: Install Python |
| 113 | + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 |
| 114 | + with: |
| 115 | + python-version: ${{ matrix.python-version }} |
| 116 | + activate-environment: true |
| 117 | + enable-cache: false |
| 118 | + |
| 119 | + - name: Install wheel |
| 120 | + run: uv pip install --reinstall --no-index --find-links . squawk-cli |
| 121 | + |
| 122 | + # Upstream ships no wheel-level test suite (its Rust suite is not packaged, |
| 123 | + # gotcha 187), and the wheel carries only the .data/scripts/squawk binary |
| 124 | + # with no importable module, so there is no `python -m squawk` either. |
| 125 | + # Drive the linter against a migration that trips known rules instead. |
| 126 | + - name: Test wheel |
| 127 | + run: | |
| 128 | + set -euo pipefail |
| 129 | + squawk --version |
| 130 | + squawk --help >/dev/null |
| 131 | + squawk upload-to-github --help >/dev/null |
| 132 | + file "$(command -v squawk)" | grep -q ELF |
| 133 | +
|
| 134 | + work=$(mktemp -d) |
| 135 | + printf 'ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL;\n' > "$work/bad.sql" |
| 136 | + printf 'SELECT 1;\n' > "$work/ok.sql" |
| 137 | +
|
| 138 | + squawk "$work/ok.sql" |
| 139 | +
|
| 140 | + rc=0 |
| 141 | + squawk "$work/bad.sql" || rc=$? |
| 142 | + [ "$rc" -eq 1 ] |
| 143 | +
|
| 144 | + rc=0 |
| 145 | + squawk --reporter json "$work/bad.sql" > "$work/all.json" || rc=$? |
| 146 | + [ "$rc" -eq 1 ] |
| 147 | + grep -q '"rule_name":"adding-required-field"' "$work/all.json" |
| 148 | + grep -q '"rule_name":"prefer-bigint-over-int"' "$work/all.json" |
| 149 | +
|
| 150 | + rc=0 |
| 151 | + squawk --exclude=prefer-bigint-over-int --reporter json "$work/bad.sql" > "$work/fewer.json" || rc=$? |
| 152 | + [ "$rc" -eq 1 ] |
| 153 | + grep -q '"rule_name":"adding-required-field"' "$work/fewer.json" |
| 154 | + ! grep -q '"rule_name":"prefer-bigint-over-int"' "$work/fewer.json" |
| 155 | +
|
| 156 | + publish: |
| 157 | + name: Publish squawk-cli ${{ matrix.version }} |
| 158 | + needs: [setup, build_wheel, test_wheel] |
| 159 | + if: needs.setup.outputs.versions != '[]' |
| 160 | + strategy: |
| 161 | + fail-fast: false |
| 162 | + matrix: |
| 163 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 164 | + permissions: |
| 165 | + contents: write |
| 166 | + pull-requests: write |
| 167 | + uses: $/.github/workflows/_publish-wheel.yml |
| 168 | + secrets: |
| 169 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 170 | + with: |
| 171 | + artifact-pattern: squawk-cli-${{ matrix.version }}-manylinux_riscv64 |
0 commit comments