#!/bin/bash

program=mettoolbox

pkgs="\
     setuptools \
     mando \
     numpy \
     scipy \
     matplotlib \
     pandas \
     coverage \
     flake8 \
     pytest \
     pytest-cov \
     pytest-mpl \
     "

envs=(~/pythons/python-3.6.0  \
      ~/pythons/python-3.7.0  \
      ~/pythons/python-3.8.0)

pytest_opts='--doctest-modules --ignore docsrc --mpl'

for env in ${envs[@]}; do
    echo "${env}"

    source "${env}"/bin/activate
    pip install --upgrade pip
    pip install wheel
    pip install --no-cache --upgrade --only-binary numpy,pandas,scipy ${pkgs}
    pip uninstall -y ${program}
    rm -rf build
    pip install -e ../${program}
    pytest ${pytest_opts} tests/test_*.py
    deactivate
done

coverage erase
coverage run `which pytest` ${pytest_opts}
coverage report --include="${program}/*" --omit="tests/*"
coverage html --include="${program}/*" --omit="tests/*"
flake8 ${program}/*.py --exit-zero
