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 18261c6 commit 388a306
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ This is the main entry for selecting a template for your PR.
- [Feature](?expand=1&template=feature.md)
- [Fix](?expand=1&template=fix.md)
- [Refinement](?expand=1&template=refinement.md)
- [Chore/tag](?expand=1&template=tag.md)

If PR type is not in the above list, feel free to start from blank PR body.

** DON'T INCLUDE THIS PAGE'S CONTENTS IN YOUR PR BODY. **
** DON'T INCLUDE THIS PAGE'S CONTENTS IN YOUR PR BODY. **
28 changes: 28 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Description

## Commits since <last_tag_version>

<!-- Insert the comparing URL here.
For example:
[`tag/v3.6.0...cf54361`](https://github.com/tier4/ota-client/compare/v3.6.0...cf54361)
-->

### Bug fix

<!-- List of bug fix PRs if any. -->


### Refinement

<!-- List of refinement PRs if any. -->

### Chore

<!-- List of chore PRs if any. -->

### Deps

<!-- List of deps PRs. -->
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
2 changes: 1 addition & 1 deletion otaclient/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ boto3==1.17.112
retrying==1.3.3
urllib3>=1.26.8, <2.0.0
uvicorn[standard]==0.20.0
aiohttp==3.8.5
aiohttp==3.8.6
aiofiles==22.1.0
zstandard==0.18.0
pycurl==7.45.1
Expand Down
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 388a306

Please sign in to comment.