mirror of https://github.com/zulip/zulip.git
Generate mypy coverage report for travis + coveralls.
This commit is contained in:
parent
04e2745136
commit
0b7852f081
|
@ -0,0 +1,2 @@
|
||||||
|
service_name: travis-pro
|
||||||
|
repo_token: hnXUEBKsORKHc8xIENGs9JjktlTb2HKlG
|
18
.travis.yml
18
.travis.yml
|
@ -1,6 +1,7 @@
|
||||||
before_install:
|
before_install:
|
||||||
- nvm install 0.10
|
- nvm install 0.10
|
||||||
install:
|
install:
|
||||||
|
- pip install coveralls
|
||||||
- tools/travis/setup-$TEST_SUITE
|
- tools/travis/setup-$TEST_SUITE
|
||||||
- tools/clean-venv-cache --travis
|
- tools/clean-venv-cache --travis
|
||||||
cache:
|
cache:
|
||||||
|
@ -9,10 +10,15 @@ cache:
|
||||||
- $HOME/phantomjs
|
- $HOME/phantomjs
|
||||||
- $HOME/zulip-venv-cache
|
- $HOME/zulip-venv-cache
|
||||||
env:
|
env:
|
||||||
- TEST_SUITE=frontend
|
global:
|
||||||
- TEST_SUITE=backend
|
- COVERALLS_PARALLEL=true
|
||||||
- TEST_SUITE=production
|
- COVERALLS_SERVICE_NAME=travis-pro
|
||||||
- TEST_SUITE=py3k
|
- COVERALLS_REPO_TOKEN=hnXUEBKsORKHc8xIENGs9JjktlTb2HKlG
|
||||||
|
matrix:
|
||||||
|
- TEST_SUITE=frontend
|
||||||
|
- TEST_SUITE=backend
|
||||||
|
- TEST_SUITE=production
|
||||||
|
- TEST_SUITE=py3k
|
||||||
language: python
|
language: python
|
||||||
python:
|
python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
|
@ -28,3 +34,7 @@ services:
|
||||||
- docker
|
- docker
|
||||||
addons:
|
addons:
|
||||||
postgresql: "9.3"
|
postgresql: "9.3"
|
||||||
|
after_success:
|
||||||
|
coveralls
|
||||||
|
notifications:
|
||||||
|
webhooks: https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN
|
||||||
|
|
|
@ -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,
|
parser.add_argument('-a', '--all', dest='all', action='store_true', default=False,
|
||||||
help="""run mypy on all python files, ignoring the exclude list.
|
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.""")
|
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,
|
parser.add_argument('--linecoverage-report', dest='linecoverage_report', action='store_true', default=False,
|
||||||
help="""run the linecount report to see annotation coverage""")
|
help="""run the linecoverage report to see annotation coverage""")
|
||||||
parser.add_argument('--disallow-untyped-defs', dest='disallow_untyped_defs', action='store_true', default=False,
|
parser.add_argument('--disallow-untyped-defs', dest='disallow_untyped_defs', action='store_true', default=False,
|
||||||
help="""throw errors when functions are not annotated""")
|
help="""throw errors when functions are not annotated""")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -58,9 +58,9 @@ else:
|
||||||
mypy_command = "mypy"
|
mypy_command = "mypy"
|
||||||
|
|
||||||
extra_args = ["--fast-parser", "--silent-imports", "--py2", "--check-untyped-defs"]
|
extra_args = ["--fast-parser", "--silent-imports", "--py2", "--check-untyped-defs"]
|
||||||
if args.linecount_report:
|
if args.linecoverage_report:
|
||||||
extra_args.append("--linecount-report")
|
extra_args.append("--linecoverage-report")
|
||||||
extra_args.append("linecount-report")
|
extra_args.append("linecoverage-report")
|
||||||
if args.disallow_untyped_defs:
|
if args.disallow_untyped_defs:
|
||||||
extra_args.append("--disallow-untyped-defs")
|
extra_args.append("--disallow-untyped-defs")
|
||||||
|
|
||||||
|
@ -68,6 +68,13 @@ if args.disallow_untyped_defs:
|
||||||
# run mypy
|
# run mypy
|
||||||
if python_files:
|
if python_files:
|
||||||
rc = subprocess.call([mypy_command] + extra_args + 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)
|
sys.exit(rc)
|
||||||
else:
|
else:
|
||||||
print("There are no files to run mypy on.")
|
print("There are no files to run mypy on.")
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
six==1.10.0
|
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
|
typed-ast==0.5.2
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo '+ ./tools/run-mypy'
|
echo '+ ./tools/run-mypy --linecoverage-report'
|
||||||
./tools/run-mypy
|
./tools/run-mypy --linecoverage-report
|
||||||
retcode="$?"
|
retcode="$?"
|
||||||
|
|
||||||
if [ "$retcode" == "0" ]; then
|
if [ "$retcode" == "0" ]; then
|
||||||
|
|
Loading…
Reference in New Issue