|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -ex -o pipefail |
| 4 | + |
| 5 | +# Log some general info about the environment |
| 6 | +uname -a |
| 7 | +env | sort |
| 8 | + |
| 9 | +# See https://github.com/python-trio/trio/issues/334 |
| 10 | +YAPF_VERSION=0.22.0 |
| 11 | + |
| 12 | +# Curl's built-in retry system is not very robust; it gives up on lots of |
| 13 | +# network errors that we want to retry on. Wget might work better, but it's |
| 14 | +# not installed on azure pipelines's windows boxes. So... let's try some good |
| 15 | +# old-fashioned brute force. (This is also a convenient place to put options |
| 16 | +# we always want, like -f to tell curl to give an error if the server sends an |
| 17 | +# error response, and -L to follow redirects.) |
| 18 | +function curl-harder() { |
| 19 | + for BACKOFF in 0 1 2 4 8 15 15 15 15; do |
| 20 | + sleep $BACKOFF |
| 21 | + if curl -fL --connect-timeout 5 "$@"; then |
| 22 | + return 0 |
| 23 | + fi |
| 24 | + done |
| 25 | + return 1 |
| 26 | +} |
| 27 | + |
| 28 | + |
| 29 | +python -m pip install -U pip setuptools wheel |
| 30 | +python -m pip --version |
| 31 | + |
| 32 | +python setup.py sdist --formats=zip |
| 33 | +python -m pip install dist/*.zip |
| 34 | + |
| 35 | +if [ "$CHECK_FORMATTING" = "1" ]; then |
| 36 | + pip install yapf==${YAPF_VERSION} |
| 37 | + if ! yapf -rpd setup.py pytest_trio; then |
| 38 | + cat <<EOF |
| 39 | +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 40 | +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 41 | +
|
| 42 | +Formatting problems were found (listed above). To fix them, run |
| 43 | +
|
| 44 | + pip install yapf==${YAPF_VERSION} |
| 45 | + yapf -rpi setup.py pytest_trio |
| 46 | +
|
| 47 | +in your local checkout. |
| 48 | +
|
| 49 | +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 50 | +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 51 | +EOF |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | +elif [ "$CHECK_DOCS" = "1" ]; then |
| 55 | + pip install -Ur docs-requirements.txt |
| 56 | + cd docs |
| 57 | + # -n (nit-picky): warn on missing references |
| 58 | + # -W: turn warnings into errors |
| 59 | + sphinx-build -nW -b html source build |
| 60 | +else |
| 61 | + # Actual tests |
| 62 | + python -m pip install -r test-requirements.txt |
| 63 | + |
| 64 | + # We run the tests from inside an empty directory, to make sure Python |
| 65 | + # doesn't pick up any .py files from our working dir. Might have been |
| 66 | + # pre-created by some of the code above. |
| 67 | + mkdir empty || true |
| 68 | + cd empty |
| 69 | + |
| 70 | + # These environment variables ensure that the import of the pytest-trio plugin is covered |
| 71 | + # even if pytest-trio is loaded before pytest-cov. See https://pytest-cov.readthedocs.io/en/latest/plugins.html |
| 72 | + env COV_CORE_SOURCE=pytest_trio COV_CORE_CONFIG=.coveragerc COV_CORE_DATAFILE=.coverage pytest |
| 73 | + |
| 74 | + # The codecov docs recommend something like 'bash <(curl ...)' to pipe the |
| 75 | + # script directly into bash as its being downloaded. But, the codecov |
| 76 | + # server is flaky, so we instead save to a temp file with retries, and |
| 77 | + # wait until we've successfully fetched the whole script before trying to |
| 78 | + # run it. |
| 79 | + curl-harder -o codecov.sh https://codecov.io/bash |
| 80 | + bash codecov.sh -n "${JOB_NAME}" |
| 81 | +fi |
0 commit comments