diff --git a/.github/workflows/build-sqlglotc.yml b/.github/workflows/build-sqlglotc.yml new file mode 100644 index 00000000000..32004b6844d --- /dev/null +++ b/.github/workflows/build-sqlglotc.yml @@ -0,0 +1,100 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +# +# sqlglotc is the mypyc-compiled companion extension for sqlglot: cibuildwheel +# builds the `sqlglotc/` subdirectory of the tobymao/sqlglot monorepo, whose +# setup.py mypyc-compiles a subset of sqlglot's own modules and ships the +# resulting .so files under the `sqlglot.*` namespace (Requires-Dist pins the +# matching `sqlglot==`, so importing `sqlglot` picks up the compiled +# extensions transparently). Upstream publishes wheels for cp310-cp314 (no +# cp314t - "mypyc doesn't have great support for free threaded builds", same +# as build-black.yml) on every platform except riscv64; sqlglotc/pyproject.toml +# carries no [tool.cibuildwheel] table, so CIBW_* here isn't overriding +# anything upstream committed (mirroring .github/workflows/package-publish.yml's +# build-wheels job instead). Testing runs upstream's own `make unitc` recipe +# (SKIP_INTEGRATION=1 python -m unittest) against the installed compiled +# wheel; duckdb and pandas (imported by tests/test_optimizer.py and +# tests/test_executor.py) come from our registry since neither ships riscv64 +# wheels on public PyPI. +name: Build sqlglotc wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'sqlglotc version to build (git tag, e.g. 30.17.0)' + required: true + default: '30.17.0' + pull_request: + paths: + - '.github/workflows/build-sqlglotc.yml' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '30.17.0' }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +env: + SQLGLOTC_VERSION: ${{ inputs.version || '30.17.0' }} + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + + build_wheels: + needs: [setup] + name: Build sqlglotc ${{ inputs.version || '30.17.0' }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 180 + strategy: + fail-fast: false + matrix: + # mypyc emits per-interpreter (non-abi3) wheels; upstream skips free-threaded, so no cp314t. + python: ["cp312", "cp313", "cp314"] + + steps: + # Full monorepo checkout: sqlglotc/setup.py compiles from the sibling + # ../sqlglot source tree, and tests/ (used below) lives at the repo root. + - name: Checkout sqlglot ${{ env.SQLGLOTC_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: tobymao/sqlglot + ref: v${{ env.SQLGLOTC_VERSION }} + fetch-depth: 0 + persist-credentials: false + + - name: Build wheels + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + package-dir: sqlglotc + only: ${{ matrix.python }}-manylinux_riscv64 + env: + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + CIBW_TEST_REQUIRES: duckdb pandas python-dateutil pytz + CIBW_ENVIRONMENT_PASS_LINUX: PIP_EXTRA_INDEX_URL PIP_ONLY_BINARY + PIP_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/ + # PyPI's newest pandas (3.0.5) ships no riscv64 wheel anywhere yet; + # without this, pip resolves it over our registry's 3.0.3 (which + # does have one) and falls back to a from-source build that never + # finishes in CI's time budget. + PIP_ONLY_BINARY: pandas + CIBW_TEST_COMMAND: cd {project} && SKIP_INTEGRATION=1 python -m unittest + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: sqlglotc-${{ env.SQLGLOTC_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish sqlglotc ${{ inputs.version || '30.17.0' }} + needs: [setup, build_wheels] + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + with: + artifact-pattern: sqlglotc-${{ inputs.version || '30.17.0' }}-*-manylinux_riscv64