Generate mypy coverage report for travis + coveralls.

This commit is contained in:
Reid Barton 2016-06-04 12:03:14 -07:00 committed by Tim Abbott
parent 04e2745136
commit 0b7852f081
5 changed files with 31 additions and 12 deletions

2
.coveralls.yml Normal file
View File

@ -0,0 +1,2 @@
service_name: travis-pro
repo_token: hnXUEBKsORKHc8xIENGs9JjktlTb2HKlG

View File

@ -1,6 +1,7 @@
before_install:
- nvm install 0.10
install:
- pip install coveralls
- tools/travis/setup-$TEST_SUITE
- tools/clean-venv-cache --travis
cache:
@ -9,10 +10,15 @@ cache:
- $HOME/phantomjs
- $HOME/zulip-venv-cache
env:
- TEST_SUITE=frontend
- TEST_SUITE=backend
- TEST_SUITE=production
- TEST_SUITE=py3k
global:
- COVERALLS_PARALLEL=true
- COVERALLS_SERVICE_NAME=travis-pro
- COVERALLS_REPO_TOKEN=hnXUEBKsORKHc8xIENGs9JjktlTb2HKlG
matrix:
- TEST_SUITE=frontend
- TEST_SUITE=backend
- TEST_SUITE=production
- TEST_SUITE=py3k
language: python
python:
- "2.7"
@ -28,3 +34,7 @@ services:
- docker
addons:
postgresql: "9.3"
after_success:
coveralls
notifications:
webhooks: https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN

View File

@ -36,8 +36,8 @@ parser.add_argument('-m', '--modified', action='store_true', default=False, help
parser.add_argument('-a', '--all', dest='all', action='store_true', default=False,
help="""run mypy on all python files, ignoring the exclude list.
This is useful if you have to find out which files fail mypy check.""")
parser.add_argument('--linecount-report', dest='linecount_report', action='store_true', default=False,
help="""run the linecount report to see annotation coverage""")
parser.add_argument('--linecoverage-report', dest='linecoverage_report', action='store_true', default=False,
help="""run the linecoverage report to see annotation coverage""")
parser.add_argument('--disallow-untyped-defs', dest='disallow_untyped_defs', action='store_true', default=False,
help="""throw errors when functions are not annotated""")
args = parser.parse_args()
@ -58,9 +58,9 @@ else:
mypy_command = "mypy"
extra_args = ["--fast-parser", "--silent-imports", "--py2", "--check-untyped-defs"]
if args.linecount_report:
extra_args.append("--linecount-report")
extra_args.append("linecount-report")
if args.linecoverage_report:
extra_args.append("--linecoverage-report")
extra_args.append("linecoverage-report")
if args.disallow_untyped_defs:
extra_args.append("--disallow-untyped-defs")
@ -68,6 +68,13 @@ if args.disallow_untyped_defs:
# run mypy
if python_files:
rc = subprocess.call([mypy_command] + extra_args + python_files)
if args.linecoverage_report:
# Move the coverage report to where coveralls will look for it.
try:
os.rename('linecoverage-report/coverage.txt', '.coverage')
except OSError:
# maybe mypy crashed; exit with its error code
pass
sys.exit(rc)
else:
print("There are no files to run mypy on.")

View File

@ -1,3 +1,3 @@
six==1.10.0
git+https://github.com/python/mypy.git@e1c5a255877cf817eda525466b0d33f8bc4e50b3
git+https://github.com/rwbarton/mypy.git@3f4497689636cc9eea44239ba3ab73f1f5c7aaa6
typed-ast==0.5.2

View File

@ -1,7 +1,7 @@
#!/bin/bash
echo '+ ./tools/run-mypy'
./tools/run-mypy
echo '+ ./tools/run-mypy --linecoverage-report'
./tools/run-mypy --linecoverage-report
retcode="$?"
if [ "$retcode" == "0" ]; then