Skip to content

Commit

Permalink
Set up Travis CI like in the main repo (vfaronov/httpolice)
Browse files Browse the repository at this point in the history
  • Loading branch information
vfaronov committed Aug 6, 2016
1 parent 8f8cb8c commit 3039096
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[report]

exclude_lines =
pragma: no cover
def __repr__
raise NotImplementedError
if __name__ == '__main__':
43 changes: 43 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
language: python

python: "2.7"

env:
- REQUIRES=minimum
- REQUIRES=normal

install:
- if [ "$REQUIRES" = minimum ]; then tools/minimum_requires.sh; fi
- pip install -e .
- pip install -r tools/requirements.txt

cache: pip

script:
# Basic stuff.
- python setup.py check --strict --restructuredtext
- pylint *.py
- py.test

# Although the docs are processed by Read the Docs,
# we still want to check that they are building OK.
- sphinx-build -W doc/ doc/_build/

# Check the assorted reStructuredText documents at the top of the repo.
- tools/check_rst.sh

# Check that the source distribution includes everything it should,
# and nothing it shouldn't (including all the files we just built).
- check-manifest

deploy:
on:
tags: true
# Only release from one of the environments.
python: "2.7"
condition: $REQUIRES = normal
provider: pypi
user: vfaronov
password:
secure: CJxSxCcPAebJP0YtRVg30ZuWNZYb7Y6WJVTDuH9c59NDqCpE6y1UfXFyj9zunM3pXrfxgvh+pVA4r4dzrI8n4+OBcqlWFfumZjDhYLM2luruKc+IxVf3mEw3p5v+77ssCkWHhmN7Auh/nIQMYtNp2p8TmO+yJA7Yd4oRnGNMPv/dEAKQlOGAYwI6i1rn+orknI+8q2cc7bmgeEUC97lMl9yhmF55aWycH+XGBVkFUiiu3/LLKzP2NG4YMTah7wFzclbPFqK4BK24Vwid0EXzQx1lEWmRyblo9msmeotD4qSCU4hwUYz5lZP4OCWkwqAA20xouK0tg17S3yq+glf4CQzEOCuCLa3r7VfgJW8ddfZ0J8rarVln8w+V22qsCvicTzRBZgEhwhZhQkHt5lOCwRJ62XgKJ6me9r+xlMYAy5QhDfj3KHUqV+om6Plj/nS/5AHduqTwRqd/mAOSIonMf/1ATYH7+Vk1HuHZPrKTqnbSrh4sdCqgWydgcVhbcF1nynxDwuG57znn6odLmMa90p/O2OdA+J2/1T4OL4akqmkf9mSZep/3nR/0fCN5AETDqdglWAG4EjNHWOnzgMsMKOyBkwn6bX0RCeXiVu13xNxalN4Od4s+//ErFkjJ70awI5Y55O+ZzUQ7ggBqhpvkRrLhL8zbDP4H+F38txAUqtw=
distributions: "sdist bdist_wheel"
19 changes: 19 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
include requirements.in
include setup.cfg

include README.rst
include LICENSE.txt
include CHANGELOG.rst

include test_*.py
include .coveragerc
include .isort.cfg
include pylintrc
include pytest.ini

# Even though Travis only works on a Git repo,
# this file is important as a reference on the build procedure.
include .travis.yml

graft doc
prune doc/_build
graft tools

global-exclude *.pyc
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ __ http://docs.mitmproxy.org/en/stable/mitmdump.html
`Read the docs`__.

__ http://mitmproxy-httpolice.readthedocs.io/

Many details from the `main repo`__'s ``HACKING.rst`` apply here as well.

__ https://github.com/vfaronov/django-httpolice
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = []

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down
2 changes: 1 addition & 1 deletion mitmproxy_httpolice.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def decode(s):
return s


if __name__ == '__main__': # pragma: no cover
if __name__ == '__main__':
# Print the path to this script,
# for substitution into the mitmproxy command.
print(__file__)
3 changes: 1 addition & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[pytest]
# Require 100% test coverage of the module. Do not print a coverage report.
addopts = --cov=mitmproxy_httpolice.py --cov-fail-under=100 --no-cov-on-fail --cov-report=
addopts = --cov=mitmproxy_httpolice.py --cov=test_fake_mitmdump.py --cov=test_real_mitmdump.py --cov-fail-under=100 --no-cov-on-fail --cov-report=
2 changes: 2 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mitmproxy >= 0.15
HTTPolice >= 0.3.0.dev3
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
with io.open('README.rst') as f:
long_description = f.read()

