Skip to content

Commit f4b700c

Browse files
committed
add release tester
1 parent f220ce5 commit f4b700c

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ jobs:
8080
# env:
8181
# - TOXENV=dev
8282
# - EXTRA_ARGS=
83+
- name: "check MANIFEST.in completeness"
84+
python: 3.7
85+
install: ""
86+
script: RELEASE_SKIP=head ${TRAVIS_BUILD_DIR}/misc/release-test.sh
8387

8488
install:
8589
- pip install -U pip setuptools

misc/release-test.sh

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -x
5+
6+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null && pwd )"
7+
8+
export LC_ALL=C
9+
export TEST_MYPYC=1
10+
export MYPY_USE_MYPYC=1
11+
export CC=clang MYPYC_OPT_LEVEL=0
12+
export MYPY_TEST_PREFIX=${DIR} # not good, should be part of the mypy module,
13+
# like the mypyc test data is part of the mypyc module
14+
15+
package=mypy
16+
module=mypy
17+
module2=mypyc
18+
slug=${TRAVIS_PULL_REQUEST_SLUG:=python/mypy}
19+
repo=https://github.com/${slug}.git
20+
run_tests() { # synchronize with pytest.ini
21+
py.test -o testpaths=${module}/test \
22+
-o python_files=test*.py -o python_classes= \
23+
-o python_functions= -nauto --pyargs ${module}
24+
py.test -o testpaths=${module2}/test \
25+
-o python_files=test*.py -o python_classes= \
26+
-o python_functions= -k 'not test_c_unit_test' -nauto --pyargs ${module2}
27+
28+
}
29+
pipver=10.0.0 # minimum required version of pip given python3.6+ and --no-build-isolation
30+
setuptoolsver=24.2.0 # required to generate correct metadata for
31+
# python_requires
32+
33+
rm -Rf testenv? || /bin/true
34+
35+
export HEAD=${TRAVIS_PULL_REQUEST_SHA:-$(git rev-parse HEAD)}
36+
37+
if [ "${RELEASE_SKIP}" != "head" ]
38+
then
39+
testenv1=$(mktemp -d -t "${package}_env1-XXXXXXXXXX")
40+
virtualenv "${testenv1}" -p python3
41+
# First we test the head
42+
# shellcheck source=/dev/null
43+
source "${testenv1}/bin/activate"
44+
rm -Rf "${testenv1}/local"
45+
rm -f "${testenv1}/lib/python-wheels/setuptools"* \
46+
&& pip install --force-reinstall -U pip==${pipver} \
47+
&& pip install setuptools==${setuptoolsver} wheel
48+
pip install -rmypy-requirements.txt
49+
pip install -rtest-requirements.txt
50+
python setup.py build_ext --inplace
51+
./runtests.py
52+
pip uninstall -y ${package} || true; pip install --no-build-isolation .
53+
post_install1_test=$(mktemp -d -t ${package}_env1_test-XXXXXXXXXX)
54+
# if there is a subdir named '${module}' py.test will execute tests
55+
# there instead of the installed module's tests
56+
pushd "${post_install1_test}"
57+
# shellcheck disable=SC2086
58+
run_tests; popd
59+
fi
60+
61+
testenv2=$(mktemp -d -t ${package}_env2-XXXXXXXXXX)
62+
testenv3=$(mktemp -d -t ${package}_env3-XXXXXXXXXX)
63+
64+
virtualenv "${testenv2}" -p python3
65+
virtualenv "${testenv3}" -p python3
66+
rm -Rf "${testenv2}/local" "${testenv3}/local"
67+
68+
# Secondly we test via pip
69+
70+
cd "${testenv2}"
71+
# shellcheck source=/dev/null
72+
source bin/activate
73+
rm -f lib/python-wheels/setuptools* \
74+
&& pip install --force-reinstall -U pip==${pipver} \
75+
&& pip install setuptools==${setuptoolsver} wheel typing_extensions mypy_extensions typed_ast
76+
pip install --no-build-isolation -e "git+${repo}@${HEAD}#egg=${package}"
77+
cd src/${package}
78+
pip install -rmypy-requirements.txt
79+
pip install -rtest-requirements.txt
80+
python setup.py sdist bdist_wheel
81+
./runtests.py
82+
cp dist/${package}*tar.gz "${testenv3}/"
83+
pip uninstall -y ${package} || true; pip install --no-build-isolation .
84+
post_install2_test=$(mktemp -d -t "${package}_env2_test-XXXXXXXXXX")
85+
cd "${post_install2_test}" # no subdir named ${package} here, safe for py.testing the installed module
86+
# shellcheck disable=SC2086
87+
run_tests
88+
89+
# Is the distribution in testenv2 complete enough to build another
90+
# functional distribution?
91+
92+
cd "${testenv3}"
93+
# shellcheck source=/dev/null
94+
source bin/activate
95+
rm -f lib/python-wheels/setuptools* \
96+
&& pip install --force-reinstall -U pip==${pipver} \
97+
&& pip install setuptools==${setuptoolsver} wheel
98+
pip install "-r${DIR}/mypy-requirements.txt"
99+
pip install "-r${DIR}/test-requirements.txt"
100+
mkdir out
101+
tar --extract --directory=out -z -f ${package}*.tar.gz
102+
cd out/${package}*
103+
python setup.py build_ext --inplace
104+
./runtests.py
105+
pip uninstall -y ${package} || true; pip install --no-build-isolation .
106+
post_install3_test=$(mktemp -d -t "${package}_env3_test-XXXXXXXXXX")
107+
pushd "${post_install3_test}"
108+
# shellcheck disable=SC2086
109+
run_tests; popd

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[pytest]
22
minversion = 6.0.0
33

4+
# Are you updating anything in this file? Then update misc/release-test.sh as well
5+
# Thanks!
6+
47
testpaths = mypy/test mypyc/test
58

69
python_files = test*.py

0 commit comments

Comments
 (0)