diff --git a/.travis.yml b/.travis.yml index da145e7bce0..803fd9462f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,9 +29,7 @@ install: - if [[ $TRAVIS_PYTHON_VERSION != 'pypy'* ]]; then pip install ujson; fi script: - - nosetests -v --with-flaky --no-flaky-report --with-coverage --cover-package=telegram/ tests - - if [[ $TRAVIS_PYTHON_VERSION == 3.5 ]]; then pre-commit run --all-files; fi - - python ./setup.py bdist_dumb + - python travis.py after_success: coveralls \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index 35dd2355c01..1ec26c73f78 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,3 +7,4 @@ yapf pre-commit pre-commit-hooks beautifulsoup4 +rednose diff --git a/travis.py b/travis.py new file mode 100644 index 00000000000..509bb41f5d7 --- /dev/null +++ b/travis.py @@ -0,0 +1,93 @@ +from __future__ import print_function + +import subprocess +import sys +from platform import python_implementation +import inspect + +import nose +from nose.config import Config +from nose.plugins import Plugin, DefaultPluginManager +from nose.plugins.cover import Coverage + +import tests + + +class CustomCoverage(Coverage): + enabled = True + name = 'coverage' + score = 201 # One higher than original package + + def report(self, stream): + fold('coverage', 'Coverage report', stream=stream) + super(CustomCoverage, self).report(stream) + fold('coverage', stream=stream) + + +class FoldPlugin(Plugin): + enabled = True + name = 'travis-fold' + score = 100 + + def setOutputStream(self, stream): + self.stream = stream + + def startContext(self, context): + if inspect.ismodule(context) and context != tests: + fold(context.__name__, context.__name__, stream=self.stream) + + def stopContext(self, context): + if inspect.ismodule(context) and context != tests: + fold(context.__name__, stream=self.stream) + +folds = set() + + +def fold(foldname, comment=None, stream=sys.stdout): + if foldname in folds: + folds.remove(foldname) + print('\ntravis_fold:end:{}'.format(foldname), file=stream, end='') + else: + folds.add(foldname) + print('travis_fold:start:{}'.format(foldname), file=stream, end='') + + if comment: + print('\n{}'.format(comment), file=stream) + else: + print('', file=stream) + + +def main(): + print('Starting...') + fold('tests', 'Running tests...') + config = Config(verbosity=2, plugins=DefaultPluginManager(), env={'NOSE_REDNOSE': '1'}) + tests = nose.run(argv=['--with-flaky', '--no-flaky-report', + '--with-coverage', '--cover-package=telegram/', + '--with-travis-fold', + 'tests'], + addplugins=[FoldPlugin(), CustomCoverage()], + config=config) + print('\n' * 2) + if tests: + fold('tests') + + # Only run pre-commit hooks once + pre_commit = True + if sys.version_info[:2] == (3, 6) and python_implementation() == 'CPython': + fold('pre-commit', 'Running pre-commits') + # TODO: Only run pre-commit hooks on changed files + # Using something like git diff-tree and $TRAVIS_COMMIT_RANGE + pre_commit = subprocess.call(['pre-commit', 'run', '--all-files']) == 0 + if pre_commit: + fold('pre-commit') + + fold('bdist_dumb', 'Testing build...') + # run_setup('setup.py', ['bdist_dumb']) # Makes us unable to fetch exit code + bdist_dumb = subprocess.call(['python', 'setup.py', 'bdist_dumb']) == 0 + if bdist_dumb: + fold('bdist_dumb') + + sys.exit(0 if all((tests, pre_commit, bdist_dumb)) else 1) + +if __name__ == '__main__': + main() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy