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