summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHernan Grecco <hernan.grecco@gmail.com>2014-08-01 01:26:11 -0300
committerHernan Grecco <hernan.grecco@gmail.com>2014-08-01 01:26:11 -0300
commitd6e3ec67c38f656c68926531043f9798e2e96517 (patch)
treecd4aa081b6dd1a1509da83362425b8f6ae356c96
parent30f709e5cc9f165f4ae4a34cd6e4d7273f412bba (diff)
downloadpint-d6e3ec67c38f656c68926531043f9798e2e96517.tar.gz
Add travis check
-rw-r--r--pint/__init__.py41
-rw-r--r--setup.py3
2 files changed, 44 insertions, 0 deletions
diff --git a/pint/__init__.py b/pint/__init__.py
index e5452ce..21051c7 100644
--- a/pint/__init__.py
+++ b/pint/__init__.py
@@ -82,6 +82,47 @@ def _run_pyroma(data): # pragma: no cover
sys.exit(1)
+def _check_travis(data): # pragma: no cover
+ """Check if Travis reports that everything is ok.
+ (used to perform checks before releasing a new version).
+ """
+ import json
+ import sys
+
+ from zest.releaser.utils import system, ask
+ if not ask('Check with Travis before releasing?'):
+ return
+
+ try:
+ # Python 3
+ from urllib.request import urlopen
+ def get(url):
+ return urlopen(url).read().decode('utf-8')
+
+ except ImportError:
+ # Python 2
+ from urllib2 import urlopen
+ def get(url):
+ return urlopen(url).read()
+
+ url = 'https://api.github.com/repos/%s/%s/status/%s'
+
+ username = 'hgrecco'
+ repo = 'pint'
+ commit = system('git rev-parse HEAD')
+
+ try:
+ result = json.loads(get(url % (username, repo, commit)))['state']
+ print('Travis says: %s' % result)
+ if result != 'success':
+ if not ask('Do you want to continue anyway?'):
+ sys.exit(1)
+ except Exception:
+ print('Could not determine the commit state with Travis.')
+ if ask('Do you want to continue anyway?'):
+ sys.exit(1)
+
+
def test():
"""Run all tests.
diff --git a/setup.py b/setup.py
index 6615f1a..5604a21 100644
--- a/setup.py
+++ b/setup.py
@@ -48,6 +48,9 @@ setup(
'zest.releaser.releaser.after_checkout': [
'pyroma = pint:_run_pyroma',
],
+ 'zest.releaser.prereleaser.before': [
+ 'travis = pint:_check_travis',
+ ],
},
license='BSD',
classifiers=[