Skip to content

Add comprehensive test coverage reporting infrastructure #33

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

jbrinkman
Copy link
Collaborator

Summary

Implements comprehensive test coverage reporting infrastructure for the C# Valkey GLIDE client project as requested in issue #27. This PR adds automated coverage collection, report generation, and CI/CD integration.

Changes Made

🔧 Task-based Build System (Taskfile.yml)

  • New Taskfile.yml: Comprehensive task definitions for coverage workflows
  • Coverage tasks: coverage, coverage:unit, coverage:integration
  • Granular control: Separate tasks for unit tests, integration tests, and combined coverage
  • Report generation: Automated HTML report generation using ReportGenerator
  • Coverage merging: Smart merging of multiple coverage files from different test projects
  • Summary display: JSON-based coverage summary extraction and display

🚀 GitHub Actions Workflow (.github/workflows/test-coverage.yml)

  • Automated PR coverage: Runs coverage analysis on all pull requests
  • Multi-framework support: Tests both .NET 6.0 and 8.0 targets
  • Coverage comments: Automatically posts coverage summary as PR comments
  • Visual indicators: Color-coded coverage status (🟢 Good, 🟡 Moderate, 🔴 Low)
  • Artifact uploads: Coverage reports and test results uploaded as downloadable artifacts
  • Coverage thresholds: Built-in quality gates (80%+ line, 70%+ branch = good)

📝 Git Configuration (.gitignore)

  • Reports exclusion: Added [Rr]eports/ to exclude generated coverage reports
  • Clean repository: Prevents coverage artifacts from being committed

🎯 Features

Coverage Collection

# Run all tests with coverage
task coverage

# Unit tests only  
task coverage:unit

# Integration tests only
task coverage:integration

Report Generation

  • HTML reports: Rich, interactive coverage reports with drill-down capability
  • JSON summaries: Machine-readable coverage metrics for automation
  • Multi-format support: Cobertura XML format for external tool integration

CI/CD Integration

  • Automatic execution: Coverage runs on every PR
  • Smart commenting: Updates existing coverage comments rather than creating duplicates
  • Quality gates: Visual feedback on coverage quality with emoji indicators
  • Artifact storage: 30-day retention of coverage reports and test results

🔍 Technical Implementation

Coverage Pipeline

  1. Clean environment: Removes old results and creates fresh directories
  2. Tool installation: Automatically installs ReportGenerator if not present
  3. Test execution: Runs tests with Coverlet coverage collection
  4. File merging: Intelligently merges multiple coverage files from different frameworks
  5. Report generation: Creates comprehensive HTML reports and JSON summaries
  6. Summary display: Extracts and displays key coverage metrics

Quality Features

  • Assembly filtering: Focuses on Valkey.Glide* assemblies only
  • Test exclusion: Excludes test projects from coverage metrics
  • Framework support: Works with both net6.0 and net8.0 simultaneously
  • Cross-platform: Runs on Ubuntu (CI) and supports local development on any OS

📊 Acceptance Criteria ✅

  • Coverage data collection: ✅ For both unit and integration tests
  • HTML report generation: ✅ Rich interactive reports with drill-down
  • Line and branch coverage: ✅ Both metrics tracked and displayed
  • Multi-framework support: ✅ net6.0 and net8.0 both supported
  • Performance: ✅ Minimal impact on test execution time
  • CI/CD integration: ✅ Automated GitHub Actions workflow

🎉 Usage Examples

Local Development

# Quick coverage check
task coverage:unit

# Full coverage report  
task coverage
open reports/index.html  # View detailed HTML report

CI/CD

  • Coverage automatically runs on PRs
  • Results posted as PR comments
  • Reports available as downloadable artifacts

Advanced Usage

# Clean and rebuild
task clean build

# Just run tests (no coverage)
task test:unit

# Coverage summary only
task coverage:summary

🔗 Integration Ready

The coverage data is output in standard formats, making it ready for integration with:

  • SonarQube: Cobertura XML format support
  • Codecov.io: Direct XML file upload
  • Azure DevOps: Native coverage report integration
  • Other tools: JSON summaries for custom integrations

Fixes #27

@jbrinkman jbrinkman requested a review from a team as a code owner August 18, 2025 16:13
@jbrinkman jbrinkman force-pushed the jbrinkman/code-coverage-report branch from 02b0910 to e6ba8b4 Compare August 18, 2025 16:15
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please update dev guide

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wanted to have a discussion about taskfile usage as we have a lot of details in the developer guide that probably could move into the taskfile. Didn't want to do that until we discussed.

…rk parameter support- Remove separate test-coverage.yml workflow- Add conditional coverage steps to tests.yml workflow using coverage-check output- Add framework parameter support to Taskfile.yml- Coverage now runs only on Ubuntu x64 with .NET 8.0.x to optimize CI resources- Add .NET 9.0.x support to test workflows for C# language feature compatibility

Signed-off-by: jbrinkman <[email protected]>

vars:
TEST_RESULTS_DIR: testresults
REPORTS_DIR: reports
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider updating CI - it stores the report in the project root

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what you want here. All reports are getting uploaded as artifacts correctly. I don't see anything to fix here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

See CI job lines 97-99

Taskfile.yml Outdated
Comment on lines 156 to 157
./install_and_test.sh -no-tls -minimal -only-glide -data 1 -tasks 10 -csharp -dotnet-framework net8.0
./install_and_test.sh -no-tls -minimal -only-glide -data 1 -tasks 10 -csharp -dotnet-framework net6.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
./install_and_test.sh -no-tls -minimal -only-glide -data 1 -tasks 10 -csharp -dotnet-framework net8.0
./install_and_test.sh -no-tls -minimal -only-glide -data 1 -tasks 10 -csharp -dotnet-framework net6.0
./install_and_test.sh -no-tls -minimal -only-glide -data 1 -tasks 10 -csharp

Probably this works too

@@ -109,6 +107,10 @@ jobs:
redis-server --save "" --daemonize "yes"
./install_and_test.sh -no-tls -minimal -only-glide -data 1 -tasks 10 -csharp -dotnet-framework net${{ matrix.dotnet }}

- name: Run coverage
Copy link
Collaborator

Choose a reason for hiding this comment

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

This runs all tests second time. I propose to add a condition (like else) for test step (lines 97-99)


vars:
TEST_RESULTS_DIR: testresults
REPORTS_DIR: reports
Copy link
Collaborator

Choose a reason for hiding this comment

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

See CI job lines 97-99

echo "Line Coverage: ${LINE_COVERAGE}%"
echo "Branch Coverage: ${BRANCH_COVERAGE}%"
else
echo "No coverage summary found. Run 'task coverage:report' first."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
echo "No coverage summary found. Run 'task coverage:report' first."
echo "No coverage summary found. Run 'task coverage:report' first."
exit 1

jbrinkman and others added 2 commits August 20, 2025 15:32
Co-authored-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Joseph Brinkman <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Joseph Brinkman <[email protected]>
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.

Add test coverage reporting support
2 participants