Skip to content

Fix CI: write coverage database to repo root - #143

Merged
nstarman merged 1 commit into
cosmology-api:mainfrom
nstarman:claude/fix-ci-failures-b1b3c8
Jul 15, 2026
Merged

Fix CI: write coverage database to repo root#143
nstarman merged 1 commit into
cosmology-api:mainfrom
nstarman:claude/fix-ci-failures-b1b3c8

Conversation

@nstarman

Copy link
Copy Markdown
Contributor

Problem

CI was failing on all tests matrix jobs of run 29376673214 even though the test suite itself passed (140 passed). The failure was:

No .coverage file was found in the root directory, this is now a requirement for uploading coverage to Codecov.

The OpenAstronomy tox.yml@v1 reusable workflow now requires a .coverage file in the root of the workspace for every matrix job in order to upload coverage to Codecov (see the OpenAstronomy tox docs).

Root cause

Two things prevented the .coverage file from ending up in the repo root:

  1. changedir hides the coverage file. The test environments run in a temporary directory (changedir = .tmp/{envname}), so coverage-enabled envs wrote .coverage there instead of the repo root.
  2. Some jobs produced no coverage at all. The py311-test-alldeps jobs (linux/windows/macos) had no cov factor, so they generated no .coverage file and failed the new check regardless of the changedir issue.

Fix

  1. Set COVERAGE_FILE = {toxinidir}/.coverage in [testenv] so the coverage database is always written to the repo root, as recommended by the OpenAstronomy docs.
  2. Add the -cov factor to the py311-test-alldeps matrix jobs so every matrix job produces a .coverage file.

Verification

  • The failing CI run shows the test suite already passing (140 passed); the only failure was the missing .coverage file.
  • Confirmed locally that setting COVERAGE_FILE to an absolute path makes pytest-cov write .coverage to that path even when pytest runs from a temporary changedir (and nothing is left behind in the changedir).

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 15, 2026 13:29

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 failures in the OpenAstronomy tox.yml@v1 reusable workflow by ensuring every test matrix job produces a .coverage file in the repository root, which is now required for Codecov upload.

Changes:

  • Set COVERAGE_FILE = {toxinidir}/.coverage in tox.ini so coverage data is written to the repo root even when changedir is used.
  • Update the CI test matrix to run the py311-test-alldeps jobs with the -cov factor across linux/windows/macos so those jobs generate coverage output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tox.ini Forces coverage data file location to the repo root to satisfy CI coverage upload requirements despite changedir.
.github/workflows/ci_tests.yml Adjusts the tox env names so the previously non-coverage py311-test-alldeps jobs run with -cov and generate .coverage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nstarman
nstarman force-pushed the claude/fix-ci-failures-b1b3c8 branch from fd7bc4b to ea12a2e Compare July 15, 2026 14:30
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6e800fa) to head (24b1300).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #143   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines          320       314    -6     
=========================================
- Hits           320       314    -6     

☔ 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.

CI was failing on the `tests` jobs even though the suite passes. Two
independent problems both broke the OpenAstronomy `tox.yml` coverage upload,
which requires a `.coverage` file in the repo root for every matrix job:

1. The `py311-test-alldeps` jobs (linux/windows) had no `cov` factor, so they
   produced no coverage data at all and failed the root `.coverage` check.
   Add the `-cov` factor so every matrix job generates coverage.

2. The workflow runs `coverage combine`/`coverage xml` in the repo root via
   `uvx coverage`, which installs a bare `coverage` without the `[toml]`
   extra. On Python < 3.11 (no stdlib `tomllib`) that build cannot read the
   `[tool.coverage.*]` config in `pyproject.toml`, failing the py39/py310 jobs
   with:

       Can't read 'pyproject.toml' without TOML support. Install with [toml] extra

   Move the coverage configuration to a dedicated `.coveragerc` (INI), which
   any coverage install can read without TOML support, and point tox's
   `--cov-config` at it. coverage discovers `.coveragerc` first and never
   attempts to parse `pyproject.toml`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nstarman
nstarman force-pushed the claude/fix-ci-failures-b1b3c8 branch from ea12a2e to 24b1300 Compare July 15, 2026 15:36
@nstarman
nstarman merged commit ed9fcdc into cosmology-api:main Jul 15, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants