From 42f6ae3100205c862968ace5f0f4bb5f20aeab29 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Thu, 16 Nov 2023 06:35:18 +0000 Subject: [PATCH] ci: try using coverage directly in action --- .github/workflows/test.yml | 11 +++++++++-- docker/docker-compose_tests.yml | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a86e70bd8..1c6de4c1e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,6 +3,7 @@ name: test CI on: [pull_request] jobs: + pytest_with_coverage: runs-on: ubuntu-20.04 timeout-minutes: 20 @@ -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/pytest-coverage-comment@v1.1.40 + uses: MishaKav/pytest-coverage-comment@v1.1.49 + with: + - pytest-xml-coverage-path: ./test_result/coverage.xml + python_lint_check: runs-on: ubuntu-20.04 timeout-minutes: 3 diff --git a/docker/docker-compose_tests.yml b/docker/docker-compose_tests.yml index 0c5ff3f61..d52ec3cc0 100644 --- a/docker/docker-compose_tests.yml +++ b/docker/docker-compose_tests.yml @@ -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