From 3f2ca99fe16668e3d50b8e1706182ec7b226c352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl?= Date: Mon, 3 Aug 2026 23:20:17 +0200 Subject: [PATCH] fix(ci): restrict Codecov shard uploads (#2745) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Closes #2744 Restrict each Codecov Action v5 matrix upload to its declared `coverage-${{ matrix.shard }}.xml` report. This prevents automatic discovery from uploading the unsharded `coverage.xml` alongside every shard. ## Type of Change - [x] Bug fix (non-breaking change fixes an issue) ## Changes Made - Set Codecov Action `disable_search: true` for Python shard uploads. - Add a CI workflow contract test that protects the explicit-report-only setup. ## Testing - [x] Unit tests pass (`pytest`) - [x] Linting passes (`ruff check`) - [x] Type checking passes (`mypy headroom`) (not applicable: workflow/test-only change) - [x] New tests added new functionality - [x] Manual testing performed (not applicable: GitHub Actions will execute the workflow) ### Test Output ```text $ uv run --with ruff ruff format --check scripts/tests/test_ci_workflow.py 1 file already formatted $ uv run --with ruff ruff check scripts/tests/test_ci_workflow.py All checks passed! $ uv run --with pytest pytest scripts/tests/test_ci_workflow.py -q 2 passed ``` ## Real Behavior Proof - Environment: GitHub Actions Ubuntu runner using Python 3.12.13; Codecov Action v5. - Exact command / steps: Run the CI Python test matrix, which writes `coverage-${{ matrix.shard }}.xml`, then runs the Codecov Action upload step. Inspect the uploader's discovered/uploaded report list. - Observed result: Before this change, raw CI logs showed the Action explicitly uploading `coverage-2.xml` and additionally discovering/uploading `coverage.xml`. This PR configures `disable_search: true`; the workflow contract test confirms the explicit report setting and search disablement. Runtime upload evidence will be added from this draft PR's CI run. - Not tested: Codecov's final cross-shard patch calculation; that depends on Codecov processing the reports after CI completes. ## Review Readiness - [x] I have performed a self-review - [x] This PR ready for human review ## Checklist - [x] My code follows project's style guidelines - [x] I have performed a self-review - [x] I commented my code, particularly in hard-to-understand areas - [x] I made corresponding changes documentation (not applicable) - [x] My changes generate no new warnings - [x] I added tests prove my fix is effective or feature works - [x] New and existing unit tests pass locally changes - [x] I did **not** edit `CHANGELOG.md` — generated by release-please from Conventional Commit PR title (a CI guard enforces this) ## Additional Notes This is intentionally limited to the Codecov upload configuration and its workflow contract test. It does not include the unrelated Copilot Keychain fix. --- .github/workflows/ci.yml | 1 + scripts/tests/test_ci_workflow.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83cf8f78f..49acfaf42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -293,6 +293,7 @@ jobs: uses: codecov/codecov-action@v5 with: files: coverage-${{ matrix.shard }}.xml + disable_search: true flags: python name: python-shard-${{ matrix.shard }} # Token is sent so uploads authenticate once the repo is activated on diff --git a/scripts/tests/test_ci_workflow.py b/scripts/tests/test_ci_workflow.py index 20c873d46..c38c399b9 100644 --- a/scripts/tests/test_ci_workflow.py +++ b/scripts/tests/test_ci_workflow.py @@ -7,10 +7,17 @@ from pathlib import Path def test_sharded_ci_verifies_offline_huggingface_cache_before_pytest() -> None: workflow = Path(".github/workflows/ci.yml").read_text(encoding="utf-8") - verify_step = "Verify offline HuggingFace model cache" pytest_step = "Run test shard ${{ matrix.shard }}/4" assert verify_step in workflow assert "python scripts/ci/verify_hf_model_cache.py" in workflow assert workflow.index(verify_step) < workflow.index(pytest_step) + + +def test_sharded_ci_uploads_only_explicit_coverage_reports() -> None: + workflow = Path(".github/workflows/ci.yml").read_text(encoding="utf-8") + upload_step = workflow[workflow.index("Upload coverage shard") :] + + assert "files: coverage-${{ matrix.shard }}.xml" in upload_step + assert "disable_search: true" in upload_step