diff --git a/.github/workflows/build-cql2.yml b/.github/workflows/build-cql2.yml new file mode 100644 index 000000000000..f2d283a4c56c --- /dev/null +++ b/.github/workflows/build-cql2.yml @@ -0,0 +1,122 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on the `linux`/`musllinux` jobs of +# https://github.com/developmentseed/cql2-rs/blob/cql2-v0.6.0/.github/workflows/pypi.yml +name: Build cql2 wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'Version glob to (re)build; empty builds every version of docs/packages/cql2.yaml not released yet' + required: false + default: '' + pull_request: + branches: [main] + paths: + - '.github/workflows/build-cql2.yml' + - 'docs/packages/cql2.yaml' + push: + branches: [main] + paths: + - '.github/workflows/build-cql2.yml' + - 'docs/packages/cql2.yaml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + MUSLLINUX_RISCV64_IMAGE: quay.io/pypa/musllinux_1_2_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + with: + package: cql2 + version: ${{ inputs.version }} + + build_wheels: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + name: Build cql2 ${{ matrix.version }} cp312-abi3-${{ matrix.platform }}_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + platform: ["manylinux", "musllinux"] + + env: + CQL2_VERSION: ${{ matrix.version }} + + steps: + - name: Checkout cql2-rs cql2-v${{ env.CQL2_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: developmentseed/cql2-rs + ref: cql2-v${{ env.CQL2_VERSION }} + persist-credentials: false + + - name: Build wheels + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + output-dir: wheelhouse/ + env: + # pyo3's abi3-py310 feature is on unconditionally (python/Cargo.toml), + # so one abi3 wheel serves every interpreter in our matrix; upstream + # ships only a cp310-abi3 wheel, no free-threaded (cp314t) variant, + # so there is no separate free-threaded job either. Built on cp312 + # (our floor) and re-tested on cp313/cp314 via cibuildwheel's + # find_compatible_wheel logic. + CIBW_BUILD: >- + cp312-${{ matrix.platform }}_riscv64 cp313-${{ matrix.platform }}_riscv64 + cp314-${{ matrix.platform }}_riscv64 + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + CIBW_MUSLLINUX_RISCV64_IMAGE: ${{ env.MUSLLINUX_RISCV64_IMAGE }} + # cql2's pyproject.toml ships no [tool.cibuildwheel], so the Rust + # toolchain its maturin backend needs is installed in-container. + CIBW_BEFORE_ALL_LINUX: >- + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + CIBW_ENVIRONMENT_LINUX: PATH="$PATH:$HOME/.cargo/bin" + CIBW_TEST_REQUIRES: pytest + # python/tests' conftest.py resolves fixtures via + # Path(__file__).parents[2] / "examples", i.e. two levels above + # python/tests -- staging examples/ alongside it keeps that path valid. + CIBW_TEST_SOURCES: python/tests examples + # No python-source in pyproject.toml, so maturin ships an + # auto-generated cql2/__init__.py shim around the compiled + # cql2/cql2 submodule -- probe that submodule before running + # upstream's own tests. + CIBW_TEST_COMMAND: >- + python -c "import cql2.cql2 as m; assert m.__file__.endswith('.so'), m.__file__" && + python -m pytest -v python/tests + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: cql2-${{ env.CQL2_VERSION }}-cp312-abi3-${{ matrix.platform }}_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish cql2 ${{ matrix.version }} + needs: [setup, build_wheels] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + secrets: + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} + with: + artifact-pattern: cql2-${{ matrix.version }}-*_riscv64 diff --git a/docs/packages/cql2.yaml b/docs/packages/cql2.yaml new file mode 100644 index 000000000000..90bdd9291737 --- /dev/null +++ b/docs/packages/cql2.yaml @@ -0,0 +1,5 @@ +package-name: cql2 +source-code: https://github.com/developmentseed/cql2-rs +license: MIT +versions: +- version: 0.6.0