-
-
Notifications
You must be signed in to change notification settings - Fork 607
Remove Codecov in favor of native coverage.py #4159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replace Codecov with GitHub Actions artifacts and coverage.py's native reporting capabilities. This eliminates the external service dependency while maintaining coverage tracking across multiple test runs. Changes: - Remove .codecov.yml configuration file - Update .coveragerc to include previously Codecov-ignored files in omit - Replace upload-coverage job with new coverage combine job that: - Downloads coverage data from all test runs - Combines coverage using coverage.py - Generates HTML report and markdown summary in GitHub Actions - Uploads HTML report as artifact for detailed analysis - Update unit-tests and Windows tests to upload .coverage files - Remove --cov-report=xml from noxfile.py (no longer needed) - Clean up unused pipx coverage installs Reference: https://hynek.me/articles/ditch-codecov-python/
Reviewer's GuideReplaces external Codecov integration with a native coverage.py workflow in GitHub Actions by aggregating raw .coverage artifacts from all test jobs, generating Markdown and HTML reports in CI, and cleaning up now-unneeded configuration and options. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- The new artifact upload/download flow only uploads a single
.coveragefile per job and usesmerge-multiple: true, so identically named.coveragefiles from different jobs will overwrite each other; consider either enabling coverage parallel mode (so you get distinct.coverage.*files) and uploading them all, or varying theCOVERAGE_FILE/artifact paths per job socoverage combinecan truly merge data from all test runs. - Since the
coveragejob is markedif: always()and depends on both Linux and Windows test jobs, you may want to guard the combine step with a check that coverage artifacts were actually downloaded (or adjust theifcondition) to avoid confusing failures when an upstream job is cancelled or skipped.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new artifact upload/download flow only uploads a single `.coverage` file per job and uses `merge-multiple: true`, so identically named `.coverage` files from different jobs will overwrite each other; consider either enabling coverage parallel mode (so you get distinct `.coverage.*` files) and uploading them all, or varying the `COVERAGE_FILE`/artifact paths per job so `coverage combine` can truly merge data from all test runs.
- Since the `coverage` job is marked `if: always()` and depends on both Linux and Windows test jobs, you may want to guard the combine step with a check that coverage artifacts were actually downloaded (or adjust the `if` condition) to avoid confusing failures when an upstream job is cancelled or skipped.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Greptile SummaryThis PR successfully migrates from Codecov to native coverage.py by removing the external service dependency and implementing coverage combining directly in GitHub Actions. Key Changes:
Issue Found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant GH as GitHub Actions
participant UT as unit-tests (Linux)
participant WT as unit-tests-on-windows
participant COV as coverage job
participant ART as Artifacts
Note over GH,ART: Old Flow (Codecov)
UT->>UT: Run tests with --cov-report=xml
UT->>ART: Upload coverage.xml
WT->>WT: Run tests with --cov-report=xml
WT->>WT: Generate coverage.xml
WT->>Codecov: Upload to Codecov service
UT->>Codecov: Upload to Codecov service
Note over GH,ART: New Flow (Native coverage.py)
UT->>UT: Run tests (no XML generation)
UT->>ART: Upload .coverage file (hidden)
WT->>WT: Run tests (no XML generation)
WT->>ART: Upload .coverage file (hidden)
COV->>ART: Download all coverage-data-* artifacts
COV->>COV: coverage combine (merge all .coverage files)
COV->>COV: coverage html (generate HTML report)
COV->>COV: coverage report --format=markdown
COV->>GH: Append to GITHUB_STEP_SUMMARY
COV->>ART: Upload html-report artifact
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 1 comment
| run: | | ||
| python -Im pip install --upgrade coverage[toml] | ||
| python -Im coverage combine | ||
| python -Im coverage html --skip-covered --skip-empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: HTML directory mismatch - .coveragerc specifies coverage_html_report but this uses htmlcov (coverage.py default)
| python -Im coverage html --skip-covered --skip-empty | |
| python -Im coverage html --skip-covered --skip-empty |
Then update line 105 to match:
path: coverage_html_report
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/test.yml
Line: 98:98
Comment:
**logic:** HTML directory mismatch - `.coveragerc` specifies `coverage_html_report` but this uses `htmlcov` (coverage.py default)
```suggestion
python -Im coverage html --skip-covered --skip-empty
```
Then update line 105 to match:
```
path: coverage_html_report
```
How can I resolve this? If you propose a fix, please make it concise.- Rename .coverage files to unique names before upload to prevent overwrites when artifacts are merged (e.g., .coverage.session-name) - Fix HTML report path to match .coveragerc (coverage_html_report)
- checkout: v6 (wrong) -> v4.3.1 with correct SHA - setup-python: v5 -> v5.6.0 with correct SHA - upload-artifact: v4 -> v4.6.2 with correct SHA - download-artifact: v4 -> v4.3.0 with correct SHA
Prevents GitHub token from being persisted in git config, which could be exposed if artifacts accidentally include the .git directory.
The .coverage file may not exist if tests fail early or coverage is disabled. Check for file existence before attempting to rename.
Session names like 'Tests-3.11(gql_core='3.3.0a9')' contain parentheses and quotes that cause shell syntax errors. Quote the filenames to treat them as literal strings.
Addresses 'overly broad permissions' security warning by explicitly setting only the required 'contents: read' permission.
|
|
||
| > Python GraphQL library based on dataclasses | ||
|
|
||
| [](https://circleci.com/gh/strawberry-graphql/strawberry/tree/main) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍓🍓🍓
- Install diff-cover alongside coverage - Generate XML coverage report for diff-cover - Add diff coverage report to GitHub step summary for PRs - Fetch full git history to enable diff comparison against base branch
Use environment variable instead of direct template expansion for github.base_ref to prevent potential code injection attacks.
Summary
This PR removes the Codecov dependency and replaces it with native coverage.py reporting using GitHub Actions artifacts, following the approach outlined in Ditch Codecov for Python Projects.
Changes:
.codecov.ymlconfiguration file.coveragercto include previously Codecov-ignored files in the omit sectionupload-coveragejob with a newcoveragejob that:coverage combineunit-testsand Windows tests to upload.coveragefiles instead ofcoverage.xml--cov-report=xmlfromnoxfile.py(no longer needed since we combine raw coverage data)pipx install coveragecommandsBenefits:
Test plan
Summary by Sourcery
Replace external Codecov integration with native coverage.py reporting aggregated in CI and surfaced via GitHub Actions artifacts and summaries.
Build:
CI:
Tests: