Skip to content

Setup PyPI publish action #35

Setup PyPI publish action

Setup PyPI publish action #35

Workflow file for this run

name: Test package & measure coverage
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
tests:
#####----- RUN FULL TEST SUITE WITHOUT COVERAGE
# Test through actual installations for end-to-end testing including
# packaging.
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, macos-13, macos-14]
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
env:
CLONE_PATH: ${{ github.workspace }}
steps:
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install OpenMPI
run: |
if [ "${{ runner.os }}" == "Linux" ]; then
sudo apt-get update
sudo apt-get -y install openmpi-bin
elif [ "${{ runner.os }}" == "macOS" ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install open-mpi
fi
- name: Setup base Python environment
run: |
$CLONE_PATH/.github/workflows/setup_base_python.sh ${{ runner.os }}
python -m pip install build
- name: Run tests without coverage
run: |
which mpirun
which mpicxx
mpicxx -show
echo " "
pushd $CLONE_PATH
# Since the package is pure Python, the binary wheel should be
# universal. Therefore, all pip installs from PyPI should get the
# wheel rather than the source distribution and we test the wheel.
python -m build --wheel
python -m pip install dist/Taweret-*-py3-none-any.whl
python -c "import Taweret ; Taweret.__version__ ; Taweret.test()"
pushd $(dirname $(which python))/../lib/python*/site-packages/openbtmixing/.libs
echo " "
if [ "${{ matrix.os }}" == "ubuntu-20.04" ]; then
ldd openbtcli
# For 20.04/OpenMPI 4.0.3,
# mpicxx uses -L/usr/lib/x86_64-linux-gnu/openmpi/lib.
# However ldd uses /lib/x86_64-linux-gnu/libmpi.so.40.
# Ultimately, it looks like we use
# /lib/x86_64-linux-gnu/openmpi/lib/libmpi.so.40.20.3
# Note that there is a
# /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so.40.20.3
# that has the same size (1124440) as the system version.
#
# My best guess is that the OpenMPI install is going to both
# /lib and /usr/lib. Indeed, if you don't install OpenMPI Taweret
# fails, which suggests no system MPI.
#
# These lines can be used to confirm that OpenMPI is being used
# correctly at build and execution time.
#echo " "
#ls -la /usr/lib/x86_64-linux-gnu/openmpi/lib
#echo " "
#ls -la /lib/x86_64-linux-gnu/libmpi*
#echo " "
#ls -la /lib/x86_64-linux-gnu/openmpi/lib
#echo " "
elif [ "${{ matrix.os }}" == "ubuntu-22.04" ]; then
ldd openbtcli
# For 22.04/OpenMPI 4.1.2,
# mpicxx uses -L/usr/lib/x86_64-linux-gnu/openmpi/lib.
# However ldd uses /lib/x86_64-linux-gnu/libmpi.so.40.
# Ultimately, it looks like we use
# /lib/x86_64-linux-gnu/libmpi.so.40.30.2
# and I don't find any general MPI libraries in the locations
# specified by mpicxx.
#
# My best guess is that the OpenMPI install is going to just
# /lib and that there are being found by the compiler
# automatically. Indeed, if you don't install OpenMPI Taweret
# fails, which suggests no system MPI. This would imply that
# mpicxx is assuming that the system install will be found but it
# needs to identify where the (mostly) mca libs are.
#
# These lines can be used to confirm that OpenMPI is being used
# correctly at build and execution time.
#echo " "
#ls -la /usr/lib/x86_64-linux-gnu/openmpi/lib/openmpi3
#echo " "
#ls -la /lib/x86_64-linux-gnu/libmpi*
#echo " "
#ls -la /lib/x86_64-linux-gnu/openmpi/lib/openmpi3
#echo " "
elif [ "${{ runner.os }}" == "macOS" ]; then
otool -L openbtcli
fi
echo " "
objdump -p openbtcli
echo " "
popd
popd
coverage:
#####----- RUN FULL TEST SUITE WITH COVERAGE
# Use local editable/developer mode installation so that we are testing such
# installations. For some code coverage services, this can also improve
# the information that they present through their web interface.
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.12"]
runs-on: ${{ matrix.os }}
env:
CLONE_PATH: ${{ github.workspace }}
# These two are used internally by tox
COVERAGE_XML: ${{ github.workspace }}/coverage.xml
COVERAGE_HTML: ${{ github.workspace }}/htmlcov
steps:
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install OpenMPI
run: |
sudo apt-get update
sudo apt-get -y install openmpi-bin
- name: Setup base Python environment
run: |
$CLONE_PATH/.github/workflows/setup_base_python.sh ${{ matrix.os }}
- name: Run tests with coverage
run: |
pushd $CLONE_PATH
tox -r -e coverage,report
popd
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.KEVIN_CODECOV_TOKEN }}
slug: bandframework/Taweret
file: ${{ env.COVERAGE_XML }}
fail_ci_if_error: true
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-results
path: |
${{ env.COVERAGE_XML }}
${{ env.COVERAGE_HTML }}