Adding new task in CI to report code-coverage in branches and PRs. (#668)

* Adding new task in CI to report code-coverage in branches and PRs.
* Refactoring thirdparty libs into a separate module.
This commit is contained in:
Varad Meru 2020-05-01 15:24:13 -07:00 коммит произвёл GitHub
Родитель da2b2648cc
Коммит fa9e9f5d5a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 91 добавлений и 13 удалений

Просмотреть файл

@ -0,0 +1,7 @@
#!/bin/bash
set -e -x
coverage combine
coverage xml
coverage erase

Просмотреть файл

@ -5,4 +5,5 @@ export AzureWebJobsStorage=$LINUXSTORAGECONNECTIONSTRING
export AzureWebJobsCosmosDBConnectionString=$LINUXCOSMOSDBCONNECTIONSTRING
export AzureWebJobsEventHubConnectionString=$LINUXEVENTHUBCONNECTIONSTRING
export AzureWebJobsServiceBusConnectionString=$LINUXSERVICEBUSCONNECTIONSTRING
pytest tests/endtoend
coverage run -p --branch -m pytest tests/endtoend

Просмотреть файл

@ -1,4 +1,4 @@
#!/bin/bash
set -e -x
pytest tests/unittests
coverage run -p --branch -m pytest tests/unittests

52
.coveragerc Normal file
Просмотреть файл

@ -0,0 +1,52 @@
[run]
parallel=True
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
def __repr__
# Don't complain about missing debug-only code:
if self\.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 False:
if __name__ == .__main__.:
# Not counting some extra lines which don't need to be counted.
print
def setUp
def suite
ignore_errors = True
omit =
*/build/*
*/doc/*
*/examples/*
*/postprocessing/*
*/test/*
*/setup.py
setup.py
*/site-packages/*
*/venv/*
*/docs/*
*/pack/*
*/python/*
*/build/*
*/.venv/*
*/.env*/*
*/.vscode/*
*/tests/*
# Removing the imported libraries that might show up in this.
*/azure/functions/*
*/azure/*
*/azure_functions_worker/_thirdparty/*

Просмотреть файл

@ -3,6 +3,6 @@ ignore = W503,E402,E731
exclude =
.git, __pycache__, build, dist, .eggs, .github, .local, docs/,
Samples, azure_functions_worker/protos/,
azure_functions_worker/typing_inspect.py,
azure_functions_worker/_thirdparty/typing_inspect.py,
tests/unittests/test_typing_inspect.py,
.venv*, .env*, .vscode, venv

Просмотреть файл

@ -48,6 +48,14 @@ jobs:
LINUXEVENTHUBCONNECTIONSTRING: $(LinuxEventHubConnectionString)
LINUXSERVICEBUSCONNECTIONSTRING: $(LinuxServiceBusConnectionString)
displayName: 'E2E Tests'
- bash: |
chmod +x .ci/linux_devops_code_coverage_generate.sh
.ci/linux_devops_code_coverage_generate.sh
displayName: 'Generate Code Coverage XML file'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: cobertura
summaryFileLocation: coverage.xml
- job: Build_WINDOWS_X64
dependsOn: 'Tests'

0
azure_functions_worker/_thirdparty/__init__.py поставляемый Normal file
Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -4,7 +4,7 @@ import typing
from . import bindings
from . import protos
from . import typing_inspect
from ._thirdparty import typing_inspect
class ParamTypeInfo(typing.NamedTuple):

Просмотреть файл

@ -3,7 +3,7 @@
import argparse
from . import aio_compat
from ._thirdparty import aio_compat
from . import dispatcher
from . import logging
from .logging import error_logger, logger

Просмотреть файл

@ -30,7 +30,7 @@ import re
import grpc
import requests
from . import aio_compat
from azure_functions_worker._thirdparty import aio_compat
from . import dispatcher
from . import protos
from .utils.common import is_envvar_true

Просмотреть файл

@ -13,11 +13,11 @@ warn_return_any = True
disallow_subclassing_any = False
ignore_missing_imports = True
[mypy-azure_functions_worker.aio_compat]
[mypy-azure_functions_worker._thirdparty.aio_compat]
ignore_errors = True
[mypy-azure_functions_worker.protos.*]
ignore_errors = True
[mypy-azure_functions_worker.typing_inspect]
[mypy-azure_functions_worker._thirdparty.typing_inspect]
ignore_errors = True

Просмотреть файл

@ -271,7 +271,8 @@ setup(
'azure_functions_worker.protos.identity',
'azure_functions_worker.protos.shared',
'azure_functions_worker.bindings',
'azure_functions_worker.utils'],
'azure_functions_worker.utils',
'azure_functions_worker._thirdparty'],
install_requires=[
'grpcio~=1.26.0',
'grpcio-tools~=1.26.0',
@ -283,6 +284,7 @@ setup(
'mypy',
'pytest',
'requests==2.*',
'coverage'
]
},
include_package_data=True,

Просмотреть файл

@ -52,10 +52,18 @@ class TestGRPC(testutils.AsyncTestCase):
test_env = {}
await self._verify_environment_reloaded(test_env=test_env)
@unittest.skipIf(sys.platform == 'darwin',
'MacOS creates the processes specific var folder in '
'/private filesystem and not in /var like in linux '
'systems.')
async def test_changing_current_working_directory(self):
test_cwd = tempfile.gettempdir()
await self._verify_environment_reloaded(test_cwd=test_cwd)
@unittest.skipIf(sys.platform == 'darwin',
'MacOS creates the processes specific var folder in '
'/private filesystem and not in /var like in linux '
'systems.')
async def test_reload_env_message(self):
test_env = {'TEST_KEY': 'foo', 'HELLO': 'world'}
test_cwd = tempfile.gettempdir()
@ -95,6 +103,7 @@ class TestGRPC(testutils.AsyncTestCase):
def _verify_azure_namespace_import(self, result, expected_output):
try:
print(os.getcwd())
path_import_script = os.path.join(
testutils.UNIT_TESTS_ROOT,
'azure_namespace_import',

Просмотреть файл

@ -2,12 +2,11 @@
# Author: Ivan Levkivskyi
# License: MIT
from azure_functions_worker.typing_inspect import (
from azure_functions_worker._thirdparty.typing_inspect import (
is_generic_type, is_callable_type, is_tuple_type, is_union_type,
is_typevar, is_classvar, get_origin, get_parameters, get_last_args, get_args,
get_generic_type, get_generic_bases, get_last_origin, typed_dict_keys,
)
from unittest import TestCase, main, skipIf, skipUnless
get_generic_type, get_generic_bases, get_last_origin, )
from unittest import TestCase, main, skipIf
from typing import (
Union, ClassVar, Callable, Optional, TypeVar, Sequence, Mapping,
MutableMapping, Iterable, Generic, List, Any, Dict, Tuple, NamedTuple,