Skip to content

Commit

Permalink
testing the new deployment pipeline (#89)
Browse files Browse the repository at this point in the history
Co-authored-by: Cellan Hall <[email protected]>
  • Loading branch information
maxwellflitton and Ce11an authored Mar 13, 2024
1 parent 7de2c20 commit 71ec849
Show file tree
Hide file tree
Showing 50 changed files with 4,427 additions and 4,353 deletions.
46 changes: 0 additions & 46 deletions .github/actions/action.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: ci

on:
push:
tags:
- '**'
pull_request: {}

jobs:
test-python:
name: test ${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: install rust stable
uses: dtolnay/rust-toolchain@stable

- name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: test-v3

- name: set up python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# Issue with requests < 2.29.0 and docker. See: https://github.com/docker/docker-py/issues/3113
- run: pip install docker requests==2.28.2

- run: pip install -e .
env:
RUST_BACKTRACE: 1

- run: pip freeze

- run: sh scripts/run_tests.sh

- run: cargo test

240 changes: 81 additions & 159 deletions .github/workflows/cross_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,184 +4,106 @@ on:
pull_request:
types: [closed]
branches:
- main
- release-staging

env:
CARGO_TERM_COLOR: always

jobs:

wait-for-other-workflow:
name: Wait for Other Workflow
linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- name: Wait for Other Workflow to Complete
run: "echo 'Waiting for other workflow to complete...'"

build: # Workflow credit to https://github.com/samuelcolvin/rtoml/blob/main/.github/workflows/ci.yml
if: github.event.pull_request.merged == true
name: >
build ${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
(${{ matrix.alt_arch_name || matrix.arch }})
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.target }}
path: dist

windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: ["cp310", "pp37", "pp38", "pp39"]
arch: [main, alt]
include:
- os: ubuntu
platform: linux
- os: windows
ls: dir
- os: macos
arch: alt
alt_arch_name: "arm64 universal2"
exclude:
- os: macos
python-version: "pp37"
arch: alt
- os: macos
python-version: "pp38"
arch: alt
- os: macos
python-version: "pp39"
arch: alt
runs-on: ${{ format('{0}-latest', matrix.os) }}
target: [x64, x86]
steps:
- uses: actions/checkout@v3

- name: set up python
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: set up rust
uses: dtolnay/rust-toolchain@stable
python-version: '3.10'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
toolchain: stable

- name: update pip version
run: |
pip install requests
python get_latest_version.py
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
key: ${{ matrix.alt_arch_name }}

- run: rustup target add aarch64-apple-darwin
if: matrix.os == 'macos'

- run: rustup toolchain install stable-i686-pc-windows-msvc
if: matrix.os == 'windows'

- run: rustup target add i686-pc-windows-msvc
if: matrix.os == 'windows'

- name: Get pip cache dir
id: pip-cache
if: matrix.os != 'windows'
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Get pip cache dir
id: pip-cache-win
if: matrix.os == 'windows'
run: |
"dir=$(pip cache dir)" >> $env:GITHUB_OUTPUT
- name: Cache python dependencies
uses: actions/cache@v3
name: wheels-windows-${{ matrix.target }}
path: dist

macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
path: ${{ steps.pip-cache.outputs.dir || steps.pip-cache-win.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}

- name: install python dependencies
run: pip install -U setuptools wheel twine cibuildwheel platformdirs

- name: Display cibuildwheel cache dir
id: cibuildwheel-cache
run: |
from platformdirs import user_cache_path
import os
with open(os.getenv('GITHUB_OUTPUT'), 'w') as f:
f.write(f"dir={str(user_cache_path(appname='cibuildwheel', appauthor='pypa'))}")
shell: python

- name: Cache cibuildwheel tools
uses: actions/cache@v3
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
path: ${{ steps.cibuildwheel-cache.outputs.dir }}
key: ${{ runner.os }}-cibuildwheel-${{ matrix.python-version }}

- name: Install LLVM and Clang # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797
uses: KyleMayes/install-llvm-action@v1
if: runner.os == 'Windows'
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
version: "11.0"
directory: ${{ runner.temp }}/llvm

- name: Set LIBCLANG_PATH
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
if: runner.os == 'Windows'

- name: build_sdist
if: matrix.os == 'ubuntu' && matrix.python-version == 'cp310'
run: |
pip install maturin build
python -m build --sdist -o wheelhouse
- name: build ${{ matrix.platform || matrix.os }} binaries
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "${{ matrix.python-version }}-*"
# rust doesn't seem to be available for musl linux on i686
CIBW_SKIP: "*-musllinux_i686"
# we build for "alt_arch_name" if it exists, else 'auto'
CIBW_ARCHS: ${{ matrix.alt_arch_name || 'auto' }}
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH" CARGO_TERM_COLOR="always"'
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
CIBW_BEFORE_BUILD: rustup show
CIBW_BEFORE_BUILD_LINUX: >
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y &&
rustup show
CIBW_BUILD_VERBOSITY: 1

- run: ${{ matrix.ls || 'ls -lh' }} wheelhouse/

- uses: actions/upload-artifact@v3
name: wheels-macos-${{ matrix.target }}
path: dist

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
name: wheels
path: wheelhouse

command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist

release:
if: github.event.pull_request.merged == true
needs: build
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse

- name: Install twine
run: python -m pip install --upgrade twine

- name: Create pypirc file
run: |
echo "[distutils]" > ~/.pypirc
echo "index-servers =" >> ~/.pypirc
echo " pypi" >> ~/.pypirc
echo "" >> ~/.pypirc
echo "[pypi]" >> ~/.pypirc
echo "username: __token__" >> ~/.pypirc
echo "password: \${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

- uses: actions/download-artifact@v4
- name: Publish to PyPI
run: twine upload wheelhouse/*
uses: PyO3/maturin-action@v1
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*
Loading

0 comments on commit 71ec849

Please sign in to comment.