8000 Build packages and perform package sanity tests. Fixes #136 · pylint-dev/pylint-django@1aabc0d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1aabc0d

Browse files
committed
Build packages and perform package sanity tests. Fixes #136
1 parent cc6e7c7 commit 1aabc0d

File tree

2 files changed

+99
-4
lines changed

2 files changed

+99
-4
lines changed

.travis.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ python:
55
- 3.5
66
- 3.6
77
env:
8-
- DJANGO=1.11
8+
# note: latest versions first b/c the top-most is included in new
9+
# build stages if not specified
910
- DJANGO=2.0
11+
- DJANGO=1.11
1012
stages:
1113
- django_not_installed
1214
- django_is_installed
1315
- test
16+
- build_and_package_sanity
1417
matrix:
1518
exclude:
1619
# Python/Django combinations that aren't officially supported
@@ -21,6 +24,7 @@ matrix:
2124
- { stage: test, python: 3.6, env: TOXENV=flake8 }
2225
- { stage: test, python: 3.6, env: TOXENV=pylint }
2326
- { stage: test, python: 3.6, env: TOXENV=readme }
27+
- { stage: build_and_package_sanity, python: 3.6, env: SANITY_CHECK=1 }
2428
allow_failures:
2529
- env: TOXENV=flake8
2630
- env: TOXENV=pylint
@@ -29,11 +33,21 @@ matrix:
2933
install:
3034
- pip install tox-travis
3135
script:
32-
- tox
36+
- |
37+
38+
if [ -z "$SANITY_CHECK" ]; then
39+
tox
40+
else
41+
./scripts/build.sh
42+
fi
3343
3444
after_success:
35-
- pip install coveralls
36-
- coveralls
45+
- |
46+
if [ -z "$SANITY_CHECK" ]; then
47+
pip install coveralls
48+
coveralls
49+
fi
50+
3751
notifications:
3852
email:
3953
on_failure: change

scripts/build.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
# Build packages for distribution on PyPI
4+
# and execute some sanity scripts on them
5+
#
6+
# note: must be executed from the root directory of the project
7+
8+
# first clean up the local environment
9+
echo "..... Clean up first"
10+
find . -type f -name '*.pyc' -delete
11+
find . -type d -name __pycache__ -delete
12+
find . -type d -name '*.egg-info' | xargs rm -rf
13+
rm -rf build/ .cache/ dist/ .eggs/ .tox/
14+
15+
# then build the packages
16+
echo "..... Building PyPI packages"
17+
set -e
18+
python setup.py sdist >/dev/null
19+
python setup.py bdist_wheel >/dev/null
20+
set +e
21+
22+
# then run some sanity tests
23+
echo "..... Searching for .pyc files inside the built packages"
24+
matched_files=`tar -tvf dist/*.tar.gz | grep -c "\.pyc"`
25+
if [ "$matched_files" -gt "0" ]; then
26+
echo "ERROR: .pyc files found in .tar.gz package"
27+
exit 1
28+
fi
29+
matched_files=`unzip -t dist/*.whl | grep -c "\.pyc"`
30+
if [ "$matched_files" -gt "0" ]; then
31+
echo "ERROR: .pyc files found in wheel package"
32+
exit 1
33+
fi
34+
35+
echo "..... Trying to verify that all source files are present"
36+
# remove pylint_django/*.egg-info/ generated during build
37+
find . -type d -name '*.egg-info' | xargs rm -rf
38+
39+
source_files=`find ./pylint_django/ -type f | sed 's|./||'`
40+
41+
# verify for .tar.gz package
42+
package_files=`tar -tvf dist/*.tar.gz`
43+
for src_file in $source_files; do
44+
echo "$package_files" | grep $src_file >/dev/null
45+
if [ "$?" -ne 0 ]; then
46+
echo "ERROR: $src_file not found inside tar.gz package"
47+
exit 1
48+
fi
49+
done
50+
51+
# verify for wheel package
52+
package_files=`unzip -t dist/*.whl`
53+
for src_file in $source_files; do
54+
echo "$package_files" | grep $src_file >/dev/null
55+
if [ "$?" -ne 0 ]; then
56+
echo "ERROR: $src_file not found inside wheel package"
57+
exit 1
58+
fi
59+
done
60+
61+
# exit on error from now on
62+
set -e
63+
64+
echo "..... Trying to install the new tarball inside a virtualenv"
65+
# note: installs with the optional dependency to verify this is still working
66+
virtualenv .venv/test-tarball
67+
source .venv/test-tarball/bin/activate
68+
pip install --no-binary :all: -f dist/ pylint_django[with_django]
69+
pip freeze | grep Django
70+
deactivate
71+
rm -rf .venv/
72+
73+
echo "..... Trying to install the new wheel inside a virtualenv"
74+
virtualenv .venv/test-wheel
75+
source .venv/test-wheel/bin/activate
76+
pip install pylint-plugin-utils # because it does not provide a wheel package
77+
pip install --only-binary :all: -f dist/ pylint_django
78+
deactivate
79+
rm -rf .venv/
80+
81+
echo "..... PASS"

0 commit comments

Comments
 (0)
0