Skip to content

Commit 3032edf

Browse files
aristathclaude
andcommitted
Fix coverage parsing to properly capture class names
PHPUnit outputs class names and coverage stats on separate lines: - Line 1: "Progress_Planner\Activity" - Line 2: " Methods: 55.56% ( 5/ 9) Lines: 91.92% ( 91/ 99)" The previous grep approach was only capturing the stats line without the class name, resulting in empty coverage comparisons. The fix uses awk to: 1. Capture lines starting with class names (^[A-Za-z_]) 2. Look for the following stats line 3. Combine them into a single line for parsing 4. Strip ANSI color codes from both parts This enables the Python comparison script to properly parse class names and show file-level coverage changes in the collapsible details section. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0a7c79f commit 3032edf

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

.github/workflows/code-coverage.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,16 @@ jobs:
127127
echo "Current code coverage: $COVERAGE%"
128128
129129
# Save detailed per-file coverage for later comparison
130-
# Extract lines that show per-file coverage (format: "ClassName Methods: X% Lines: Y%")
131-
grep -E "^\s+[A-Za-z_\\]+" current-coverage-full.txt | \
132-
grep -E "Methods:.*Lines:" | \
133-
sed 's/\x1b\[[0-9;]*m//g' > current-coverage-details.txt || true
130+
# PHPUnit outputs class name on one line, stats on the next line
131+
# We need to combine them: "ClassName" + " Methods: X% Lines: Y%"
132+
awk '
133+
/^[A-Za-z_]/ { classname = $0; next }
134+
/^ Methods:.*Lines:/ {
135+
gsub(/\x1b\[[0-9;]*m/, "", classname);
136+
gsub(/\x1b\[[0-9;]*m/, "", $0);
137+
print classname " " $0
138+
}
139+
' current-coverage-full.txt > current-coverage-details.txt || true
134140
135141
echo "=== Current coverage details saved ==="
136142
head -20 current-coverage-details.txt || true
@@ -164,9 +170,15 @@ jobs:
164170
echo "Base branch code coverage: $BASE_COVERAGE%"
165171
166172
# Extract per-file coverage for comparison
167-
grep -E "^\s+[A-Za-z_\\]+" base-coverage-full.txt | \
168-
grep -E "Methods:.*Lines:" | \
169-
sed 's/\x1b\[[0-9;]*m//g' > base-coverage-details.txt || true
173+
# PHPUnit outputs class name on one line, stats on the next line
174+
awk '
175+
/^[A-Za-z_]/ { classname = $0; next }
176+
/^ Methods:.*Lines:/ {
177+
gsub(/\x1b\[[0-9;]*m/, "", classname);
178+
gsub(/\x1b\[[0-9;]*m/, "", $0);
179+
print classname " " $0
180+
}
181+
' base-coverage-full.txt > base-coverage-details.txt || true
170182
171183
echo "=== Base coverage details saved ==="
172184
head -20 base-coverage-details.txt || true

0 commit comments

Comments
 (0)