Add travis check

This commit is contained in:
Hernan Grecco
2014-08-01 01:26:11 -03:00
parent 30f709e5cc
commit d6e3ec67c3
2 changed files with 44 additions and 0 deletions

View File

@@ -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.

View File

@@ -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=[