Skip to content

Commit bc594cc

Browse files
committed
ci(coverage): Add cargo-tarpaulin code coverage to CI workflow
Add automated code coverage generation and reporting to Codecov using cargo-tarpaulin. This enhances CI/CD pipeline with continuous coverage monitoring on every push and pull request. **Changes:** 1. Added cargo-tarpaulin Installation Step - Linux/macOS only (Windows excluded due to limited test coverage) - Installs latest tarpaulin via 'cargo install' - Conditional execution: matrix.os != 'windows-latest' 2. Added Coverage Generation Step - Command: cargo tarpaulin --workspace --locked --lib --bins --tests - Excludes: prtip-network, prtip-scanner (consistent with test strategy) - Output: Cobertura XML format in ./coverage/ directory - Timeout: 300 seconds (5 minutes) to prevent CI hangs - Environment: PRTIP_DISABLE_HISTORY=1 (prevents test race conditions) 3. Updated Codecov Upload Action - Changed: codecov/test-results-action@v1 → codecov/codecov-action@v4 - Reason: test-results-action expects JUnit XML (test results), codecov-action@v4 expects Cobertura XML (coverage data) - File path: ./coverage/cobertura.xml (explicit for reliability) - fail_ci_if_error: false (don't block CI on coverage upload failures) - verbose: true (detailed logging for troubleshooting) - Conditional: matrix.os != 'windows-latest' && !cancelled() **Technical Details:** - Tarpaulin generates Cobertura XML (coverage %), not JUnit XML (test results) - Previous action (test-results-action) expected wrong format - New action (codecov-action@v4) correctly handles coverage data - Coverage scope matches existing test execution strategy - Linux/macOS only (tarpaulin compatibility) **Impact:** - ✅ Automated coverage reporting on every CI run - ✅ Codecov integration for coverage tracking and visualization - ✅ Maintains all existing CI workflows (7/7 jobs) - ✅ Zero impact on test execution (coverage runs after tests) - ✅ No breaking changes to existing infrastructure **Files Modified:** - .github/workflows/ci.yml: +18 lines (3 new steps, 1 modified) - CHANGELOG.md: +12 lines (Changed section entry) **Verification:** - Workflow syntax: Valid YAML - Conditionals: Properly formatted for GitHub Actions - File paths: Explicit and correct - Codecov action: Latest v4 with correct parameters **Strategic Value:** Establishes continuous coverage monitoring infrastructure for ProRT-IP. Enables data-driven decisions for test coverage improvements and ensures code quality metrics are tracked across all development phases. Supports Phase 6 goals: Comprehensive testing, quality metrics, professional development practices. Aligns with existing coverage reporting from Sprint 5.6 (54.92% baseline, automated CI tracking). Related: Sprint 5.6 Coverage Enhancement (commit ed9c991) See: CHANGELOG.md for complete Sprint 6.3 progress
1 parent e760c45 commit bc594cc

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,28 @@ jobs:
170170
# Release artifacts are built in the dedicated release.yml workflow.
171171
# CI purpose is testing (debug builds sufficient for test validation).
172172

173-
- name: Upload test results to Codecov
174-
if: ${{ !cancelled() }}
175-
uses: codecov/test-results-action@v1
173+
- name: Install cargo-tarpaulin
174+
if: matrix.os != 'windows-latest'
175+
run: cargo install cargo-tarpaulin
176+
177+
- name: Generate test coverage with tarpaulin
178+
if: matrix.os != 'windows-latest'
179+
run: |
180+
cargo tarpaulin --workspace --locked --lib --bins --tests \
181+
--exclude prtip-network --exclude prtip-scanner \
182+
--out Xml --output-dir ./coverage \
183+
--timeout 300
184+
env:
185+
PRTIP_DISABLE_HISTORY: "1"
186+
187+
- name: Upload test coverage to Codecov
188+
if: ${{ !cancelled() && matrix.os != 'windows-latest' }}
189+
uses: codecov/codecov-action@v4
176190
with:
177191
token: ${{ secrets.CODECOV_TOKEN }}
192+
files: ./coverage/cobertura.xml
193+
fail_ci_if_error: false
194+
verbose: true
178195

179196
# Job 4: Security audit
180197
security_audit:

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- **CI/CD: Added Code Coverage with cargo-tarpaulin** (2025-11-15)
13+
- Added cargo-tarpaulin installation step to CI workflow (Linux/macOS only)
14+
- Added coverage generation step using `cargo tarpaulin --workspace --locked --lib --bins --tests`
15+
- Generates Cobertura XML output in `./coverage/` directory
16+
- Changed Codecov upload from `test-results-action@v1` to `codecov-action@v4` (correct action for coverage data)
17+
- Excludes `prtip-network` and `prtip-scanner` crates (consistent with existing test strategy)
18+
- Windows platform excluded (limited test coverage already, tarpaulin Linux/macOS only)
19+
- Coverage timeout: 300 seconds (5 minutes) to prevent CI hangs
20+
- **Impact:** Automated code coverage reporting to Codecov on every CI run
21+
1022
### Fixed
1123

1224
- **Test Infrastructure: macOS batch_coordination.rs Test Failures** (2025-11-15)

0 commit comments

Comments
 (0)