diff options
author | Hernan Grecco <hernan.grecco@gmail.com> | 2014-08-01 01:26:11 -0300 |
---|---|---|
committer | Hernan Grecco <hernan.grecco@gmail.com> | 2014-08-01 01:26:11 -0300 |
commit | d6e3ec67c38f656c68926531043f9798e2e96517 (patch) | |
tree | cd4aa081b6dd1a1509da83362425b8f6ae356c96 | |
parent | 30f709e5cc9f165f4ae4a34cd6e4d7273f412bba (diff) | |
download | pint-d6e3ec67c38f656c68926531043f9798e2e96517.tar.gz |
Add travis check
-rw-r--r-- | pint/__init__.py | 41 | ||||
-rw-r--r-- | setup.py | 3 |
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. @@ -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=[ |