Write coverage data to repo root for Codecov upload - #142
Merged
nstarman merged 1 commit intoJul 14, 2026
Conversation
Tests run in a temporary directory (changedir = .tmp/{envname}), so
pytest-cov wrote the .coverage data file inside that temp dir. The
OpenAstronomy tox workflow now requires the .coverage file to be in the
repository root in order to combine reports and upload to Codecov,
causing CI to fail with "No .coverage file was found in the root
directory" / "No coverage reports found".
Set COVERAGE_FILE = {toxinidir}/.coverage for coverage environments so
the data file lands in the root, as documented at
https://github-actions-workflows.openastronomy.org/en/stable/tox.html#coverage
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #142 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 14 14
Lines 320 320
=========================================
Hits 320 320 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes CI coverage upload failures by ensuring pytest-cov writes the .coverage data file to the repository root even when tox runs tests from a temporary changedir.
Changes:
- Set
COVERAGE_FILE = {toxinidir}/.coveragefor-cov(coverage) tox environments via thecov:factor. - Document why this is needed (tox
changedir+ OpenAstronomy workflow requirement) and link to the relevant workflow docs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nstarman
added a commit
to nstarman/cosmology-api
that referenced
this pull request
Jul 15, 2026
The OpenAstronomy `tox.yml` workflow requires a `.coverage` file in the workspace root for every matrix job that uploads to Codecov. PR cosmology-api#142 pointed `COVERAGE_FILE` at the repo root for coverage-enabled envs, but the `py311-test-alldeps` jobs (linux/windows) had no `cov` factor, so they produced no coverage at all and still failed with: No .coverage file was found in the root directory, this is now a requirement for uploading coverage to Codecov. Add the `-cov` factor to those jobs so every matrix job generates a `.coverage` file. Combined with the `cov: COVERAGE_FILE` setting from cosmology-api#142, the database now lands in the root for all jobs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CI is failing on
-covtest jobs at the Codecov upload step (e.g. run 29299462239). The tests themselves pass, but the job errors with:Root cause
tox.iniruns tests in a temporary directory (changedir = .tmp/{envname}) so the package isn't imported from the source tree. Consequentlypytest-covwrites the.coveragedata file inside that temp directory, not the repository root. The OpenAstronomy tox workflow now requires the.coveragefile to live in the workspace root so it can combine reports and upload them to Codecov, so it finds zero coverage files and fails.I reproduced the mechanism locally: with
pytest --covrun from a subdirectory the.coveragefile lands in that subdirectory; settingCOVERAGE_FILEto the root redirects it back to the root.Fix
Set
COVERAGE_FILE = {toxinidir}/.coveragefor coverage environments (gated on thecov:factor), as documented at https://github-actions-workflows.openastronomy.org/en/stable/tox.html#coverage. This lands the coverage data file in the repo root where the workflow expects it.Verified with
tox config -e py312-test-covthatCOVERAGE_FILEresolves to the repo root, and confirmed it is not set for non-coverage environments.🤖 Generated with Claude Code