Skip to content

Commit

Permalink
ci: try using coverage directly in action
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed Nov 16, 2023
1 parent 33847e7 commit 42f6ae3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 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,19 @@ 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

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 tests/test_boot_control && 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

0 comments on commit 42f6ae3

Please sign in to comment.