diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0b7c8be6f..972474573 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,11 +11,13 @@ jobs: uses: actions/checkout@v3 - name: Build ota-test_base docker image run: | - docker-compose -f docker/docker-compose_tests.yml build + docker compose -f docker/docker-compose_tests.yml build - name: Execute pytest with coverage trace under ota-test_base container 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 -p test_result + docker compose -f docker/docker-compose_tests.yml up --abort-on-container-exit + # export the coverage report to the comment! - name: Add coverage report to PR comment continue-on-error: true diff --git a/.gitignore b/.gitignore index 3992bbacf..12e4e8092 100644 --- a/.gitignore +++ b/.gitignore @@ -166,3 +166,6 @@ build # local vscode configs .devcontainer .vscode + +# local test artifacts +test_result/ diff --git a/docker/docker-compose_tests.yml b/docker/docker-compose_tests.yml index 0c5ff3f61..1b5747be0 100644 --- a/docker/docker-compose_tests.yml +++ b/docker/docker-compose_tests.yml @@ -6,10 +6,10 @@ services: dockerfile: ./docker/test_base/Dockerfile image: ota-test_base network_mode: bridge - command: "python3 -m pytest" 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 diff --git a/docker/test_base/entry_point.sh b/docker/test_base/entry_point.sh index 4725b20f3..7e4309e1e 100644 --- a/docker/test_base/entry_point.sh +++ b/docker/test_base/entry_point.sh @@ -24,5 +24,7 @@ TESTS_DEPENDENCIES="${OTA_CLIENT_DIR}/tests/requirements.txt" python3 -m pip install --no-cache-dir -q -r $TESTS_DEPENDENCIES # exec the input params -echo "execute command..." -exec "$@" +echo "execute test with coverage" +cd "${OTA_CLIENT_DIR}" +coverage run -m pytest --junit-xml=test_result/pytest.xml "${@:-}" +coverage xml -o test_result/coverage.xml