with io.open('requirements.in') as f:
install_requires = [line for line in f
if line and not line.startswith('#')]


setup(
name='mitmproxy-HTTPolice',
Expand All @@ -24,10 +28,7 @@
author='Vasiliy Faronov',
author_email='vfaronov@gmail.com',
license='MIT',
install_requires=[
'mitmproxy >=0.15',
'HTTPolice >=0.2.0',
],
install_requires=install_requires,
py_modules=['mitmproxy_httpolice'],
classifiers=[
'Intended Audience :: Developers',
Expand Down
12 changes: 4 additions & 8 deletions test_real_mitmdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ def start(self):
os.close(fd)
script_path = subprocess.check_output(['python', '-m',
'mitmproxy_httpolice']).strip()
self.process = subprocess.Popen(
[
'mitmdump', '-p', str(self.port), '-s',
"'%s' '%s'" % (script_path, self.report_path)
],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
self.process = subprocess.Popen([
'mitmdump', '-p', str(self.port), '-s',
"'%s' '%s'" % (script_path, self.report_path)
])
time.sleep(2) # Give it some time to get up and running

# This whole thing is actually easier to do by hand
Expand Down
9 changes: 9 additions & 0 deletions tools/check_rst.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

test -e setup.py || { echo 'must run from repo root' >&2; exit 1; }

for fn in *.rst; do
rst2html.py --halt=warning "$fn" >/dev/null
done
11 changes: 11 additions & 0 deletions tools/minimum_requires.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

# Install the lowest permitted versions of requirements.
# This checks that these lower bounds are up-to-date.

set -e

test -e setup.py || { echo 'must run from repo root' >&2; exit 1; }

sed -e 's/>=/==/g' <requirements.in >minimum_requirements.txt
pip install -r minimum_requirements.txt
20 changes: 20 additions & 0 deletions tools/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pip-tools
check-manifest
pylint
pytest
pytest-cov
docutils
wheel
twine

# mitmproxy 0.15 requires ``click >= 6.2, < 6.3``.
# If we don't pin this down, we get a newer version of click and nothing works.
# Eventually we will use pip-sync which will take care of this automatically.
click == 6.2

# Pin down the versions of Sphinx and Alabaster as used on Read the Docs
# (you can see them in the generated page footers).
# This will have to be checked and synchronized from time to time.
# Not sure if good idea.
Sphinx == 1.3.5
alabaster == 0.7.8
44 changes: 44 additions & 0 deletions tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file tools/requirements.txt tools/requirements.in
#
alabaster==0.7.8
args==0.1.0 # via clint
astroid==1.4.8 # via pylint
babel==2.3.4 # via sphinx
backports.functools-lru-cache==1.2.1 # via pylint
check-manifest==0.31
click==6.2
clint==0.5.1 # via twine
configparser==3.5.0 # via pylint
coverage==4.2 # via pytest-cov
docutils==0.12
first==2.0.1 # via pip-tools
isort==4.2.5 # via pylint
Jinja2==2.8 # via sphinx
lazy-object-proxy==1.2.2 # via astroid
MarkupSafe==0.23 # via jinja2
mccabe==0.5.2 # via pylint
pip-tools==1.7.0
pkginfo==1.3.2 # via twine
py==1.4.31 # via pytest
Pygments==2.1.3 # via sphinx
pylint==1.6.4
pytest-cov==2.3.0
pytest==2.9.2
pytz==2016.6.1 # via babel
requests-toolbelt==0.7.0 # via twine
requests==2.10.0 # via requests-toolbelt, twine
six==1.10.0 # via astroid, pip-tools, pylint, sphinx
snowballstemmer==1.2.1 # via sphinx
sphinx-rtd-theme==0.1.9 # via sphinx
Sphinx==1.3.5 # via sphinx-rtd-theme
twine==1.7.4
wheel==0.29.0
wrapt==1.10.8 # via astroid

# The following packages are commented out because they are
# considered to be unsafe in a requirements file:
# setuptools # via twine

0 comments on commit 3039096

Please sign in to comment.