From 01d714e88bf5ee68a1ea81e642dad43d650628a3 Mon Sep 17 00:00:00 2001 From: Elton Cardoso do Nascimento <43186596+EltonCN@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:30:06 -0300 Subject: [PATCH] Coverage check --- .github/workflows/test.yml | 13 +++++++++---- .gitignore | 2 ++ tests/check_coverage.py | 8 ++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 tests/check_coverage.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6821505..b497ad2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,9 @@ name: Test on: push: - branches: [ develop, main ] + branches: [ dev, main ] pull_request: - branches: [ develop, main ] + branches: [ dev, main ] jobs: build: @@ -25,9 +25,14 @@ jobs: run: | python3 -m pip install --upgrade pip python3 -m pip install pytest + python3 -m pip install pytest-cov python3 -m pip install .[tests] - name: Tests run: | - pytest - shell: bash \ No newline at end of file + pytest --cov=cst_python --cov-report json + shell: bash + + - name: Coverage Check + run: | + python3 tests/check_coverage.py \ No newline at end of file diff --git a/.gitignore b/.gitignore index efa407c..d5e6f4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +coverage.json + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/tests/check_coverage.py b/tests/check_coverage.py new file mode 100644 index 0000000..044a576 --- /dev/null +++ b/tests/check_coverage.py @@ -0,0 +1,8 @@ +import json + +if __name__ == "__main__": + + with open("coverage.json") as file: + coverage_info = json.load(file) + + assert coverage_info["totals"]["percent_covered"] > 78 \ No newline at end of file