Skip to content

tests+pypi

tests+pypi #232

Workflow file for this run

name: tests+pypi
defaults:
run:
shell: bash
env:
arbitrarily_selected_artefact_set: '3.10/ubuntu-latest/0/openmpi'
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 13 * * 4'
release:
types: [published]
jobs:
precommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.10'
- name: Linting
run: |
pip install pre-commit
pre-commit clean
pre-commit autoupdate
pre-commit run --all-files
pdoc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- uses: mpi4py/setup-mpi@v1
- name: Build
run: |
pip install pdoc3
pip install -e .
python -We -m pdoc --html PyMPDATA_MPI
- name: Deploy
if: github.ref == 'refs/heads/main'
uses: JamesIves/[email protected]
with:
BRANCH: pdoc
FOLDER: html/PyMPDATA_MPI
CLEAN: true
pylint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: mpi4py/setup-mpi@v1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[tests]
pip install pylint pytest matplotlib
- name: Analysing the code with pylint
run: |
pylint --unsafe-load-any-extension=y --disable=fixme $(git ls-files '*.py')
tests:
needs: [pylint, pdoc, precommit]
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
mpi: [ 'mpich', 'openmpi', 'intelmpi']
python-version: ["3.10"]
disable-jit: [1, 0]
mpi-np: [1, 2, 3, 4]
exclude:
# as of time of writing, mpi4py/setup-mpi does not support it
- platform: macos-latest
mpi: intelmpi
# issues with: *** The MPI_Comm_rank() function was called before MPI_INIT was invoked.
- platform: ubuntu-latest
mpi: intelmpi
# https://github.com/Homebrew/homebrew-core/issues/26974
- platform: macos-latest
mpi: mpich
fail-fast: false
runs-on: ${{ matrix.platform }}
timeout-minutes: 45
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpi }}
- if: matrix.mpi == 'mpich'
run: echo _ch="ch" >> $GITHUB_ENV
- if: startsWith(matrix.platform, 'ubuntu-')
run: sudo apt-get update && sudo apt-get install -y libhdf5-mpi$_ch-dev pkg-config
- if: startsWith(matrix.platform, 'ubuntu-') && matrix.mpi == 'mpich'
run: |
echo HDF5_LIBDIR=/usr/lib/x86_64-linux-gnu/hdf5/mpich >> $GITHUB_ENV
echo HDF5_INCLUDEDIR=/usr/include/hdf5/mpich >> $GITHUB_ENV
- if: startsWith(matrix.platform, 'macos-')
run: brew install hdf5-mpi && echo HDF5_DIR=/opt/homebrew >> $GITHUB_ENV
- run: HDF5_MPI="ON" CC=mpicc pip install --no-binary=h5py "git+https://github.com/h5py/h5py@81f6c01#egg=h5py"
- run: pip install -e .[tests]
- run: python -We -c "import PyMPDATA_MPI"
- if: matrix.mpi == 'openmpi'
run: echo _mpiexec_args="--oversubscribe" >> $GITHUB_ENV
- name: "mpiexec pytest"
env:
NUMBA_DISABLE_JIT: ${{ matrix.disable-jit }}
run: |
if [ "$arbitrarily_selected_artefact_set" == "${{ matrix.python-version }}/${{ matrix.platform }}/${{ matrix.disable-jit }}/${{ matrix.mpi }}" ]; then
export CI_PLOTS_PATH=plots/$arbitrarily_selected_artefact_set
mkdir -p $CI_PLOTS_PATH
fi
mpiexec $_mpiexec_args -n ${{ matrix.mpi-np }} pytest --timeout=600 --timeout_method=thread -s -vv -We tests/local;
- uses: actions/upload-artifact@v2
with:
name: plots
path: plots
dist:
runs-on: ubuntu-latest
needs: [tests]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # https://github.com/pypa/setuptools_scm/issues/480
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- run: pip install twine build
- run: |
unset CI
python -m build 2>&1 | tee build.log
exit `fgrep -i warning build.log | wc -l`
- run: twine check --strict dist/*
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: pypa/gh-action-pypi-publish@unstable/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@unstable/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
devops_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0 # https://github.com/pypa/setuptools_scm/issues/480
- run: pip install -r tests/devops_tests/requirements.txt
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pytest --durations=10 -v -s -We -p no:unraisableexception tests/devops_tests
tip-release-uploads:
runs-on: ubuntu-latest
needs: [tests, devops_tests]
steps:
- uses: actions/download-artifact@v2
with:
name: plots
path: plots
- run: |
sudo apt install -y librsvg2-bin
for scenario in ./plots/${{ env.arbitrarily_selected_artefact_set }}/*; do
for test_plots in $scenario/*; do
if [ ! $(find "$test_plots" -maxdepth 0 -empty | wc -l) -eq 1 ]; then
for file in $test_plots/*.svg; do
rsvg-convert $file -o tmp.png
convert tmp.png -flatten -trim +repage -bordercolor white -border 10 $file.png
done;
rm tmp.png
convert $test_plots/*.png plots/`basename $test_plots`-`basename $scenario`-anim.gif
fi
done;
done;
- uses: actions/upload-artifact@v2
with:
name: anims
path: plots/*-anim.gif
- if: github.ref == 'refs/heads/main'
uses: eine/tip@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: plots/*-anim.gif
tag: 'latest-generated-plots'