Update test suite to ensure 100% code coverage#44
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds automated 100% code coverage validation to the test suite. It builds on top of the test environment improvements from PR #42, adding both CI enforcement and documentation for the code coverage requirement.
Changes:
- Added automated coverage validation in CI workflow to fail builds if code coverage is below 100%
- Added code coverage badge to README
- Documented the code coverage requirement and how to generate coverage reports locally
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| README.md | Added code coverage badge and documentation explaining the 100% coverage requirement with instructions for generating local coverage reports |
| .github/workflows/ci.yml | Added clover.xml coverage report generation and PHP script to validate 100% code coverage after test runs |
Comments suppressed due to low confidence (2)
.github/workflows/ci.yml:42
- The XML parsing lacks error handling. If the clover.xml file doesn't exist, is malformed, or doesn't have the expected structure, the script will fail with a PHP error instead of a clear message. Consider adding error handling to check if the file exists and if the expected XML structure is present before accessing the metrics attributes.
$metrics = simplexml_load_file('clover.xml')->project->metrics;
exit((int) $metrics['statements'] === (int) $metrics['coveredstatements'] ? 0 : 1);
.github/workflows/ci.yml:42
- The coverage check script doesn't provide any diagnostic output when coverage is below 100%. Consider adding an error message that shows the actual coverage percentage to help developers understand what needs to be fixed. For example, output the number of covered vs total statements before exiting.
- name: Check 100% code coverage
shell: php {0}
run: |
<?php
$metrics = simplexml_load_file('clover.xml')->project->metrics;
exit((int) $metrics['statements'] === (int) $metrics['coveredstatements'] ? 0 : 1);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on top of #42 and clue/reactphp-eventsource#35