Skip to content

Commit 8f876d8

Browse files
Added GitHub Pages for Coverage Reports
1 parent c684774 commit 8f876d8

1 file changed

Lines changed: 88 additions & 16 deletions

File tree

.github/workflows/coverage_lcov.yml

Lines changed: 88 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ concurrency:
1414
permissions:
1515
contents: read
1616
pull-requests: write
17+
pages: write
18+
id-token: write
1719

1820
env:
1921
CHIP_NO_LOG_TIMESTAMPS: true
2022

2123
jobs:
22-
linux-coverage:
23-
name: Coverage
24+
build-coverage:
25+
name: Build Coverage
2426
if: github.actor != 'restyled-io[bot]'
2527

2628
runs-on: ubuntu-latest
@@ -101,11 +103,6 @@ jobs:
101103
102104
print(f"**Coverage Quality:** {quality}")
103105
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)")
109106
110107
except Exception as e:
111108
print(f"## 📊 Coverage Report")
@@ -130,17 +127,70 @@ jobs:
130127
echo "❌ Coverage XML file not found" >> coverage-report.md
131128
fi
132129
130+
- name: Prepare GitHub Pages Content
131+
run: |
132+
# Create _site directory (required by upload-pages-artifact)
133+
mkdir -p _site/coverage
134+
135+
# Determine the target directory based on event type
136+
if [ "${{ github.event_name }}" = "pull_request" ]; then
137+
COVERAGE_PATH="pr-${{ github.event.number }}"
138+
else
139+
BRANCH_NAME=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9]/-/g')
140+
COVERAGE_PATH="branch-$BRANCH_NAME"
141+
fi
142+
143+
# Copy HTML coverage report
144+
TARGET_DIR="_site/coverage/$COVERAGE_PATH"
145+
mkdir -p "$TARGET_DIR"
146+
cp -r out/coverage/coverage/html/* "$TARGET_DIR/"
147+
148+
# Create/update index page
149+
cat > _site/coverage/index.html << 'EOF'
150+
<!DOCTYPE html>
151+
<html>
152+
<head>
153+
<title>Coverage Reports</title>
154+
<style>
155+
body { font-family: Arial, sans-serif; margin: 40px; }
156+
.report { border: 1px solid #ddd; padding: 20px; margin: 10px 0; border-radius: 5px; }
157+
.pr { background-color: #f8f9fa; }
158+
.branch { background-color: #e8f5e9; }
159+
.timestamp { color: #666; font-size: 0.9em; }
160+
a { text-decoration: none; color: #0366d6; }
161+
a:hover { text-decoration: underline; }
162+
</style>
163+
</head>
164+
<body>
165+
<h1>📊 Coverage Reports</h1>
166+
<div id="reports"></div>
167+
</body>
168+
</html>
169+
EOF
170+
171+
# Build the correct GitHub Pages URL
172+
REPO_NAME="${{ github.event.repository.name }}"
173+
REPORT_URL="https://${{ github.repository_owner }}.github.io/${REPO_NAME}/coverage/${COVERAGE_PATH}"
174+
175+
echo "REPORT_URL=$REPORT_URL" >> $GITHUB_ENV
176+
echo "COVERAGE_PATH=$COVERAGE_PATH" >> $GITHUB_ENV
177+
178+
echo "Coverage will be available at: $REPORT_URL"
179+
133180
- name: Upload Coverage Artifacts
134181
uses: actions/upload-artifact@v4
135182
with:
136183
name: coverage-report
137184
path: |
138185
out/coverage/coverage/coverage.xml
139186
out/coverage/coverage/coverage.info
140-
out/coverage/coverage/html/**
141-
coverage-summary.txt
142187
coverage-report.md
143-
retention-days: 30
188+
retention-days: 7
189+
190+
- name: Upload Pages Artifact
191+
uses: actions/upload-pages-artifact@v3
192+
with:
193+
path: _site
144194

145195
- name: Comment Coverage Report on PR
146196
if: github.event_name == 'pull_request'
@@ -163,20 +213,23 @@ jobs:
163213
coverageReport = '## 📊 Coverage Report\n❌ Could not read coverage report: ' + error.message;
164214
}
165215
166-
// Add artifact download instructions
167-
const artifactMessage = `
216+
// Add GitHub Pages link
217+
const reportUrl = process.env.REPORT_URL;
218+
const pagesMessage = `
219+
## 🌐 Interactive Coverage Report
220+
221+
**[📊 View Full HTML Coverage Report](${reportUrl})**
168222
169-
## 📎 How to Access Coverage Reports:
223+
## 📎 Additional Reports:
170224
171225
1. **Download Artifacts:** Go to the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) and download \`coverage-report\`
172-
2. **View HTML Report:** Extract the artifact and open \`html/index.html\` in your browser for interactive coverage analysis
173-
3. **Machine Processing:** Use \`coverage.xml\` (Cobertura format) or \`coverage.info\` (LCOV format) for tooling integration
226+
2. **Machine Processing:** Use \`coverage.xml\` (Cobertura format) or \`coverage.info\` (LCOV format) for tooling integration
174227
175228
---
176229
*Coverage report updated on: ${new Date().toISOString()}*
177230
`;
178231
179-
const body = coverageReport + artifactMessage;
232+
const body = coverageReport + pagesMessage;
180233
181234
// Find existing coverage comment
182235
const comments = await github.rest.issues.listComments({
@@ -207,3 +260,22 @@ jobs:
207260
body: body
208261
});
209262
}
263+
264+
deploy-pages:
265+
needs: build-coverage
266+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
267+
268+
permissions:
269+
pages: write
270+
id-token: write
271+
272+
environment:
273+
name: github-pages
274+
url: ${{ steps.deployment.outputs.page_url }}
275+
276+
runs-on: ubuntu-latest
277+
278+
steps:
279+
- name: Deploy to GitHub Pages
280+
id: deployment
281+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)