|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | +set -x |
| 5 | + |
| 6 | +export LC_ALL=C |
| 7 | + |
| 8 | +package=cwl-upgrader |
| 9 | +module=cwlupgrader |
| 10 | +slug=${TRAVIS_PULL_REQUEST_SLUG:=common-workflow-language/${package}} |
| 11 | +repo=https://github.com/${slug}.git |
| 12 | +test_prefix="" |
| 13 | +run_tests() { |
| 14 | + ${test_prefix}bin/py.test --pyargs -x ${module} |
| 15 | +} |
| 16 | +pipver=7.0.2 # minimum required version of pip |
| 17 | +setuptoolsver=24.2.0 # required to generate correct metadata for |
| 18 | + # python_requires |
| 19 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" |
| 20 | + |
| 21 | +rm -Rf testenv? || /bin/true |
| 22 | + |
| 23 | +export HEAD=${TRAVIS_PULL_REQUEST_SHA:-$(git rev-parse HEAD)} |
| 24 | + |
| 25 | +if [ "${RELEASE_SKIP}" != "head" ] |
| 26 | +then |
| 27 | + virtualenv testenv1 -p python3 |
| 28 | + # First we test the head |
| 29 | + # shellcheck source=/dev/null |
| 30 | + source testenv1/bin/activate |
| 31 | + rm -Rf testenv1/local |
| 32 | + rm testenv1/lib/python-wheels/setuptools* \ |
| 33 | + && pip install --force-reinstall -U pip==${pipver} \ |
| 34 | + && pip install setuptools==${setuptoolsver} wheel |
| 35 | + make install-dep |
| 36 | + pip install . |
| 37 | + make test |
| 38 | + pip uninstall -y ${package} || true; pip uninstall -y ${package} || true; make install |
| 39 | + mkdir testenv1/not-${module} |
| 40 | + # if there is a subdir named '${module}' py.test will execute tests |
| 41 | + # there instead of the installed module's tests |
| 42 | + pushd testenv1/not-${module} |
| 43 | + # shellcheck disable=SC2086 |
| 44 | + test_prefix=../ run_tests; popd |
| 45 | +fi |
| 46 | + |
| 47 | +virtualenv testenv2 -p python3 |
| 48 | +virtualenv testenv3 -p python3 |
| 49 | +virtualenv testenv4 -p python3 |
| 50 | +rm -Rf testenv[234]/local |
| 51 | + |
| 52 | +# Secondly we test via pip |
| 53 | + |
| 54 | +cd testenv2 |
| 55 | +# shellcheck source=/dev/null |
| 56 | +source bin/activate |
| 57 | +rm lib/python-wheels/setuptools* \ |
| 58 | + && pip install --force-reinstall -U pip==${pipver} \ |
| 59 | + && pip install setuptools==${setuptoolsver} wheel |
| 60 | +pip install -e "git+${repo}@${HEAD}#egg=${package}" #[deps] |
| 61 | +cd src/${package} |
| 62 | +make install-dep |
| 63 | +make dist |
| 64 | +make test |
| 65 | +cp dist/${package}*tar.gz ../../../testenv3/ |
| 66 | +pip uninstall -y ${package} || true; pip uninstall -y ${package} || true; make install |
| 67 | +cd ../.. # no subdir named ${proj} here, safe for py.testing the installed module |
| 68 | +# shellcheck disable=SC2086 |
| 69 | +run_tests |
| 70 | + |
| 71 | +# Is the distribution in testenv2 complete enough to build another |
| 72 | +# functional distribution? |
| 73 | + |
| 74 | +cd ../testenv3/ |
| 75 | +# shellcheck source=/dev/null |
| 76 | +source bin/activate |
| 77 | +rm lib/python-wheels/setuptools* \ |
| 78 | + && pip install --force-reinstall -U pip==${pipver} \ |
| 79 | + && pip install setuptools==${setuptoolsver} wheel |
| 80 | +package_tar=${package}*tar.gz |
| 81 | +pip install "-r${DIR}/test-requirements.txt" |
| 82 | +pip install ${package_tar} # [deps] |
| 83 | +mkdir out |
| 84 | +tar --extract --directory=out -z -f ${package}*.tar.gz |
| 85 | +cd out/${package}* |
| 86 | +make install-dep |
| 87 | +make dist |
| 88 | +make test |
| 89 | +pip uninstall -y ${package} || true; pip uninstall -y ${package} || true; make install |
| 90 | +mkdir ../not-${module} |
| 91 | +pushd ../not-${module} |
| 92 | +# shellcheck disable=SC2086 |
| 93 | +test_prefix=../../ run_tests; popd |
0 commit comments