Skip to content

Add folding to travis script section #686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ yapf
pre-commit
pre-commit-hooks
beautifulsoup4
rednose
93 changes: 93 additions & 0 deletions travis.py
Original file line number Diff line number Diff line change
@@ -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