Skip to content

workflows: migrate canonical cibuildwheel builds #74

workflows: migrate canonical cibuildwheel builds

workflows: migrate canonical cibuildwheel builds #74

Workflow file for this run

# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on the `build-wheels` job of
# https://github.com/phonopy/phonors/blob/v0.6.0/.github/workflows/release.yml
# and the `cargo` job of
# https://github.com/phonopy/phonors/blob/v0.6.0/.github/workflows/ci.yml
name: Build phonors wheels (riscv64)
on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/phonors.yaml not released yet'
required: false
default: ''
cancel-in-progress:
description: Cancel an in-progress run in the same concurrency group.
required: false
type: boolean
default: true
pull_request:
branches: [main]
paths:
- '.github/workflows/build-phonors.yml'
- 'docs/packages/phonors.yaml'
push:
branches: [main]
paths:
- '.github/workflows/build-phonors.yml'
- 'docs/packages/phonors.yaml'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ case(github.event_name == 'pull_request', true, github.event_name == 'workflow_dispatch', inputs['cancel-in-progress'], false) }}
permissions:
contents: read # to fetch code (actions/checkout)
env:
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: phonors
version: ${{ inputs.version }}
cargo:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
name: Test phonors ${{ matrix.version }} crate
runs-on: ubuntu-24.04-riscv
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
env:
PHONORS_VERSION: ${{ matrix.version }}
steps:
- name: Checkout phonors v${{ env.PHONORS_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: phonopy/phonors
ref: v${{ env.PHONORS_VERSION }}
persist-credentials: false
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: stable
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
python-version: '3.13'
activate-environment: true
enable-cache: false
- name: cargo test
run: |
export PYO3_PYTHON="$(which python)"
export LD_LIBRARY_PATH="$(python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')"
cargo test --no-default-features
build_wheels:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
name: Build phonors ${{ matrix.version }} ${{ matrix.tag }}-manylinux_riscv64
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
include:
- tag: cp310-abi3
build: >-
cp310-manylinux_riscv64 cp311-manylinux_riscv64
cp312-manylinux_riscv64 cp313-manylinux_riscv64
cp314-manylinux_riscv64
- tag: cp314t
build: cp314t-manylinux_riscv64
uses: $/.github/workflows/_build-cibuildwheel.yml
with:
package: "phonors"
version: "${{ matrix.version }}"
repository: "phonopy/phonors"
ref: "v${{ matrix.version }}"
artifact-tag: "${{ matrix.tag }}-manylinux_riscv64"
timeout-minutes: 90
cibw-build: "${{ matrix.build }}"
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: "numpy"
cibw-test-environment: "PIP_ONLY_BINARY=numpy"
# Upstream ships no Python test suite; check the extension against numpy directly.
cibw-test-command: >
python -c "import numpy as np, phonors, phonors.phonors as m;
assert m.__file__.endswith('.so'), m.__file__;
rng = np.random.default_rng(0);
a = rng.standard_normal((3, 6, 6)) + 1j * rng.standard_normal((3, 6, 6));
h = np.ascontiguousarray(a + a.conj().transpose(0, 2, 1));
w = np.zeros((3, 6));
phonors.eigvalsh_values_batch(h, w);
np.testing.assert_allclose(w, np.linalg.eigvalsh(h), atol=1e-10)"
publish:
name: Publish phonors ${{ matrix.version }}
needs: [setup, cargo, 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:
matrix: ${{ needs.setup.outputs.matrix }}
artifact-pattern: phonors-${{ matrix.version }}-*-manylinux_riscv64