Skip to content

Commit

Permalink
Test Linux wheels in containers
Browse files Browse the repository at this point in the history
  • Loading branch information
dalcinl committed Oct 5, 2023
1 parent 76c9424 commit 0b0f8fc
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .cibw/test-linux-debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail

packages=(
python3.11-venv
pypy3
libmpich12
libopenmpi3
)
sudo=$(command -v sudo || true)
$sudo apt update -y
$sudo apt install -y ${packages[@]}
$sudo ln -sr /usr/lib/$(arch)-linux-gnu/libmpi{ch,}.so.12

sdir=$(cd "$(dirname -- "$0")" && pwd -P)
$sdir/test-wheel.sh
25 changes: 25 additions & 0 deletions .cibw/test-linux-fedora.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -euo pipefail

packages=(
python3.6
python3.7
python3.8
python3.9
python3.10
python3.11
python3.12
pypy3.9
pypy3.10
mpich
openmpi
)
sudo=$(command -v sudo || true)
opts=--setopt=install_weak_deps=False
$sudo dnf install -y $opts ${packages[@]}
set +u
source /etc/profile.d/modules.sh
set -u

sdir=$(cd "$(dirname -- "$0")" && pwd -P)
$sdir/test-wheel.sh
17 changes: 17 additions & 0 deletions .cibw/test-linux-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail

packages=(
python3.10-venv
python3.11-venv
pypy3
libmpich12
libopenmpi3
)
sudo=$(command -v sudo || true)
$sudo apt update -y
$sudo apt install -y ${packages[@]}
$sudo ln -sr /usr/lib/$(arch)-linux-gnu/libmpi{ch,}.so.12

sdir=$(cd "$(dirname -- "$0")" && pwd -P)
$sdir/test-wheel.sh
23 changes: 23 additions & 0 deletions .cibw/test-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -euo pipefail

packages_py=(
[email protected]
[email protected]
[email protected]
[email protected]
pypy3.9
pypy3.10
)
packages_mpi=(
mpich
openmpi
)
brew install ${packages_py[@]}
for mpi in ${packages_mpi[@]}; do
brew install $mpi
brew unlink $mpi
done

sdir=$(cd "$(dirname -- "$0")" && pwd -P)
$sdir/test-wheel.sh
80 changes: 80 additions & 0 deletions .cibw/test-wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash
set -euo pipefail

PYTHON=(
python3.6
python3.7
python3.8
python3.9
python3.10
python3.11
python3.12
pypy3.7
pypy3.8
pypy3.9
)

wheelhouse=${1:-dist}
venvroot=$(mktemp -d)
trap "rm -rf $venvroot" EXIT
export PIP_QUIET=1

if [[ $(uname) =~ NT ]]; then
MPI=(impi msmpi)
bin=Scripts
else
MPI=(mpich openmpi)
bin=bin
fi

function setup-python {
local python=$1
venvdir=$venvroot/$python
$python -m venv $venvdir
source $venvdir/$bin/activate
python -m pip install pip --upgrade
}

function setup-mpi4py {
local dist=$1
python -m pip install mpi4py --no-index --find-links=$dist
}

function setup-mpi {
local mpi=$1
if command -v brew > /dev/null; then
brew unlink mpich openmpi > /dev/null
brew link $mpi > /dev/null
elif command -v module > /dev/null; then
module unload mpi
module load mpi/$mpi-$(arch)
else
export MPI4PY_MPIABI=$mpi
fi
}

function mpi4py-test-basic {
python --version
python -m mpi4py --version
python -m mpi4py --mpi-std-version
python -m mpi4py --mpi-lib-version | head -n 1
echo
}

for python in ${PYTHON[@]}; do
test -z "$(command -v $python)" && continue
setup-python $python
setup-mpi4py $wheelhouse
for mpi in ${MPI[@]}; do
setup-mpi $mpi
mpi4py-test-basic
export MPI4PY_MPIABI=$mpi
mpi4py-test-basic
if [ $mpi == mpich -o $mpi == openmpi ]; then
export MPI4PY_MPIABI=mpi31-$mpi
mpi4py-test-basic
fi
unset MPI4PY_MPIABI
done
deactivate destructive
done
96 changes: 94 additions & 2 deletions .github/workflows/cd-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,100 @@ jobs:
- id: setup
run: python -u .cibw/setup-test.py wheelhouse >> "$GITHUB_OUTPUT"

test-Linux:
if: ${{ contains(needs.setup.outputs.os-arch-list, '"Linux-x86_64"') }}
needs: [setup, merge]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: wheel-${{ runner.os }}
path: dist

- uses: docker://debian:latest
with:
entrypoint: /bin/bash
args: .cibw/test-linux-debian.sh

- uses: docker://ubuntu:latest
with:
entrypoint: /bin/bash
args: .cibw/test-linux-ubuntu.sh

- uses: docker://fedora:latest
with:
entrypoint: /bin/bash
args: .cibw/test-linux-fedora.sh

test-macOS:
if: ${{ contains(needs.setup.outputs.os-arch-list, '"macOS-x86_64"') }}
needs: [setup, merge]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner:
- macos-11
- macos-12
- macos-13
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: wheel-${{ runner.os }}
path: dist

- run: .cibw/test-macos.sh
shell: bash

test-Windows:
if: ${{ contains(needs.setup.outputs.os-arch-list, '"Windows-AMD64"') }}
needs: [setup, merge]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner:
- windows-2019
- windows-2022
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: wheel-${{ runner.os }}
path: dist

- uses: actions/setup-python@v4
with:
python-version: |
pypy-3.8
pypy-3.9
3.7
3.8
3.9
3.10
3.11
3.12
- uses: mpi4py/setup-mpi@v1
with:
mpi: intelmpi
- uses: mpi4py/setup-mpi@v1
with:
mpi: msmpi

- run: .cibw/test-wheel.sh
shell: bash

test-cf:
if: ${{ needs.test-setup.outputs.matrix-test-cf != '[]' }}
if: ${{ false }} # ${{ needs.test-setup.outputs.matrix-test-cf != '[]' }}
needs: test-setup
runs-on: ${{ (matrix.os == 'Linux' && 'ubuntu-latest' ) ||
(matrix.os == 'macOS' && 'macos-latest' ) ||
Expand Down Expand Up @@ -358,7 +450,7 @@ jobs:
shell: bash -el {0}

test-gh:
if: ${{ needs.test-setup.outputs.matrix-test-gh != '[]' }}
if: ${{ false }} # ${{ needs.test-setup.outputs.matrix-test-gh != '[]' }}
needs: test-setup
runs-on: ${{ matrix.runner }}
strategy:
Expand Down

0 comments on commit 0b0f8fc

Please sign in to comment.