Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions .github/workflows/build-cocoindex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on the `generate-3p-notices`/`build`/`test-abi3`/
# `test-free-threaded` jobs of
# https://github.com/cocoindex-io/cocoindex/blob/v1.0.20/.github/workflows/release.yml
name: Build cocoindex wheels (riscv64)

on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/cocoindex.yaml not released yet'
required: false
default: ''
pull_request:
branches: [main]
paths:
- '.github/workflows/build-cocoindex.yml'
- 'docs/packages/cocoindex.yaml'
push:
branches: [main]
paths:
- '.github/workflows/build-cocoindex.yml'
- 'docs/packages/cocoindex.yaml'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read # to fetch code (actions/checkout)

env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# cocoindex_code_ast alone links ~35 tree-sitter grammar crates, each compiling
# its own C sources via `cc`; capped to avoid resource exhaustion on the
# riscv64 runner (build-valkey-glide.yml/build-daft.yml need the same).
CARGO_BUILD_JOBS: 2

jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: cocoindex
version: ${{ inputs.version }}

build_wheels:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
name: Build cocoindex ${{ matrix.version }} ${{ matrix.flavor.tag }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 480
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
flavor:
# rust/py's `abi3` feature (pyo3/abi3-py311) is default-on, so this
# one build serves every GIL-ful interpreter cp311+ as `cp311-abi3`
# -- matching the wheels PyPI already carries for 1.0.20.
- tag: cp311-abi3
interpreter: cp311
free-threaded: false
extra-args: ''
# abi3 cannot target free-threaded CPython, so upstream's own release
# job drops the feature instead of passing an abi3-pyNN variant.
- tag: cp314-cp314t
interpreter: cp314t
free-threaded: true
extra-args: '--no-default-features'

env:
COCOINDEX_VERSION: ${{ matrix.version }}

steps:
- name: Checkout cocoindex v${{ env.COCOINDEX_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: cocoindex-io/cocoindex
ref: v${{ env.COCOINDEX_VERSION }}
persist-credentials: false

# Cargo.toml carries a workspace placeholder version (999.0.0); upstream's
# own release job derives the real one from the pushed tag via this exact
# script, so feeding it the tag we checked out (rather than a real tag
# push) reproduces the same Cargo.toml/pyproject.toml/_version.py edits.
- name: Set package version
env:
GITHUB_REF: refs/tags/v${{ env.COCOINDEX_VERSION }}
run: python3 ./.github/scripts/update_version.py

- name: Determine target interpreter
id: interp
run: |
v="${{ matrix.flavor.interpreter }}"
v="${v#cp}"
echo "value=python${v:0:1}.${v:1}" >> "$GITHUB_OUTPUT"

- name: Build wheel
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
target: riscv64gc-unknown-linux-gnu
args: >-
--release --out dist
-i ${{ steps.interp.outputs.value }}
${{ matrix.flavor.extra-args }}
manylinux: '2_39'
# pyproject.toml declares `license-files = ["THIRD_PARTY_NOTICES.html"]`
# and `include = [...]` the same file; upstream's own `generate-3p-notices`
# job produces it with this exact command (about.toml/about.hbs are
# already checked in) rather than committing it, so it is regenerated
# here before maturin packages the wheel.
before-script-linux: |
set -euo pipefail
git config --global --add safe.directory "*"
cargo install cargo-about --locked --features cli
cargo about generate -o THIRD_PARTY_NOTICES.html about.hbs

- name: Install Python
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
python-version: ${{ steps.interp.outputs.value }}
activate-environment: true
enable-cache: false

- name: Verify free-threaded interpreter
if: matrix.flavor.free-threaded
run: |
python -c "import sys; print(f'GIL enabled: {sys._is_gil_enabled()}'); sys.exit(1) if sys._is_gil_enabled() else None"

- name: Test wheel
env:
# numpy/psutil have no riscv64 wheels upstream; both are already
# published by this repo (docs/packages/numpy.yaml, psutil.yaml).
UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/
UV_INDEX_STRATEGY: unsafe-best-match
run: |
uv pip install --find-links dist cocoindex
python -c "import cocoindex, sys; print('import ok on', sys.version)"

- name: Check wheel contents
run: |
python3 - dist/*.whl <<'EOF'
import sys, zipfile
names = zipfile.ZipFile(sys.argv[1]).namelist()
sos = [n for n in names if n.endswith('.so')]
assert sos and all(n.startswith('cocoindex/_internal/core') for n in sos), sos
lic = {n.rsplit('/', 1)[1] for n in names if '.dist-info/licenses/' in n} - {''}
assert lic == {'THIRD_PARTY_NOTICES.html'}, lic
print('OK:', sys.argv[1], sos, lic)
EOF

- name: Store wheels
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cocoindex-${{ env.COCOINDEX_VERSION }}-${{ matrix.flavor.tag }}-manylinux_riscv64
path: dist/*.whl
if-no-files-found: error

publish:
name: Publish cocoindex ${{ 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: cocoindex-${{ matrix.version }}-*-manylinux_riscv64
5 changes: 5 additions & 0 deletions docs/packages/cocoindex.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package-name: cocoindex
source-code: https://github.com/cocoindex-io/cocoindex
license: Apache-2.0
versions:
- version: 1.0.20
Loading