diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000000..7804da58abc9 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,39 @@ +[run] +branch = true + +source = + datumaro/datumaro/ + cvat/apps/ + utils/cli/ + +omit = + datumaro/datumaro/__main__.py + datumaro/datumaro/version.py + cvat/settings/* + */tests/* + */test_* + */_test_* + */migrations/* + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about missing debug-only code: + def __repr__ + if\s+[\w\.()]+\.isEnabledFor\(log\.DEBUG\): + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + # Don't complain if non-runnable code isn't run: + if 0: + if __name__ == .__main__.: + +# don't fail on the code that can be found +ignore_errors = true + +skip_empty = true \ No newline at end of file diff --git a/.gitignore b/.gitignore index 23872063a325..bc0260f9de3a 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ docker-compose.override.yml __pycache__ *.pyc ._* +.coverage # Ignore development npm files node_modules diff --git a/.travis.yml b/.travis.yml index 9875fc6e3150..278ec6bbda9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,21 @@ python: services: - docker +env: + - CONTAINER_COVERAGE_DATA_DIR="/coverage_data" + HOST_COVERAGE_DATA_DIR="${TRAVIS_BUILD_DIR}/coverage_data" + +install: + - gem install coveralls-lcov + - pip install coveralls + before_script: - docker-compose -f docker-compose.yml -f docker-compose.ci.yml build + - mkdir -m a=rwx -p ${HOST_COVERAGE_DATA_DIR} script: - - 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' - - 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' - - docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'python3 manage.py test datumaro/' - - 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' + - 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}' + - 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}' + +after_success: + - coveralls-lcov -v -n lcov.info > coverage.json && coveralls --merge=coverage.json \ No newline at end of file diff --git a/cvat/requirements/testing.txt b/cvat/requirements/testing.txt index f5f61eec145b..79c222a250fd 100644 --- a/cvat/requirements/testing.txt +++ b/cvat/requirements/testing.txt @@ -3,3 +3,4 @@ fakeredis==1.1.0 # Fix dependencies for fakeredis 1.1.0 # Pip will not reinstall six package if it is installed already six==1.12.0 +coveralls \ No newline at end of file diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index f67559124c1e..ac3a7c548e3e 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -15,3 +15,6 @@ services: TRAVIS_JOB_ID: TRAVIS_BRANCH: TRAVIS_PULL_REQUEST: + CONTAINER_COVERAGE_DATA_DIR: + volumes: + - ${HOST_COVERAGE_DATA_DIR}:${CONTAINER_COVERAGE_DATA_DIR}