Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ jobs:
- name: Install dependencies
run: |
uv sync --all-extras
uv pip install pytest-cov

- name: Download spaCy models
run: |
Expand All @@ -130,5 +129,28 @@ jobs:
uv run python -m nltk.downloader words

- name: Run tests with coverage
# --cov-fail-under enforces the overall regression floor (configured in
# pyproject.toml [tool.coverage.report] fail_under = 33).
# Patch coverage (new/changed lines ≥ 80%) is enforced by Codecov below.
run: |
uv run pytest tests/ --cov=src/risk_assessment --cov-report=xml --cov-report=html --cov-report=term
uv run pytest tests/ \
--cov=src/risk_assessment \
--cov-report=xml \
--cov-report=html \
--cov-report=term-missing

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
fail_ci_if_error: true
verbose: true

- name: Upload HTML coverage report as artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-html-report
path: htmlcov/
retention-days: 14
23 changes: 23 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
coverage:
status:
project:
# Overall coverage must not drop below the current baseline.
# `target: auto` means "don't regress from the last commit on the base branch".
# The 1% threshold gives a small float to absorb measurement noise.
default:
target: auto
threshold: 1%
informational: false # fails the PR check if breached

patch:
# Lines added or changed by the PR must be covered at ≥ 80%.
default:
target: 80%
threshold: 0%
informational: false # fails the PR check if breached

comment:
layout: "reach,diff,flags,files"
behavior: default # updates the existing comment on re-push
require_changes: true # only post when coverage actually changes
hide_project_coverage: false
16 changes: 15 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,18 @@ include = ["src", "tests"]
exclude = [".pre-commit-config.yaml"]

[tool.pytest.ini_options]
addopts = "--cov=risk_assessment --cov-report html"
addopts = "--cov=src/risk_assessment --cov-report=html --cov-report=xml --cov-report=term-missing"

[tool.coverage.run]
source = ["src/risk_assessment"]
omit = [
"*/tests/*",
"*/__init__.py",
]

[tool.coverage.report]
# Regress guard: overall coverage must not drop below this.
# Update this value when coverage genuinely improves.
fail_under = 33
show_missing = true
skip_covered = false
Loading