Skip to content

Commit

Permalink
merge chore/use_coverage_py
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed Nov 17, 2023
1 parent 1c56334 commit 47ce3ed
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: test CI
on: [pull_request]

jobs:

pytest_with_coverage:
runs-on: ubuntu-20.04
timeout-minutes: 20
Expand All @@ -13,13 +14,20 @@ jobs:
run: |
docker-compose -f docker/docker-compose_tests.yml build
- name: Execute pytest with coverage trace under ota-test_base container
# NOTE: test_result folder holds the coverage.xml, check docker-compose_tests.yml for
# coverage execution command line and volumes configurations.
run: |
set -o pipefail
docker-compose -f docker/docker-compose_tests.yml up --no-log-prefix --abort-on-container-exit | tee pytest-coverage.txt
mkdir test_result
docker-compose -f docker/docker-compose_tests.yml up --no-log-prefix --abort-on-container-exit
# export the coverage report to the comment!
- name: Add coverage report to PR comment
continue-on-error: true
uses: MishaKav/[email protected]
uses: MishaKav/[email protected]
with:
pytest-xml-coverage-path: test_result/coverage.xml
junitxml-path: test_result/pytest.xml

python_lint_check:
runs-on: ubuntu-20.04
timeout-minutes: 3
Expand Down
3 changes: 2 additions & 1 deletion docker/docker-compose_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ services:
dockerfile: ./docker/test_base/Dockerfile
image: ota-test_base
network_mode: bridge
command: "python3 -m pytest"
command: "bash -c 'coverage run -m pytest --junit-xml=test_result/pytest.xml && coverage xml -o test_result/coverage.xml'"
container_name: ota-test
volumes:
- ../pyproject.toml:/ota-client/pyproject.toml:ro
- ../.flake8:/ota-client/.flake8:ro
- ../otaclient:/ota-client/otaclient:ro
- ../tests:/ota-client/tests:ro
- ../test_result:/ota-client/test_result:rw
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,28 @@ extend-exclude = '''(

[tool.coverage.run]
branch = false
omit = ["**/*_pb2.py*","**/*_pb2_grpc.py*"]
source = ["otaclient.app", "otaclient.ota_proxy"]

[tool.coverage.report]
omit = ["**/*_pb2.py*","**/*_pb2_grpc.py*"]
exclude_also = [
"def __repr__",
"if cfg.DEBUG_MODE",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]
show_missing = true
skip_covered = true
skip_empty = true

[tool.pyright]
exclude = ["**/__pycache__"]
ignore = ["**/*_pb2.py*","**/*_pb2_grpc.py*"]
pythonVersion = "3.8"

[tool.pytest.ini_options]
addopts = "--cov=otaclient.app --cov=otaclient.ota_proxy"
asyncio_mode = "auto"
log_auto_indent = true
log_format = "%(asctime)s %(levelname)s %(filename)s %(funcName)s,%(lineno)d %(message)s"
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pytest==7.1.2
pytest-asyncio==0.21.0
pytest-mock==3.8.2
pytest-cov==3.0.0
coverage==7.2.5
black==22.3.0
flake8==4.0.1
requests-mock==1.10.0

0 comments on commit 47ce3ed

Please sign in to comment.