Visitar URL original
build: enable codecov for tests coverage by chemelli74 · Pull Request #587 · midea-lan/midea-local · GitHub
Skip to content

build: enable codecov for tests coverage - #587

Merged
chemelli74 merged 24 commits into
midea-lan:mainfrom
chemelli74:chemelli74-codecov
Aug 3, 2026
Merged

chemelli74 merged 24 commits into
midea-lan:mainfrom
chemelli74:chemelli74-codecov

Conversation

@chemelli74

@chemelli74 chemelli74 commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Tests

    • Improved branch coverage measurement and reporting accuracy.
    • Coverage reports now focus on application code and exclude non-executable or entry-point lines.
    • Added automated coverage comparisons with a defined regression threshold.
  • Chores

    • Coverage reports are now preserved and uploaded for review.
    • Coverage upload failures now clearly fail the build and provide verbose diagnostics.
    • Updated coverage reporting configuration for more consistent comparison and review feedback.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The pull request adds branch coverage settings and updates Codecov enforcement, comparison, and comment reporting. The CI workflow uploads coverage from Ubuntu with Python 3.14 through a dependent Codecov job using action v4.

Changes

Coverage Reporting

Layer / File(s) Summary
Coverage measurement configuration
.coveragerc
Coverage measurement includes branches, targets midealocal, omits library_test.py, and excludes common non-executable lines.
Codecov enforcement and CI upload
.github/workflows/python-build.yml, codecov.yml
The workflow uploads coverage from Ubuntu with Python 3.14. Codecov uses action v4, grants required permissions, fails on upload errors, enables verbose logs, applies a 1% project threshold, compares with the latest base commit, and enables comment reporting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: rokam, wuwentao

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: enabling Codecov coverage reporting for tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/python-build.yml:
- Line 13: Remove the workflow-level id-token: write permission and preserve it
only on the existing deploy job plus a new isolated Codecov upload job. Refactor
the build job to upload coverage as an artifact, then have the Codecov job
download that artifact and perform the upload, ensuring build, prek, package
code, and tests run without OIDC access.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 40039e76-1f84-42a2-be8b-595ed34600db

📥 Commits

Reviewing files that changed from the base of the PR and between f8128f0 and a4cd249.

📒 Files selected for processing (3)
  • .coveragerc
  • .github/workflows/python-build.yml
  • codecov.yml

Comment thread .github/workflows/python-build.yml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/python-build.yml:
- Around line 102-103: Add an actions/checkout step before the “Download
coverage artifacts” step in the coverage upload job, ensuring the repository is
checked out before codecov/codecov-action@v7 runs. Preserve the existing
artifact download and upload configuration.
- Around line 83-90: Update the coverage artifact handling in the matrix
workflow so each OS/Python coverage.xml and reports/coverage remains in a
distinct directory instead of being merged with last-writer-wins collisions.
Adjust the Codecov upload configuration to discover and submit the complete set
of matrix XML reports, while preserving all HTML coverage files.
- Around line 8-9: Update the workflow trigger and Codecov flow so tests
continue running on pull_request while authenticated coverage upload uses a
separate trusted workflow or safe artifact handoff; do not execute or check out
pull-request head code from pull_request_target. In the codecov job, add
actions/checkout before codecov/codecov-action@v7 and ensure the upload consumes
artifacts from the pull_request build rather than a base-revision build.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 25a15e4c-927a-4dda-86bd-e5ffdfefbe27

📥 Commits

Reviewing files that changed from the base of the PR and between a4cd249 and 9a83ff9.

📒 Files selected for processing (1)
  • .github/workflows/python-build.yml

Comment thread .github/workflows/python-build.yml Resolved
Comment thread .github/workflows/python-build.yml Resolved
Comment thread .github/workflows/python-build.yml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/python-build.yml:
- Around line 36-38: Remove id-token: write from the shared permissions used by
the test matrix in python-build.yml, including prek, python -m build, and
pytest. Move Codecov upload into a separate job with only that job granted
id-token: write, or switch the upload to CODECOV_TOKEN and remove the OIDC
permission entirely; preserve contents: read where required.
- Around line 85-89: Update the Codecov upload step guarded by the Ubuntu Python
3.14 matrix condition to configure authentication explicitly, using either
use_oidc: true or the existing secrets.CODECOV_TOKEN via token. Preserve
fail_ci_if_error: true and the current upload conditions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 76251aa5-73a4-4665-8104-3814085ef13c

