Skip to content

Commit c684774

Browse files
Updated the PR bot comment
1 parent 14f3c0c commit c684774

1 file changed

Lines changed: 72 additions & 28 deletions

File tree

.github/workflows/coverage_lcov.yml

Lines changed: 72 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
uses: ./.github/actions/checkout-submodules-and-bootstrap
4747
with:
4848
platform: linux
49-
bootstrap-log-name: bootstrap-logs-codecov-${{ matrix.type }}
49+
bootstrap-log-name: bootstrap-logs-codecov
5050

5151
- name: Run Build Coverage
5252
run: ./scripts/build_coverage.sh --yaml --xml
@@ -56,47 +56,84 @@ jobs:
5656
# Generate a human-readable coverage summary
5757
lcov --summary out/coverage/coverage/coverage.info > coverage-summary.txt 2>&1 || true
5858
59-
# Extract key metrics from the XML file
59+
# Parse XML directly from the first line to extract coverage data
6060
if [ -f "out/coverage/coverage/coverage.xml" ]; then
6161
python3 -c '
6262
import xml.etree.ElementTree as ET
6363
import sys
64+
import os
6465
6566
try:
67+
# Parse the XML file
6668
tree = ET.parse("out/coverage/coverage/coverage.xml")
6769
root = tree.getroot()
6870
69-
# Find coverage metrics
70-
for coverage in root.findall(".//coverage"):
71-
line_rate = coverage.get("line-rate", "0")
72-
branch_rate = coverage.get("branch-rate", "0")
73-
lines_covered = coverage.get("lines-covered", "0")
74-
lines_valid = coverage.get("lines-valid", "0")
75-
branches_covered = coverage.get("branches-covered", "0")
76-
branches_valid = coverage.get("branches-valid", "0")
77-
78-
print(f"## 📊 Coverage Report")
79-
print(f"")
80-
print(f"**Overall Coverage Metrics:**")
81-
print(f"- **Line Coverage:** {float(line_rate)*100:.1f}% ({lines_covered}/{lines_valid} lines)")
82-
print(f"- **Branch Coverage:** {float(branch_rate)*100:.1f}% ({branches_covered}/{branches_valid} branches)")
83-
print(f"")
84-
print(f"📁 **Available Reports:**")
85-
print(f"- 📋 Coverage XML (machine-readable)")
86-
print(f"- 📊 Coverage HTML (interactive report)")
87-
print(f"- 📄 Coverage Info (LCOV format)")
88-
print(f"- 📝 Coverage Summary (text)")
89-
break
71+
# Extract coverage attributes from the root coverage element
72+
line_rate = root.get("line-rate", "0")
73+
branch_rate = root.get("branch-rate", "0")
74+
lines_covered = root.get("lines-covered", "0")
75+
lines_valid = root.get("lines-valid", "0")
76+
branches_covered = root.get("branches-covered", "0")
77+
branches_valid = root.get("branches-valid", "0")
78+
timestamp = root.get("timestamp", "0")
79+
80+
# Convert to percentages
81+
line_percentage = float(line_rate) * 100
82+
branch_percentage = float(branch_rate) * 100
83+
84+
# Generate report
85+
print(f"## 📊 Coverage Report")
86+
print(f"")
87+
print(f"**Overall Coverage Metrics:**")
88+
print(f"- **Line Coverage:** {line_percentage:.1f}% ({lines_covered}/{lines_valid} lines)")
89+
print(f"- **Branch Coverage:** {branch_percentage:.1f}% ({branches_covered}/{branches_valid} branches)")
90+
print(f"")
91+
92+
# Add coverage quality indicator
93+
if line_percentage >= 80:
94+
quality = "🟢 Excellent"
95+
elif line_percentage >= 60:
96+
quality = "🟡 Good"
97+
elif line_percentage >= 40:
98+
quality = "🟠 Fair"
99+
else:
100+
quality = "🔴 Needs Improvement"
101+
102+
print(f"**Coverage Quality:** {quality}")
103+
print(f"")
104+
print(f"📁 **Available Reports:**")
105+
print(f"- 📋 Coverage XML (machine-readable)")
106+
print(f"- 📊 Coverage HTML (interactive report)")
107+
print(f"- 📄 Coverage Info (LCOV format)")
108+
print(f"- 📝 Coverage Summary (text)")
109+
90110
except Exception as e:
91111
print(f"## 📊 Coverage Report")
92-
print(f"❌ Error parsing coverage data: {e}")
112+
print(f"❌ Error parsing coverage data: {str(e)}")
113+
print(f"")
114+
# Try to show first few lines of XML for debugging
115+
try:
116+
with open("out/coverage/coverage/coverage.xml", "r") as f:
117+
lines = f.readlines()[:3]
118+
print(f"**XML Preview:**")
119+
for line in lines:
120+
print(f"`{line.strip()}`")
121+
except:
122+
print("Could not read XML file")
93123
' > coverage-report.md
124+
125+
# Debug: Show if the report was generated
126+
echo "Generated coverage-report.md:"
127+
cat coverage-report.md || echo "Failed to generate report"
128+
else
129+
echo "## 📊 Coverage Report" > coverage-report.md
130+
echo "❌ Coverage XML file not found" >> coverage-report.md
94131
fi
95132
96133
- name: Upload Coverage Artifacts
97134
uses: actions/upload-artifact@v4
98135
with:
99-
name: coverage-report-${{ matrix.type }}
136+
name: coverage-report
100137
path: |
101138
out/coverage/coverage/coverage.xml
102139
out/coverage/coverage/coverage.info
@@ -114,17 +151,24 @@ jobs:
114151
115152
let coverageReport = '';
116153
try {
117-
coverageReport = fs.readFileSync('coverage-report.md', 'utf8');
154+
if (fs.existsSync('coverage-report.md')) {
155+
coverageReport = fs.readFileSync('coverage-report.md', 'utf8');
156+
console.log('Coverage report content:', coverageReport);
157+
} else {
158+
console.log('coverage-report.md not found');
159+
coverageReport = '## 📊 Coverage Report\n❌ Coverage report file not found';
160+
}
118161
} catch (error) {
119-
coverageReport = '## 📊 Coverage Report\n❌ Could not generate coverage report';
162+
console.log('Error reading coverage report:', error);
163+
coverageReport = '## 📊 Coverage Report\n❌ Could not read coverage report: ' + error.message;
120164
}
121165
122166
// Add artifact download instructions
123167
const artifactMessage = `
124168
125169
## 📎 How to Access Coverage Reports:
126170
127-
1. **Download Artifacts:** Go to the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) and download \`coverage-report-${{ matrix.type }}\`
171+
1. **Download Artifacts:** Go to the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) and download \`coverage-report\`
128172
2. **View HTML Report:** Extract the artifact and open \`html/index.html\` in your browser for interactive coverage analysis
129173
3. **Machine Processing:** Use \`coverage.xml\` (Cobertura format) or \`coverage.info\` (LCOV format) for tooling integration
130174

0 commit comments

Comments
 (0)