From 6350b6f9f61d024316ab313d47bb37d16a7b0ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mal=C3=A9s?= <85952626+joaomper-TE@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:43:29 +0100 Subject: [PATCH 1/3] feature: add test coverage Example: https://github.com/joaomper-TE/thousandeyes-sdk-python/pull/25 --- .github/workflows/python.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 1f19a282..c8b6feec 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -23,7 +23,17 @@ jobs: - name: Install and test modules run: | pip install pytest - for module in $(find . -maxdepth 1 -type d -name "thousandeyes-sdk-*" ! -name "thousandeyes-sdk-core" | cut -c 3-); do + pip install coverage + + for module in $(find . -maxdepth 1 -type d -name "thousandeyes-sdk-*" ! -name "thousandeyes-sdk-core" | cut -c 3-); do pip install -e $module - pytest $module + coverage run -m pytest $module done + coverage xml + - name: Get Cover + uses: orgoro/coverage@v3.2 + with: + coverageFile: ./coverage.xml + thresholdAll: 0.4 + thresholdNew: 0.6 + token: ${{ secrets.GITHUB_TOKEN }} From 118bf9877ab4c7eb91c5bd028ca296d4e3582365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mal=C3=A9s?= <85952626+joaomper-TE@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:47:53 +0100 Subject: [PATCH 2/3] Update python.yaml --- .github/workflows/python.yaml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index c8b6feec..aae6dd62 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -25,15 +25,22 @@ jobs: pip install pytest pip install coverage + # Initialize coverage data file + coverage erase + for module in $(find . -maxdepth 1 -type d -name "thousandeyes-sdk-*" ! -name "thousandeyes-sdk-core" | cut -c 3-); do pip install -e $module - coverage run -m pytest $module + coverage run --append -m pytest $module done + + # Combine coverage data and generate report + coverage combine coverage xml - - name: Get Cover + + - name: Get Coverage uses: orgoro/coverage@v3.2 with: - coverageFile: ./coverage.xml - thresholdAll: 0.4 - thresholdNew: 0.6 - token: ${{ secrets.GITHUB_TOKEN }} + coverageFile: ./coverage.xml + thresholdAll: 0.4 + thresholdNew: 0.6 + token: ${{ secrets.GITHUB_TOKEN }} From 5de60cfc7c782a6508c359b27e3a4aaffb497169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mal=C3=A9s?= <85952626+joaomper-TE@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:59:42 +0100 Subject: [PATCH 3/3] Update python.yaml --- .github/workflows/python.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index aae6dd62..3b8d9a5c 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -30,11 +30,14 @@ jobs: for module in $(find . -maxdepth 1 -type d -name "thousandeyes-sdk-*" ! -name "thousandeyes-sdk-core" | cut -c 3-); do pip install -e $module - coverage run --append -m pytest $module + coverage run --source=$module -m pytest $module + # Move the .coverage file to a unique name + mv .coverage .coverage.$module done - # Combine coverage data and generate report - coverage combine + # Combine all .coverage files + coverage combine .coverage.* + coverage report coverage xml - name: Get Coverage