📥 Commits

Reviewing files that changed from the base of the PR and between 989ed87 and 6b0bb45.

📒 Files selected for processing (1)
  • .github/workflows/python-build.yml

Comment thread .github/workflows/python-build.yml Resolved
Comment thread .github/workflows/python-build.yml Resolved
Comment thread .github/workflows/python-build.yml Resolved
Comment thread .github/workflows/python-build.yml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
.github/workflows/python-build.yml (1)

101-105: ⚠️ Potential issue | 🟠 Major

The previous Codecov authentication finding remains unresolved.

codecov/codecov-action@v4 receives neither use_oidc: true nor token: ${{ secrets.CODECOV_TOKEN }}. Codecov v4 does not support tokenless uploads except upstream public fork pull requests. Same-repository pull requests and release runs can therefore fail, and fail_ci_if_error: true fails the job. (raw.githubusercontent.com)

Add use_oidc: true when the Codecov project is configured for OIDC, or restore the repository token. Preserve tokenless behavior for fork pull requests if required.

Proposed OIDC fix
         with:
+          use_oidc: true
           fail_ci_if_error: true
           verbose: true
#!/bin/bash
set -euo pipefail

workflow=.github/workflows/python-build.yml

if ! sed -n '88,105p' "$workflow" | rg -q 'use_oidc:\s*true|secrets\.CODECOV_TOKEN'; then
  echo "Codecov authentication is not configured" >&2
  exit 1
fi

curl -fsSL https://raw.githubusercontent.com/codecov/codecov-action/v4/README.md |
  rg -n 'Tokenless uploading is unsupported|use_oidc|CODECOV_TOKEN'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/python-build.yml around lines 101 - 105, Update the
“Upload coverage reports to Codecov” step using codecov/codecov-action@v4 to
configure authentication by adding use_oidc: true when the project supports
OIDC, or by supplying secrets.CODECOV_TOKEN. Preserve any required tokenless
behavior for upstream public fork pull requests while ensuring same-repository
pull requests and release runs authenticate successfully.
🧹 Nitpick comments (1)
.github/workflows/python-build.yml (1)

96-96: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Disable unnecessary checkout credential persistence.

actions/checkout@v7 persists a GitHub credential by default. This job does not perform authenticated Git operations after checkout. Set persist-credentials: false to remove the local credential and address the zizmor artipacked warning. (docs.zizmor.sh)

Proposed hardening
-      - uses: actions/checkout@v7
+      - uses: actions/checkout@v7
+        with:
+          persist-credentials: false
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/python-build.yml at line 96, Update the
actions/checkout@v7 step in the workflow to set persist-credentials to false,
while leaving the existing checkout behavior unchanged.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In @.github/workflows/python-build.yml:
- Around line 101-105: Update the “Upload coverage reports to Codecov” step
using codecov/codecov-action@v4 to configure authentication by adding use_oidc:
true when the project supports OIDC, or by supplying secrets.CODECOV_TOKEN.
Preserve any required tokenless behavior for upstream public fork pull requests
while ensuring same-repository pull requests and release runs authenticate
successfully.

---

Nitpick comments:
In @.github/workflows/python-build.yml:
- Line 96: Update the actions/checkout@v7 step in the workflow to set
persist-credentials to false, while leaving the existing checkout behavior
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d078afcf-8c79-468b-92a8-6391d2fc3fed

📥 Commits

Reviewing files that changed from the base of the PR and between 6b0bb45 and 4d215f4.

📒 Files selected for processing (1)
  • .github/workflows/python-build.yml

The workflow_run listener always runs whatever copy of this file is on
main, so edits to it only take effect once merged there - keeping them
in this PR was dead weight. The real fix moved to a standalone PR.
Adapted from home-assistant/core's codecov.yml: pins codecov.branch to
main (avoids ambiguity about which branch is "default" for protected-
branch token checks) and turns patch status from off to target: auto,
matching the project status check already in place.
@chemelli74
chemelli74 merged commit 759a2b2 into midea-lan:main Aug 3, 2026
17 checks passed
@chemelli74
chemelli74 deleted the chemelli74-codecov branch August 3, 2026 11:30
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