From 5b1a0e4f8f1438e2c02c54ffd70baa94436bffc5 Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Thu, 22 Jun 2017 21:35:21 +0200 Subject: [PATCH 1/8] Add folding to travis script section Maybe we should move to an actual script soon? :P --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index da145e7bce0..0fe43d5b038 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,9 +29,13 @@ install: - if [[ $TRAVIS_PYTHON_VERSION != 'pypy'* ]]; then pip install ujson; fi script: + - echo 'Running test suite...' && echo -en 'travis_fold:start:nosetests\\r' - 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 + - echo -en 'travis_fold:end:nosetests\\r' + - if [[ $TRAVIS_PYTHON_VERSION == 3.5 ]]; then echo 'Running pre-commits...' && echo -en 'travis_fold:start:pre-commmit\\r' && pre-commit run --all-files && echo -en 'travis_fold:end:pre-commit\\r'; fi + - echo 'Building wheel' && echo -en 'travis_fold:start:bdist_dump\\r' - python ./setup.py bdist_dumb + - echo -en 'travis_fold:end:bdist_dump\\r' after_success: coveralls \ No newline at end of file From a9448132edcb2bac8e97b914b938833f7847265a Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Fri, 23 Jun 2017 13:12:02 +0200 Subject: [PATCH 2/8] Better travis folding? --- .travis.yml | 8 +---- travis.py | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 travis.py diff --git a/.travis.yml b/.travis.yml index 0fe43d5b038..803fd9462f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,13 +29,7 @@ install: - if [[ $TRAVIS_PYTHON_VERSION != 'pypy'* ]]; then pip install ujson; fi script: - - echo 'Running test suite...' && echo -en 'travis_fold:start:nosetests\\r' - - nosetests -v --with-flaky --no-flaky-report --with-coverage --cover-package=telegram/ tests - - echo -en 'travis_fold:end:nosetests\\r' - - if [[ $TRAVIS_PYTHON_VERSION == 3.5 ]]; then echo 'Running pre-commits...' && echo -en 'travis_fold:start:pre-commmit\\r' && pre-commit run --all-files && echo -en 'travis_fold:end:pre-commit\\r'; fi - - echo 'Building wheel' && echo -en 'travis_fold:start:bdist_dump\\r' - - python ./setup.py bdist_dumb - - echo -en 'travis_fold:end:bdist_dump\\r' + - python travis.py after_success: coveralls \ No newline at end of file diff --git a/travis.py b/travis.py new file mode 100644 index 00000000000..7448551bd23 --- /dev/null +++ b/travis.py @@ -0,0 +1,89 @@ +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) + + stopContext = startContext + +folds = set() + + +def fold(foldname, comment=None, stream=sys.stdout): + if foldname in folds: + folds.remove(foldname) + print('travis_fold:end:{}'.format(foldname), file=stream, end='') + else: + folds.add(foldname) + print('travis_fold:start:{}'.format(foldname), file=stream, end='') + + if comment: + print('\r{}'.format(comment), file=stream) + else: + print('', file=stream) + + +def main(): + print('Starting...') + fold('tests', 'Running tests...') + config = Config(verbosity=2, plugins=DefaultPluginManager()) + tests = nose.run(argv=['--with-flaky', '--no-flaky-report', '--with-coverage', + '--with-travis-fold', '--cover-package=telegram/', + 'tests'], + addplugins=[FoldPlugin(), CustomCoverage()], + config=config) + print('\n' * 2) + fold('tests') + + # Only run pre-commit hooks once + pre_commit = True + if sys.version_info[:2] == (3, 5) 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']) + 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() From 542f2c360f7ffe9e71f45291e5eb07f5d86985e3 Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Fri, 23 Jun 2017 13:19:21 +0200 Subject: [PATCH 3/8] Don't fold tests if they failed and don't print test module name twice --- travis.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/travis.py b/travis.py index 7448551bd23..781dc56b2fc 100644 --- a/travis.py +++ b/travis.py @@ -36,7 +36,9 @@ def startContext(self, context): if inspect.ismodule(context) and context != tests: fold(context.__name__, context.__name__, stream=self.stream) - stopContext = startContext + def stopContext(self, context): + if inspect.ismodule(context) and context != tests: + fold(context.__name__, stream=self.stream) folds = set() @@ -65,7 +67,8 @@ def main(): addplugins=[FoldPlugin(), CustomCoverage()], config=config) print('\n' * 2) - fold('tests') + if tests: + fold('tests') # Only run pre-commit hooks once pre_commit = True From e9ffd70274ac280b4b5ba2c99706140fc43dbc82 Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Fri, 23 Jun 2017 13:39:33 +0200 Subject: [PATCH 4/8] Color travis log via rednose --- requirements-dev.txt | 1 + travis.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) 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 index 781dc56b2fc..6fca5352341 100644 --- a/travis.py +++ b/travis.py @@ -60,9 +60,10 @@ def fold(foldname, comment=None, stream=sys.stdout): def main(): print('Starting...') fold('tests', 'Running tests...') - config = Config(verbosity=2, plugins=DefaultPluginManager()) - tests = nose.run(argv=['--with-flaky', '--no-flaky-report', '--with-coverage', - '--with-travis-fold', '--cover-package=telegram/', + 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) From ae7e83be37de76a6b51cac484381091d38c09879 Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Fri, 23 Jun 2017 14:12:27 +0200 Subject: [PATCH 5/8] Add a newline to make log easier to read? --- travis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.py b/travis.py index 6fca5352341..2ef65eeadb4 100644 --- a/travis.py +++ b/travis.py @@ -46,7 +46,7 @@ def stopContext(self, context): def fold(foldname, comment=None, stream=sys.stdout): if foldname in folds: folds.remove(foldname) - print('travis_fold:end:{}'.format(foldname), file=stream, end='') + print('\ntravis_fold:end:{}'.format(foldname), file=stream, end='') else: folds.add(foldname) print('travis_fold:start:{}'.format(foldname), file=stream, end='') From 27ff2ebd2fc47bd1dbb2b88f40e97b42afa30a3a Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Fri, 23 Jun 2017 14:15:46 +0200 Subject: [PATCH 6/8] Will this make it always fold? --- travis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.py b/travis.py index 2ef65eeadb4..4f79aee17be 100644 --- a/travis.py +++ b/travis.py @@ -52,7 +52,7 @@ def fold(foldname, comment=None, stream=sys.stdout): print('travis_fold:start:{}'.format(foldname), file=stream, end='') if comment: - print('\r{}'.format(comment), file=stream) + print('\n{}'.format(comment), file=stream) else: print('', file=stream) From 3ba6994807333be4ef02d6ba3b39e7b0075b2b2e Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Fri, 23 Jun 2017 14:45:16 +0200 Subject: [PATCH 7/8] Run pre-commits on 3.6 --- travis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.py b/travis.py index 4f79aee17be..5400599be07 100644 --- a/travis.py +++ b/travis.py @@ -73,7 +73,7 @@ def main(): # Only run pre-commit hooks once pre_commit = True - if sys.version_info[:2] == (3, 5) and python_implementation() == 'CPython': + 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 From 5dc4674baf013a8ba3ef050b9e4192b75c9ae21b Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Fri, 23 Jun 2017 21:20:54 +0200 Subject: [PATCH 8/8] pre-commit should be True on success --- travis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.py b/travis.py index 5400599be07..509bb41f5d7 100644 --- a/travis.py +++ b/travis.py @@ -77,7 +77,7 @@ def main(): 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']) + pre_commit = subprocess.call(['pre-commit', 'run', '--all-files']) == 0 if pre_commit: fold('pre-commit') 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