Skip to content

Commit acdf233

Browse files
authored
Add coverage for python (#1483)
1 parent 8df5d61 commit acdf233

File tree

5 files changed

+58
-4
lines changed

5 files changed

+58
-4
lines changed

.coveragerc

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[run]
2+
branch = true
3+
4+
source =
5+
datumaro/datumaro/
6+
cvat/apps/
7+
utils/cli/
8+
9+
omit =
10+
datumaro/datumaro/__main__.py
11+
datumaro/datumaro/version.py
12+
cvat/settings/*
13+
*/tests/*
14+
*/test_*
15+
*/_test_*
16+
*/migrations/*
17+
18+
[report]
19+
# Regexes for lines to exclude from consideration
20+
exclude_lines =
21+
# Have to re-enable the standard pragma
22+
pragma: no cover
23+
24+
# Don't complain about missing debug-only code:
25+
def __repr__
26+
if\s+[\w\.()]+\.isEnabledFor\(log\.DEBUG\):
27+
28+
# Don't complain if tests don't hit defensive assertion code:
29+
raise AssertionError
30+
raise NotImplementedError
31+
32+
# Don't complain if non-runnable code isn't run:
33+
if 0:
34+
if __name__ == .__main__.:
35+
36+
# don't fail on the code that can be found
37+
ignore_errors = true
38+
39+
skip_empty = true

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ docker-compose.override.yml
1919
__pycache__
2020
*.pyc
2121
._*
22+
.coverage
2223

2324
# Ignore development npm files
2425
node_modules

.travis.yml

+14-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ python:
88
services:
99
- docker
1010

11+
env:
12+
- CONTAINER_COVERAGE_DATA_DIR="/coverage_data"
13+
HOST_COVERAGE_DATA_DIR="${TRAVIS_BUILD_DIR}/coverage_data"
14+
15+
install:
16+
- gem install coveralls-lcov
17+
- pip install coveralls
18+
1119
before_script:
1220
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml build
21+
- mkdir -m a=rwx -p ${HOST_COVERAGE_DATA_DIR}
1322

1423
script:
15-
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'python3 manage.py test cvat/apps utils/cli'
16-
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'python3 manage.py test --pattern="_tests.py" cvat/apps/dataset_manager'
17-
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'python3 manage.py test datumaro/'
18-
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd cvat-data && npm install && cd ../cvat-core && npm install && npm run test && npm run coveralls'
24+
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'coverage run -a manage.py test cvat/apps utils/cli && coverage run -a --source cvat/apps/ manage.py test --pattern="_tests.py" cvat/apps/dataset_manager && mv .coverage ${CONTAINER_COVERAGE_DATA_DIR}'
25+
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd cvat-data && npm install && cd ../cvat-core && npm install && npm run test && mv ./reports/coverage/lcov.info ${CONTAINER_COVERAGE_DATA_DIR}'
26+
27+
after_success:
28+
- coveralls-lcov -v -n lcov.info > coverage.json && coveralls --merge=coverage.json

cvat/requirements/testing.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ fakeredis==1.1.0
33
# Fix dependencies for fakeredis 1.1.0
44
# Pip will not reinstall six package if it is installed already
55
six==1.12.0
6+
coveralls

docker-compose.ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ services:
1515
TRAVIS_JOB_ID:
1616
TRAVIS_BRANCH:
1717
TRAVIS_PULL_REQUEST:
18+
CONTAINER_COVERAGE_DATA_DIR:
19+
volumes:
20+
- ${HOST_COVERAGE_DATA_DIR}:${CONTAINER_COVERAGE_DATA_DIR}

0 commit comments

Comments
 (0)