name: CI
on:
push:
branches: ["main"]
release:
types: [published]
pull_request:
types: [opened, reopened, synchronize]
branches: ["main"]
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
rust:
runs-on: ubuntu-24.04
concurrency:
group: rust-${{ matrix.toolchain }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
strategy:
matrix:
toolchain:
- 1.91.0 - stable
- beta
- nightly
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- name: Update Rust toolchain
run: rustup update ${TOOLCHAIN} && rustup default ${TOOLCHAIN}
env:
TOOLCHAIN: ${{ matrix.toolchain }}
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
linux:
runs-on: ${{ matrix.platform.runner || 'ubuntu-24.04' }}
concurrency:
group: linux-${{ matrix.platform.target }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
strategy:
matrix:
platform:
- target: x86_64
feat-flags: "cuda,pyo3"
- target: aarch64
runner: ubuntu-24.04-arm
arch: sbsa
feat-flags: "cuda,pyo3"
- target: riscv64
runner: ubuntu-24.04-riscv
manylinux: "2_39"
- target: armv7
- target: s390x
- target: ppc64le
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 if: ${{ matrix.platform.target != 'riscv64' }}
with:
python-version: "3.13"
- uses: riseproject-dev/setup-python@8b57351c0f828145e2ac14bd328c731503361b7a if: ${{ matrix.platform.target == 'riscv64' }}
with:
python-version: "3.13"
mirror: "https://raw.githubusercontent.com/riseproject-dev/python-versions/main"
- name: Build wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b with:
target: ${{ matrix.platform.target }}
args: --release --locked --compatibility pypi --features ${{ matrix.platform.feat-flags || 'pyo3' }} --out dist --interpreter python3.13
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
manylinux: ${{ matrix.platform.manylinux || '2_28' }}
before-script-linux: |
# Install nvTIFF and clang-devel
if command -v dnf &> /dev/null && test $(uname -m) != "riscv64"; then
# https://developer.nvidia.com/nvtiff-0-7-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Rocky&target_version=8&target_type=rpm_network
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/${{ matrix.platform.arch || 'x86_64' }}/cuda-rhel8.repo
dnf clean all
dnf install -y clang-devel cuda-crt-13-0 cuda-cudart-devel-13-0 nvtiff-cuda-13-0.7.0.* libnvtiff0-cuda-13-0.7.0.*
# Patch nvtiff.h (v0.7.0) to add missing enum tag
sed --in-place "s/nvtiffTagDataType type/enum nvtiffTagDataType type/g" /usr/include/nvtiff.h
# elif command -v apt &> /dev/null; then
# # https://developer.nvidia.com/nvtiff-0-7-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=24.04&target_type=deb_network
# wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
# dpkg -i cuda-keyring_1.1-1_all.deb
# apt update
# apt install -y cuda-crt-13-0 cuda-cudart-dev-13-0 nvtiff-cuda-13=0.7.0.* libclang-dev gcc-multilib
fi
- name: Build free-threaded wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b with:
target: ${{ matrix.platform.target }}
args: --release --locked --compatibility pypi --features ${{ matrix.platform.feat-flags || 'pyo3' }} --out dist --interpreter python3.14t
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
manylinux: ${{ matrix.platform.manylinux || '2_28' }}
before-script-linux: |
# Install nvTIFF and clang-devel
if command -v dnf &> /dev/null && test $(uname -m) != "riscv64"; then
# https://developer.nvidia.com/nvtiff-0-7-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Rocky&target_version=8&target_type=rpm_network
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/${{ matrix.platform.arch || 'x86_64' }}/cuda-rhel8.repo
dnf clean all
dnf install -y clang-devel cuda-crt-13-0 cuda-cudart-devel-13-0 nvtiff-cuda-13-0.7.0.* libnvtiff0-cuda-13-0.7.0.*
# Patch nvtiff.h (v0.7.0) to add missing enum tag
sed --in-place "s/nvtiffTagDataType type/enum nvtiffTagDataType type/g" /usr/include/nvtiff.h
# elif command -v apt &> /dev/null; then
# # https://developer.nvidia.com/nvtiff-0-7-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=24.04&target_type=deb_network
# wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
# dpkg -i cuda-keyring_1.1-1_all.deb
# apt update
# apt install -y cuda-crt-13-0 cuda-cudart-dev-13-0 nvtiff-cuda-13=0.7.0.* libclang-dev gcc-multilib
fi
- name: Upload wheels
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist/
- name: pytest
if: ${{ endswith(matrix.platform.target, '64') }} shell: bash
run: |
set -e
python3 -m venv .venv
source .venv/bin/activate
pip install cog3pio --no-index --no-deps --find-links dist --force-reinstall -vv
pip install cog3pio --prefer-binary --group tests
pytest --verbose
env:
PIP_EXTRA_INDEX_URL: ${{ matrix.platform.target == 'riscv64' && 'https://gitlab.com/api/v4/projects/56254198/packages/pypi/simple/' || '' }}
- name: pytest
if: ${{ !endswith(matrix.platform.target, '64') && !startsWith(github.ref, 'refs/tags/') }} uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 with:
arch: ${{ matrix.platform.target }}
distro: ubuntu_devel
githubToken: ${{ github.token }}
install: |
apt update
apt install -y --no-install-recommends \
gcc g++ gfortran libopenblas-dev liblapack-dev ninja-build \
pkg-config python3-pip python3-dev python3-venv
run: |
set -e
python3 -m venv .venv
source .venv/bin/activate
pip3 install -U pip
ls -lh dist/
pip3 install cog3pio --no-index --no-deps --find-links dist --force-reinstall -vv
pip3 install cog3pio --group tests
pytest --verbose
windows:
runs-on: windows-2025
concurrency:
group: windows-${{ matrix.target }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
strategy:
matrix:
target: [x64]
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 with:
python-version: "3.13"
architecture: ${{ matrix.target }}
- name: Support longpaths
run: git config --system core.longpaths true
- name: Build wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b with:
target: ${{ matrix.target }}
args: --release --locked --compatibility pypi --out dist
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 with:
python-version: "3.14t"
architecture: ${{ matrix.target }}
- name: Build free-threaded wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b with:
target: ${{ matrix.target }}
args: --release --locked --compatibility pypi --out dist -i python3.14t
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- name: Upload wheels
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f with:
name: wheels-windows-${{ matrix.target }}
path: dist/
- name: pytest
shell: bash
run: |
set -e
python3 -m venv .venv
source .venv/Scripts/activate
pip install cog3pio --no-index --no-deps --find-links dist --force-reinstall -vv
pip install cog3pio --group tests
pytest --verbose
macos:
runs-on: ${{ matrix.platform.runner }}
concurrency:
group: macos-${{ matrix.platform.target }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
strategy:
matrix:
platform:
- runner: macos-15-intel
target: x86_64
- runner: macos-14
target: aarch64
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 with:
python-version: "3.13"
- name: Build wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b with:
target: ${{ matrix.platform.target }}
args: --release --locked --compatibility pypi --out dist
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- name: Build free-threaded wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b with:
target: ${{ matrix.platform.target }}
args: --release --locked --compatibility pypi --out dist -i python3.14t
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- name: Upload wheels
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist/
- name: pytest
run: |
set -e
python3 -m venv .venv
source .venv/bin/activate
pip install cog3pio --no-index --no-deps --find-links dist --force-reinstall -vv
pip install cog3pio --group tests
pytest --verbose
sdist:
runs-on: ubuntu-24.04
concurrency:
group: sdist-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- name: Build sdist
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f with:
name: wheels-sdist
path: dist/
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
if: startsWith(github.ref, 'refs/tags/')
needs: [linux, windows, macos, sdist]
runs-on: ubuntu-24.04
concurrency:
group: testpypi-${{ github.ref }}
cancel-in-progress: true
environment:
name: testpypi
url: https://test.pypi.org/project/cog3pio
permissions:
id-token: write
steps:
- name: Download built wheels
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 with:
path: dist/
merge-multiple: true
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b with:
repository-url: https://test.pypi.org/legacy/
verbose: true
publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
runs-on: ubuntu-24.04
concurrency:
group: pypi-${{ github.ref }}
cancel-in-progress: true
environment:
name: pypi
url: https://pypi.org/project/cog3pio/
if: github.event.release.prerelease == false && startsWith(github.ref, 'refs/tags/')
needs: [linux, windows, macos, sdist]
permissions:
id-token: write steps:
- name: Download built wheels
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 with:
path: dist/
merge-multiple: true
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b with:
verbose: true