Skip to content

Commit

Permalink
Generate mypy coverage report for travis + coveralls.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwbarton authored and timabbott committed Jun 4, 2016
1 parent 04e2745 commit 0b7852f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_name: travis-pro
repo_token: hnXUEBKsORKHc8xIENGs9JjktlTb2HKlG
18 changes: 14 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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"
Expand All @@ -28,3 +34,7 @@ services:
- docker
addons:
postgresql: "9.3"
after_success:
coveralls
notifications:
webhooks: https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN
17 changes: 12 additions & 5 deletions tools/run-mypy
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -58,16 +58,23 @@ 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")


# 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.")
2 changes: 1 addition & 1 deletion tools/setup/py3_test_reqs.txt
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions tools/travis/mypy
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0b7852f

Please sign in to comment.