Codecov Integration Setup Guide
This guide explains how to set up and configure Codecov for LaxyFile's code coverage reporting.
Overview
Codecov is integrated into LaxyFile's CI/CD pipeline to provide:
- Automated coverage reporting for all pull requests and commits
- Coverage trends and historical data
- Component-based coverage tracking for different parts of the codebase
- Coverage status checks to maintain code quality
Setup Steps
1. Codecov Account Setup
- Sign up for Codecov: Go to codecov.io and sign up with your GitHub account
- Add Repository: Add the
swadhinbiswas/laxyfilerepository to your Codecov dashboard - Get Upload Token: Copy the repository upload token from Codecov dashboard
2. GitHub Secrets Configuration
Add the following secrets to your GitHub repository:
- Go to Settings → Secrets and variables → Actions
- Add new repository secret:
- Name:
CODECOV_TOKEN - Value: Your Codecov upload token from step 1.3
- Name:
3. Configuration Files
The following files are already configured in the repository:
codecov.yml - Main Configuration
coverage:
precision: 2
round: down
range: "70...100"
status:
project:
default:
target: 80% # Overall project coverage target
threshold: 1% # Allow 1% decrease
patch:
default:
target: 75% # New code coverage target
threshold: 2% # Allow 2% decrease for patches
Component Coverage Targets
- Core Components: 85% coverage target
- File Operations: 85% coverage target
- Utilities: 85% coverage target
- AI Components: 80% coverage target
- Plugin System: 80% coverage target
- UI Components: 75% coverage target
- Preview System: 75% coverage target
4. GitHub Actions Integration
Coverage is automatically collected and uploaded in two workflows:
Test Workflow (.github/workflows/test.yml)
- Runs on every push and pull request
- Tests across multiple OS and Python versions
- Uploads coverage with detailed flags
Release Workflow (.github/workflows/release.yml)
- Runs on tagged releases
- Ensures coverage before deployment
- Uploads release-specific coverage data
Coverage Reports
Viewing Coverage
- Codecov Dashboard: Visit your repository on codecov.io
- GitHub PR Comments: Codecov automatically comments on pull requests
- GitHub Status Checks: Coverage status appears in PR checks
- Local HTML Reports: Generated in
htmlcov/directory after running tests
Coverage Flags
The integration uses several flags to organize coverage data:
unittests: Unit test coverageintegration: Integration test coverageperformance: Performance test coveragerelease: Release build coverage- OS flags:
ubuntu-latest,macos-latest,windows-latest - Python version flags:
python3.8,python3.9, etc.
Understanding Coverage Reports
Project Coverage
- Overall percentage of code covered by tests
- Trend analysis showing coverage changes over time
- File-by-file breakdown of coverage percentages
Patch Coverage
- New code coverage for pull requests
- Line-by-line analysis of what's covered
- Suggestions for improving coverage
Component Coverage
- Module-specific targets for different parts of the codebase
- Individual status checks for each component
- Focused improvement recommendations
Best Practices
Writing Tests for Coverage
- Aim for 80%+ overall coverage
- Focus on critical paths first
- Test edge cases and error conditions
- Mock external dependencies appropriately
Improving Coverage
- Identify uncovered lines using coverage reports
- Add tests for missing scenarios
- Remove dead code that can't be covered
- Use
# pragma: no coverfor intentionally uncovered code
Coverage Exclusions
The following are excluded from coverage:
- Test files (
tests/) - Documentation (
docs/) - Build scripts (
scripts/) - Package metadata (
setup.py,__main__.py) - Generated files (
build/,dist/)
Troubleshooting
Common Issues
Coverage Not Uploading
- Check that
CODECOV_TOKENis set correctly - Verify the coverage.xml file is generated
- Check GitHub Actions logs for upload errors
Low Coverage Warnings
- Review uncovered lines in Codecov dashboard
- Add tests for critical uncovered code
- Consider adjusting coverage targets if appropriate
Status Check Failures
- Check if coverage dropped below thresholds
- Review the specific component that failed
- Add tests to bring coverage back up
Getting Help
- Codecov Documentation: docs.codecov.com
- GitHub Issues: Report integration issues
- Coverage Reports: Use detailed reports to identify gaps
Monitoring and Maintenance
Regular Tasks
- Review coverage trends monthly
- Update coverage targets as codebase matures
- Clean up excluded files list periodically
- Monitor component coverage for balance
Coverage Goals
- Short-term: Maintain 80%+ overall coverage
- Medium-term: Achieve 85%+ for core components
- Long-term: Establish 90%+ coverage for critical paths
Integration Benefits
With Codecov properly configured, you get:
✅ Automated coverage reporting on every commit
✅ Pull request coverage analysis with detailed feedback
✅ Historical coverage tracking and trend analysis
✅ Component-based coverage goals for focused improvement
✅ Integration with GitHub status checks for quality gates
✅ Visual coverage reports with line-by-line analysis
This ensures LaxyFile maintains high code quality and comprehensive test coverage across all components and platforms.