diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d55356..5f8c97b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,31 @@ jobs: uv run ruff check src/ tests/ scripts/ uv run ruff format --check src/ tests/ scripts/ + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install uv + uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 + with: + version: ${{ env.UV_VERSION }} + enable-cache: true + + - name: Install the complete locked test environment + run: uv sync --locked --all-extras --all-groups + + - name: Enforce package coverage + run: uv run pytest tests/ -q -ra --cov=ml4t.data --cov-report=term-missing + dependency-audit: name: Dependency Audit runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8a03b8..a9fca8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -102,7 +102,7 @@ jobs: uv run ruff check src/ tests/ scripts/ uv run ruff format --check src/ tests/ scripts/ uv run ty check - uv run pytest tests/ -q -ra + uv run pytest tests/ -q -ra --cov=ml4t.data --cov-report=term-missing uv run pytest tests/ -q -ra -W error::ResourceWarning - name: Audit locked dependencies run: | diff --git a/AGENTS.md b/AGENTS.md index 74644a7..0a07fcf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -60,7 +60,7 @@ Run focused tests while editing, then run the repository gates: uv run ruff check src tests scripts uv run ruff format --check src tests scripts uv run ty check -uv run pytest tests -q -ra +uv run pytest tests -q -ra --cov=ml4t.data --cov-report=term-missing uv run pytest tests -q -ra -W error::ResourceWarning uv run mkdocs build --strict uv build diff --git a/README.md b/README.md index 78fbe5d..8055c60 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ uv run pre-commit install uv run ruff check src/ tests/ uv run ruff format --check src/ tests/ uv run ty check -uv run pytest tests/ -q +uv run pytest tests/ -q -ra --cov=ml4t.data --cov-report=term-missing uv run mkdocs build --strict uv build ``` diff --git a/docs/contributing/testing.md b/docs/contributing/testing.md index a56bad7..f8b7446 100644 --- a/docs/contributing/testing.md +++ b/docs/contributing/testing.md @@ -14,11 +14,11 @@ uv sync --locked --all-extras --all-groups ## Run the default lane ```bash -uv run pytest tests -q -ra +uv run pytest tests -q -ra --cov=ml4t.data --cov-report=term-missing ``` `pyproject.toml` excludes `slow`, `paid_tier`, `integration`, and `requires_api_key` tests from this -command. It also enables strict marker validation, so an undeclared marker fails collection. +command. It also enables strict marker validation and fails if package coverage falls below 85%. Run the separate resource-leak lane before submitting a change that opens files, HTTP clients, or other managed resources: @@ -82,11 +82,8 @@ Import-time behavior must not require unrelated extras or credentials. ## Coverage and failure diagnosis -Generate a local report with the package import path: - -```bash -uv run pytest tests -q --cov=ml4t.data --cov-report=term-missing -``` +The default lane reports missing lines for the `ml4t.data` package and enforces the same 85% +threshold as CI and the release workflow. When a test fails only in the full suite, rerun it sequentially and preserve the order-dependent reproduction. Do not remove the resource-warning lane, weaken markers, or replace a live contract diff --git a/pyproject.toml b/pyproject.toml index 004cb6e..687b8c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -301,6 +301,8 @@ omit = [ ] [tool.coverage.report] +fail_under = 85 +show_missing = true exclude_lines = [ "pragma: no cover", "def __repr__",