Add travis check
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user