Skip to content

Write coverage data to repo root for Codecov upload - #142

Merged
nstarman merged 1 commit into
cosmology-api:mainfrom
nstarman:claude/fix-ci-failures-639fe1
Jul 14, 2026
Merged

Write coverage data to repo root for Codecov upload#142
nstarman merged 1 commit into
cosmology-api:mainfrom
nstarman:claude/fix-ci-failures-639fe1

Conversation

@nstarman

Copy link
Copy Markdown
Contributor

Problem

CI is failing on -cov test jobs at the Codecov upload step (e.g. run 29299462239). The tests themselves pass, but the job errors with:

No .coverage file was found in the root directory, this is now a requirement for uploading coverage to Codecov.
No coverage reports found. Please make sure you're generating reports successfully.

Root cause

tox.ini runs tests in a temporary directory (changedir = .tmp/{envname}) so the package isn't imported from the source tree. Consequently pytest-cov writes the .coverage data file inside that temp directory, not the repository root. The OpenAstronomy tox workflow now requires the .coverage file 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 --cov run from a subdirectory the .coverage file lands in that subdirectory; setting COVERAGE_FILE to the root redirects it back to the root.

Fix

Set COVERAGE_FILE = {toxinidir}/.coverage for coverage environments (gated on the cov: 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-cov that COVERAGE_FILE resolves to the repo root, and confirmed it is not set for non-coverage environments.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings July 14, 2026 23:05
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0647cc1) to head (e074006).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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}/.coverage for -cov (coverage) tox environments via the cov: 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
nstarman merged commit 6f6a1c4 into cosmology-api:main Jul 14, 2026
15 checks passed
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>
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