Skip to content

Fix Rust HN example (#27) #44

Fix Rust HN example (#27)

Fix Rust HN example (#27) #44

Workflow file for this run

name: Python - Test & Publish Package
on:
workflow_dispatch:
push:
tags:
- 'v*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PACKAGE_NAME: chidori
PYTHON_VERSION: "3.9" # to build abi3 wheels
jobs:
python-macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64]
# if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
toolchain/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build wheels - x86_64
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --features python
maturin-version: "v1.1.0"
working-directory: toolchain/chidori
sccache: true
- name: Install built wheel - x86_64
working-directory: toolchain/chidori
run: |
pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
pip install pytest pytest-mock pytest-asyncio
pytest ./tests/python
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: toolchain/chidori/dist
python-macos-universal:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
toolchain/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build wheels - universal2
uses: messense/maturin-action@v1
with:
args: --release --out dist --features python --target universal2-apple-darwin
maturin-version: "v1.1.0"
working-directory: toolchain/chidori
sccache: true
- name: Install built wheel - universal2
working-directory: toolchain/chidori
run: |
pip install dist/${{ env.PACKAGE_NAME }}-*universal2.whl --force-reinstall
pip install pytest pytest-mock pytest-asyncio
pytest ./tests/python
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: toolchain/chidori/dist
python-windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ matrix.target }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
toolchain/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --features python
maturin-version: "v1.1.0"
working-directory: toolchain/chidori
sccache: true
- name: Install built wheel
shell: bash
working-directory: toolchain/chidori
run: |
python -m pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
pip install pytest pytest-mock pytest-asyncio
python -m pytest -v ./tests/python
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: toolchain/chidori/dist
python-linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist --features python
maturin-version: "v1.1.0"
working-directory: toolchain/chidori
sccache: true
- name: Install built wheel
working-directory: toolchain/chidori
if: matrix.target == 'x86_64'
run: |
pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
pip install pytest pytest-mock pytest-asyncio
pytest -v -p no:qt ./tests/python
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: toolchain/chidori/dist
# python-linux-cross:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# target: [aarch64]
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# with:
# python-version: ${{ env.PYTHON_VERSION }}
# - name: Build wheels
# uses: messense/maturin-action@v1
# with:
# target: ${{ matrix.target }}
# manylinux: auto
# args: --release --out dist --features python
# maturin-version: "v0.13.0"
# working-directory: toolchain/chidori
# sccache: true
# - uses: uraimo/[email protected]
# if: matrix.target != 'ppc64'
# name: Install built wheel
# with:
# arch: ${{ matrix.target }}
# distro: ubuntu20.04
# githubToken: ${{ github.token }}
# install: |
# apt-get update
# apt-get install -y --no-install-recommends python3 python3-pip
# pip3 install -U pip
# run: |
# pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall
# pip install pytest pytest-mock pytest-asyncio
# pytest -v
# - name: Upload wheels
# uses: actions/upload-artifact@v3
# with:
# name: wheels
# path: toolchain/chidori/dist
release:
name: Release
runs-on: ubuntu-latest
needs:
- python-macos
- python-macos-universal
- python-windows
- python-linux
# - python-linux-cross
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- uses: actions/setup-python@v2
- name: Publish to PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
pip install --upgrade twine upload --skip-existing *