Skip to content

CI: Split off separate coverage job#3005

Merged
EwoutH merged 3 commits intomesa:mainfrom
EwoutH:codecov_debug
Dec 23, 2025
Merged

CI: Split off separate coverage job#3005
EwoutH merged 3 commits intomesa:mainfrom
EwoutH:codecov_debug

Conversation

@EwoutH
Copy link
Copy Markdown
Member

@EwoutH EwoutH commented Dec 23, 2025

After moving tests into subdirectories in, coverage.py consistently reported 0% coverage due to a conflict between pytest-cov and the new test package structure.

Changes:

  • Replace pytest --cov with coverage run -m pytest
  • Split coverage into dedicated CI job (Ubuntu 3.14 only)
  • Remove coverage overhead from cross-platform test runs

This is a workaround for #3004.

@EwoutH EwoutH marked this pull request as ready for review December 23, 2025 21:40
@mesa mesa deleted a comment from github-actions bot Dec 23, 2025
@mesa mesa deleted a comment from github-actions bot Dec 23, 2025
After moving tests into subdirectories in, coverage.py consistently reported 0% coverage due to a conflict between pytest-cov and the new test package structure.

Changes:
- Replace `pytest --cov` with `coverage run -m pytest`
- Add `relative_files = true` to coverage configuration
- Split coverage into dedicated CI job (Ubuntu 3.14 only)
- Remove coverage overhead from cross-platform test runs

Fixes mesa#3004
@EwoutH EwoutH changed the title Codecov debug CI: Split off separate coverage job Dec 23, 2025
This reverts commit e76468e.
@EwoutH EwoutH added the ci Release notes label label Dec 23, 2025
@EwoutH
Copy link
Copy Markdown
Member Author

EwoutH commented Dec 23, 2025

For some reason replacing pytest --cov with coverage run -m pytest fixes this. Very weird.

Merging to resolve, but still curious about the root cause.

@EwoutH EwoutH merged commit 52ecf2a into mesa:main Dec 23, 2025
14 checks passed
@quaquel
Copy link
Copy Markdown
Member

quaquel commented Dec 23, 2025

Great to see it fixed and no idea here either about what's going on.

EwoutH pushed a commit that referenced this pull request Dec 27, 2025
## Summary
Improves coverage collection after test reorganization in #2994 by adopting `pytest`'s native coverage integration and measuring all code including tests.

## Problem
After moving tests into nested subdirectories, coverage.py reported 0% coverage. The root cause was a combination of:
1. Path resolution issues with nested test packages
2. Tests not being measured in coverage reports

## Solution
This PR implements reviewer feedback to adopt coverage best practices:

### Configuration Changes (`pyproject.toml`):
- **Added `source = ["."]`**: Measures all code in the project directory
- **Kept `source_pkgs = ["mesa"]`**: Specifically tracks the mesa package
- **Added `relative_files = true`**: Fixes path resolution for nested directories
- **Removed `omit = ["tests/*"]`**: Now measures test coverage (critical for verifying all tests run)
- **Added `[tool.coverage.paths]`**: Maps installed package paths for accurate coverage reporting

### CI Changes (`.github/workflows/build_lint.yml`):
- **Replaced** `coverage run -m pytest` + `coverage xml` (2 commands from #3005)
- **With** `python -Im pytest -p pytest_cov --cov --cov-report=xml --cov-report=markdown-append:"${GITHUB_STEP_SUMMARY}" --cov-context=test tests/` (single command)
- **Benefits**:
  - `-Im` flag ensures testing installed package, not git checkout
  - `-p pytest_cov` loads plugin early to avoid import issues
  - `--cov` (no value) measures everything per coverage config
  - Markdown report appears in GitHub Actions summary (better UX)
  - `--cov-context=test` enables per-test coverage tracking

---------

Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants