Skip to content

feat: ensure that tests have 100% coverage (i.e. no dead code in tests) - #3128

Closed
paul-nechifor wants to merge 1 commit into
mainfrom
paul/feat/test-coverage
Closed

feat: ensure that tests have 100% coverage (i.e. no dead code in tests)#3128
paul-nechifor wants to merge 1 commit into
mainfrom
paul/feat/test-coverage

Conversation

@paul-nechifor

Copy link
Copy Markdown
Contributor

Closes DIM-1318

Problem

We need to make sure that all tests are executed.If they're not, they're dead code and should be deleted.

Solution

  • Check that we have 100% coverage on test files.
  • Exclude tests which can't run (marked with skipif_in_ci and mujoco)

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a CI gate for detecting test code that never runs. The main changes are:

  • Collect coverage from regular, self-hosted, large, and Rust test jobs.
  • Combine coverage artifacts and require full coverage of test files.
  • Exclude test cases that cannot run in CI.
  • Add a minimal dependency group for the coverage gate.

Confidence Score: 5/5

No additional blocking issue qualifies for this follow-up review.

  • No new incomplete fix or distinct production failure was found beyond the existing review threads.

Important Files Changed

Filename Overview
.github/workflows/ci.yml Adds coverage artifact uploads and the cross-job test-file coverage gate.
bin/check-test-file-coverage Adds validation that reports unexecuted lines in discovered test files.
pyproject.toml Adds the coverage dependency group, relative paths, and CI marker exclusions.
uv.lock Locks the new coverage-gate dependency group.

Reviews (2): Last reviewed commit: "feat: ensure test coverage" | Re-trigger Greptile

Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
# line-covered by the union of all CI pytest jobs' coverage data.
# No `if:` needed: plain `needs` skips this job whenever an input job
# is skipped (fork PRs skip self-hosted-tests) or failed/cancelled.
needs: [tests, self-hosted-tests, rust]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Fork Pull Requests Skip Gate

self-hosted-tests is skipped for fork pull requests, and this unconditional needs dependency causes GitHub to skip the coverage gate too. A fork PR can therefore add or orphan a test file without this check running against the available test and Rust coverage.

@paul-nechifor
paul-nechifor force-pushed the paul/feat/test-coverage branch from 0bd4859 to 3076de9 Compare July 21, 2026 23:07
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

@@            Coverage Diff             @@
##             main    #3128      +/-   ##
==========================================
+ Coverage   73.14%   73.65%   +0.51%     
==========================================
  Files        1033     1033              
  Lines       93633    93054     -579     
  Branches     8518     8583      +65     
==========================================
+ Hits        68487    68543      +56     
+ Misses      22806    22170     -636     
- Partials     2340     2341       +1     
Flag Coverage Δ
OS-ubuntu-24.04-arm 66.72% <ø> (+0.49%) ⬆️
OS-ubuntu-latest 69.01% <ø> (+0.48%) ⬆️
Py-3.10 69.00% <ø> (+0.48%) ⬆️
Py-3.11 69.00% <ø> (+0.48%) ⬆️
Py-3.12 68.99% <ø> (+0.48%) ⬆️
Py-3.13 68.99% <ø> (+0.48%) ⬆️
Py-3.14 69.01% <ø> (+0.49%) ⬆️
Py-3.14t 68.99% <ø> (+0.48%) ⬆️
SelfHosted-Large 30.18% <ø> (+0.09%) ⬆️
SelfHosted-Linux 37.32% <ø> (+0.13%) ⬆️
SelfHosted-macOS 36.20% <ø> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread .github/workflows/ci.yml
python -m pytest -c /dev/null --rootdir . --noconftest --import-mode=importlib -p no:cacheprovider -v \
# Under coverage so the test-file-coverage gate can prove these
# files run: they importorskip themselves out of every other job.
python -m coverage run -m pytest -c /dev/null --rootdir . --noconftest --import-mode=importlib -p no:cacheprovider -v \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this skip the conftest in the first place...?

Comment thread .github/workflows/ci.yml

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels rather messy and convoluted. I'd much rather just have a path split in codecov and just add that as a required status check. No additional code needed. No extra CI steps needed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay. Do you want to do that?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a task to look at it (looks like we can use regex or globbing there), though I still think it'd be much cleaner to have a separate tests/ directory like other Python projects.

@github-actions github-actions Bot added the ready-to-merge Required CI checks have passed on this PR label Jul 22, 2026
@paul-nechifor
paul-nechifor marked this pull request as draft July 22, 2026 02:48
@github-actions github-actions Bot removed the ready-to-merge Required CI checks have passed on this PR label Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants