Skip to content

Commit 6fd39e3

Browse files
authored
Merge pull request #479 from wpengine/chore-fix-codeception-percentage-calculation
chore: Fix codeception workflow to calculate correctly the code coverage percentage
2 parents ea4a066 + a4f6d42 commit 6fd39e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

plugins/wpgraphql-logging/bin/run-codeception.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ run_tests() {
6969
# Prefer XML summary for robustness; fallback to HTML if present
7070
if [[ -f "tests/_output/coverage.xml" ]]; then
7171
# Extract total statements and covered statements from the summary metrics line
72-
total_statements=$(grep -Eo 'statements="[0-9]+"' "tests/_output/coverage.xml" | head -1 | grep -Eo '[0-9]+')
73-
total_covered=$(grep -Eo 'coveredstatements="[0-9]+"' "tests/_output/coverage.xml" | head -1 | grep -Eo '[0-9]+')
72+
total_statements=$(grep -Eo ' statements="[0-9]+"' "tests/_output/coverage.xml" | tail -1 | grep -Eo '[0-9]+')
73+
total_covered=$(grep -Eo ' coveredstatements="[0-9]+"' "tests/_output/coverage.xml" | tail -1 | grep -Eo '[0-9]+')
7474
if [[ -n "$total_statements" && -n "$total_covered" && "$total_statements" -gt 0 ]]; then
7575
coverage_percent=$(awk "BEGIN { printf \"%.2f\", ($total_covered / $total_statements) * 100 }")
7676
fi

0 commit comments

Comments
 (0)