Merge pull request #29 from algorandfoundation/ci/rm_paths #158
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python CI | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- "*" | |
pull_request: | |
branches: | |
- master | |
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@master | |
with: | |
toolchain: 1.82.0 | |
targets: ${{ matrix.target.name }} | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
cache: "pip" # caching pip dependencies | |
- name: pip install | |
run: | | |
cd packages/python/${{ env.CRATE }} | |
pip install ".[dev]" | |
- 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: | | |
cd packages/python/${{ env.CRATE }} | |
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 }} --default-toolchain=1.82.0 | |
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: Install pip-tools | |
env: | |
RUN: python${{ env.PYTHON_VERSION }} -m pip install pip-tools | |
run: docker exec build-container bash -c "$RUN" | |
- name: Install dependencies | |
env: | |
RUN: | | |
set -e | |
cd /workspace/packages/python/${{ env.CRATE }} | |
python${{ env.PYTHON_VERSION }} -m piptools compile pyproject.toml --extra dev -o requirements.txt | |
python${{ env.PYTHON_VERSION }} -m pip install -r requirements.txt | |
run: docker exec build-container bash -c "$RUN" | |
- name: maturin build | |
env: | |
RUN: | | |
cd /workspace/packages/python/${{ env.CRATE }} | |
python${{ env.PYTHON_VERSION }} -m maturin build --release --target ${{ env.TARGET }} --compatibility ${{ env.MANYLINUX }} --features ffi_uniffi | |
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: Debug module contents | |
env: | |
RUN: | | |
python${{ env.PYTHON_VERSION }} -c "import algo_models; print('Available attributes:', dir(algo_models))" | |
run: docker exec build-container bash -c "$RUN" | |
- name: pytest | |
env: | |
RUN: | | |
cd /workspace/packages/python/${{ env.CRATE }} | |
python${{ env.PYTHON_VERSION }} -m pytest | |
run: docker exec build-container bash -c "$RUN" |