Add travis check
This commit is contained in:
@@ -82,6 +82,47 @@ def _run_pyroma(data): # pragma: no cover
|
|||||||
sys.exit(1)
|
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():
|
def test():
|
||||||
"""Run all tests.
|
"""Run all tests.
|
||||||
|
|
||||||
|
|||||||
3
setup.py
3
setup.py
@@ -48,6 +48,9 @@ setup(
|
|||||||
'zest.releaser.releaser.after_checkout': [
|
'zest.releaser.releaser.after_checkout': [
|
||||||
'pyroma = pint:_run_pyroma',
|
'pyroma = pint:_run_pyroma',
|
||||||
],
|
],
|
||||||
|
'zest.releaser.prereleaser.before': [
|
||||||
|
'travis = pint:_check_travis',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
license='BSD',
|
license='BSD',
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
|||||||
Reference in New Issue
Block a user