diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..c712d259 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +omit = tests/* diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 4b599662..81372125 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1,4 +1,4 @@ -name: Run Pytest +name: Run Pytest with Coverage on: push: @@ -35,8 +35,27 @@ jobs: - name: Create virtual environment and install dependencies run: | uv venv - uv sync + uv sync --dev # Include dev tools like pytest and pytest-cov - - name: Run tests + - name: Run tests and generate Cobertura coverage report run: | - uv run pytest + mkdir -p coverage + PYTHONPATH=. uv run pytest \ + --cov \ + --cov-report=term-missing \ + --cov-report=xml:coverage/cobertura.xml \ + --cov-fail-under=80 \ + --cov-report=html:coverage/html + + - name: Code Coverage Report + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + filename: coverage/cobertura.xml + badge: true + fail_below_min: true + format: markdown + hide_branch_rate: true + hide_complexity: true + indicators: true + output: console + thresholds: '80 80' \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 661ef26d..2a5c024a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,4 +20,5 @@ dev = [ "polyfactory>=2.21.0", "pytest>=8.3.5", "pytest-mock>=3.14.0", + "pytest-cov>=4.1.0", ]