Skip to content

build(typescript): use rollup for cjs and esm #123

build(typescript): use rollup for cjs and esm

build(typescript): use rollup for cjs and esm #123

Workflow file for this run

name: Python CI
on:
push:
paths:
- crates/algo_models_ffi/**
- crates/algo_models/**
- "!*.md"
branches:
- main
- master
tags:
- "*"
pull_request:
paths:
- crates/algo_models_ffi/**
- creates/algo_models/**
- packages/python/**
- "!*.md"
workflow_dispatch:
permissions:
contents: read
env:
CRATE: algo_models
# Python >= 3.8 is needed to support manylinux_x_y tags (unless you want to manually update pip)
# Python 3.10 was chosen because it is currently the most popular according to https://mayeut.github.io/manylinux-timeline/
PYTHON_VERSION: "3.10"
jobs:
build_and_test:
defaults:
run:
shell: bash
runs-on: ${{ matrix.target.runner }}
strategy:
matrix:
target:
# name: The name of the target passed to cargo build
# runner: The GitHub runner to use
- name: x86_64-pc-windows-msvc
runner: windows-latest
- name: aarch64-pc-windows-msvc
runner: windows-latest
- name: x86_64-apple-darwin
runner: macos-13
- name: aarch64-apple-darwin
runner: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target.name }}
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip" # caching pip dependencies
- run: pip install maturin
- name: Install python dependencies
run: pip install -r crates/${{ env.CRATE }}_ffi/tests/py/requirements.txt
- name: maturin build
run: |
cd crates/${{ env.CRATE }}_ffi
maturin build --release --target ${{ matrix.target.name }}
- name: pytest
# Until GitHub makes windows arm64 runners publicly available, there is not a simple way to test aarch64-pc-windows-msvc
# GitHub is currently working on making them available but no ETA: https://github.com/actions/runner-images/issues/10820
if: matrix.target.name != 'aarch64-pc-windows-msvc'
run: |
set -e
pip install target/wheels/*.whl
cd crates/${{ env.CRATE }}_ffi
pytest
linux_build_and_test:
defaults:
run:
shell: bash
runs-on: ubuntu-22.04${{ matrix.arch == 'aarch64' && '-arm' || '' }}
strategy:
matrix:
# i686, ppc64le, s390x are also supported but not running them for now to reduce CI time
# We might not ever need to support them, but we can make that decision later
# As a useful datapoint, PyNaCl only builds x86_64 and aarch64 wheels
# https://github.com/pyca/pynacl/blob/9ffa598e47242bf783aae23c20c31e876c438f1a/.github/workflows/wheel-builder.yml#L32-L41
arch: [aarch64, x86_64]
libc: [gnu, musl]
exclude:
- arch: s390x
libc: musl
- arch: i686
libc: musl
- arch: ppc64le
libc: musl
env:
# See https://github.com/pypa/manylinux for more information on manylinux
# Generally it's good to try to support the glibc version from two RHEL releases ago (roughly within EOM period)
# The current RHEL release (as of 2/7/2025) is 9 and the glibc version from RHEL 7 was 2.17 (aka manylinux2014)
MANYLINUX: ${{ matrix.libc == 'musl' && 'musllinux_1_2' || 'manylinux2014' }}
TARGET: ${{ matrix.arch == 'ppc64le' && 'powerpc64le' || matrix.arch }}-unknown-linux-${{ matrix.libc }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
if: matrix.arch != 'aarch64' && matrix.arch != 'x86_64'
uses: docker/setup-qemu-action@v3
- name: Start Container
env:
container: quay.io/pypa/${{ env.MANYLINUX }}_${{ matrix.arch }}
run: |
set -e
docker pull ${{ env.container }}
docker run --name build-container \
-d \
-v ${{ github.workspace }}:/workspace \
-e CARGO_HOME="/usr/local" \
${{ env.container }} \
tail -f /dev/null
- name: Install Rustup
env:
RUN: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-host ${{ env.TARGET }}
run: docker exec build-container bash -c "$RUN"
- name: rustup target add
env:
RUN: rustup target add ${{ env.TARGET }}
run: docker exec build-container bash -c "$RUN"
- name: pip install maturin[patchelf]
env:
RUN: python${{ env.PYTHON_VERSION }} -m pip install maturin[patchelf]
run: docker exec build-container bash -c "$RUN"
- name: maturin build
env:
RUN: |
cd /workspace/crates/${{ env.CRATE }}_ffi
python${{ env.PYTHON_VERSION }} -m maturin build --release --target ${{ env.TARGET }} --compatibility ${{ env.MANYLINUX }}
run: docker exec build-container bash -c "$RUN"
- name: pip install wheel
env:
RUN: python${{ env.PYTHON_VERSION }} -m pip install /workspace/target/wheels/*.whl
run: docker exec build-container bash -c "$RUN"
- name: pip install test requirements
env:
RUN: python${{ env.PYTHON_VERSION }} -m pip install -r /workspace/crates/${{ env.CRATE }}_ffi/tests/py/requirements.txt
run: docker exec build-container bash -c "$RUN"
- name: pytest
env:
RUN: |
cd /workspace/crates/${{ env.CRATE }}_ffi
python${{ env.PYTHON_VERSION }} -m pytest
run: docker exec build-container bash -c "$RUN"