Use diff_cover.

This commit is contained in:
Adi Roiban 2016-07-31 14:07:08 +01:00
parent d76a49ad53
commit b8691bb244
3 changed files with 59 additions and 1 deletions

View File

@ -30,6 +30,10 @@ matrix:
# on starting separate jobs.
- python: 2.7
env: TOXENV=narrativedocs,apidocs,pyflakes,topfile,manifest-checker
# Twistedchecker is running as a separate job so that we can ignore if it
# fails.
- python: 2.7
env: TOXENV=txchecker-travis
#
# OSX 10.10
#
@ -44,6 +48,9 @@ matrix:
allow_failures:
# For now, OSX run on Travis-CI has a few failures.
- os: osx
# twistedchecker job was introduce as an experimental job.
# Once it is stable we can enforce it
- env: TOXENV=txchecker-travis
addons:

View File

@ -0,0 +1,43 @@
#!/usr/bin/env sh
#
# Helper for running twistedchecker and reporting only errors that are part
# of the changes since trunk.
#
# Call it as:
# * SCRIPT_NAME twisted
# * SCRIPT_NAME twisted/words/
# * SCRIPT_NAME twisted.words
target=$1
# FIXME: https://github.com/twisted/twistedchecker/issues/116
# Since for unknown modules twistedchecker will return the same error, the
# diff will fail to detect that we are trying to check an invalid path or
# module.
# This is why we check that the argument is a path and if not a path, it is
# an importable module.
if [ ! -d "$target" ]; then
python -c "import $target" 2> /dev/null
if [ $? -ne 0 ]; then
>&2 echo "$target does not exists as a path or as a module."
exit 1
fi
fi
# Make sure we have trunk on the local repo.
git fetch origin trunk:refs/remotes/origin/trunk
mkdir -p build/
twistedchecker -f parseable $target > build/twistedchecker-branch.report
# Make sure repo is producing the diff with prefix so that the output of
# `git diff` can be parsed by diff_cover.
git config diff.noprefix false
diff-quality \
--violations=pylint \
--fail-under=100 \
--compare-branch=origin/trunk build/twistedchecker-branch.report
diff_exit_code=$?
exit $diff_exit_code

10
tox.ini
View File

@ -4,6 +4,9 @@
; coverage results to codecov.io. It should be called after running the
; standard coverage environment.
;
; A non-default `txchecker-travis` environment is used to run twistedchecker
; on travis in --diff mode
;
[tox]
skip_missing_interpreters=True
toxworkdir=build/
@ -40,8 +43,9 @@ deps =
; Code quality checkers
pyflakes: pyflakes
twistedchecker: twistedchecker
manifest-checker: check-manifest
{twistedchecker,txchecker}: twistedchecker>=0.6.0
txchecker: diff_cover
; Documentation
apidocs: pydoctor
@ -87,6 +91,10 @@ commands =
codecov-publish: codecov {env:CODECOV_OPTIONS:}
twistedchecker: twistedchecker {posargs:twisted}
# Run twistedchecker with a diff base on trunk.
txchecker-travis: {toxinidir}/.travis/twistedchecker-trunk-diff.sh {posargs:twisted}
pyflakes: pyflakes {posargs:twisted admin bin}
apidocs: {toxinidir}/bin/admin/build-apidocs {toxinidir} apidocs