Skip to content

Commit ad54413

Browse files
committed
adding std action for posting cov comment
1 parent 50023f7 commit ad54413

File tree

3 files changed

+126
-121
lines changed

3 files changed

+126
-121
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Post Coverage Comment
2+
description: Posts a standardized code coverage comment on a pull request
3+
4+
inputs:
5+
pr_number:
6+
description: 'Pull request number'
7+
required: true
8+
coverage_percentage:
9+
description: 'Overall coverage percentage'
10+
required: true
11+
covered_lines:
12+
description: 'Number of covered lines'
13+
required: true
14+
total_lines:
15+
description: 'Total number of lines'
16+
required: true
17+
patch_coverage_pct:
18+
description: 'Patch/diff coverage percentage'
19+
required: true
20+
low_coverage_files:
21+
description: 'Files with lowest coverage (multiline)'
22+
required: true
23+
patch_coverage_summary:
24+
description: 'Patch coverage summary markdown (multiline)'
25+
required: true
26+
ado_url:
27+
description: 'Azure DevOps build URL'
28+
required: true
29+
30+
runs:
31+
using: composite
32+
steps:
33+
- name: Post coverage comment
34+
uses: marocchino/sticky-pull-request-comment@v2
35+
with:
36+
header: Code Coverage Report
37+
number: ${{ inputs.pr_number }}
38+
message: |
39+
# 📊 Code Coverage Report
40+
41+
<table>
42+
<tr>
43+
<td align="center" width="200">
44+
45+
### 🔥 Diff Coverage
46+
### **${{ inputs.patch_coverage_pct }}**
47+
<br>
48+
</td>
49+
<td align="center" width="200">
50+
51+
### 🎯 Overall Coverage
52+
### **${{ inputs.coverage_percentage }}**
53+
<br>
54+
</td>
55+
<td>
56+
57+
**📈 Total Lines Covered:** `${{ inputs.covered_lines }}` out of `${{ inputs.total_lines }}`
58+
**📁 Project:** `mssql-python`
59+
60+
</td>
61+
</tr>
62+
</table>
63+
64+
---
65+
66+
${{ inputs.patch_coverage_summary }}
67+
68+
---
69+
### 📋 Files Needing Attention
70+
71+
<details>
72+
<summary>📉 <strong>Files with overall lowest coverage</strong> (click to expand)</summary>
73+
<br>
74+
75+
```diff
76+
${{ inputs.low_coverage_files }}
77+
```
78+
79+
</details>
80+
81+
---
82+
### 🔗 Quick Links
83+
84+
<table>
85+
<tr>
86+
<td align="left" width="200">
87+
<b>⚙️ Build Summary</b>
88+
</td>
89+
<td align="left">
90+
<b>📋 Coverage Details</b>
91+
</td>
92+
</tr>
93+
<tr>
94+
<td align="left" width="200">
95+
96+
[View Azure DevOps Build](${{ inputs.ado_url }})
97+
98+
</td>
99+
<td align="left">
100+
101+
[Browse Full Coverage Report](${{ inputs.ado_url }}&view=codecoverage-tab)
102+
103+
</td>
104+
</tr>
105+
</table>

.github/workflows/forked-pr-coverage-comment.yml renamed to .github/workflows/forked-pr-coverage.yml

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ jobs:
3333
contents: read
3434

3535
steps:
36+
- name: Checkout repo
37+
uses: actions/checkout@v4
38+
3639
- name: Download coverage data
3740
env:
3841
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -96,58 +99,16 @@ jobs:
9699
} >> $GITHUB_ENV
97100
98101
- name: Comment coverage summary on PR
99-
uses: marocchino/sticky-pull-request-comment@v2
102+
uses: ./.github/actions/post-coverage-comment
100103
with:
101-
number: ${{ env.PR_NUMBER }}
102-
header: Code Coverage Report
103-
message: |
104-
# 📊 Code Coverage Report
105-
106-
<table>
107-
<tr>
108-
<td align="center" width="200">
109-
110-
### 🔥 Diff Coverage
111-
### **${{ env.PATCH_COVERAGE_PCT }}**
112-
<br>
113-
</td>
114-
<td align="center" width="200">
115-
116-
### 🎯 Overall Coverage
117-
### **${{ env.COVERAGE_PERCENTAGE }}**
118-
<br>
119-
</td>
120-
<td>
121-
122-
**📈 Total Lines Covered:** `${{ env.COVERED_LINES }}` out of `${{ env.TOTAL_LINES }}`
123-
**📁 Project:** `mssql-python`
124-
125-
</td>
126-
</tr>
127-
</table>
128-
129-
---
130-
131-
${{ env.PATCH_COVERAGE_SUMMARY }}
132-
133-
---
134-
### 📋 Files Needing Attention
135-
136-
<details>
137-
<summary>📉 <strong>Files with overall lowest coverage</strong> (click to expand)</summary>
138-
<br>
139-
140-
```diff
141-
${{ env.LOW_COVERAGE_FILES }}
142-
```
143-
144-
</details>
145-
146-
---
147-
### 🔗 Quick Links
148-
149-
<table>
150-
<tr>
104+
pr_number: ${{ env.PR_NUMBER }}
105+
coverage_percentage: ${{ env.COVERAGE_PERCENTAGE }}
106+
covered_lines: ${{ env.COVERED_LINES }}
107+
total_lines: ${{ env.TOTAL_LINES }}
108+
patch_coverage_pct: ${{ env.PATCH_COVERAGE_PCT }}
109+
low_coverage_files: ${{ env.LOW_COVERAGE_FILES }}
110+
patch_coverage_summary: ${{ env.PATCH_COVERAGE_SUMMARY }}
111+
ado_url: ${{ env.ADO_URL }}
151112
<td align="left" width="200">
152113
<b>⚙️ Build Summary</b>
153114
</td>

.github/workflows/pr-code-coverage.yml

Lines changed: 9 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -463,74 +463,13 @@ jobs:
463463
- name: Comment coverage summary on PR
464464
# Skip for forked PRs due to token permission restrictions
465465
if: github.event.pull_request.head.repo.full_name == github.repository
466-
uses: marocchino/sticky-pull-request-comment@v2
466+
uses: ./.github/actions/post-coverage-comment
467467
with:
468-
header: Code Coverage Report
469-
message: |
470-
# 📊 Code Coverage Report
471-
472-
<table>
473-
<tr>
474-
<td align="center" width="200">
475-
476-
### 🔥 Diff Coverage
477-
### **${{ env.PATCH_COVERAGE_PCT }}**
478-
<br>
479-
</td>
480-
<td align="center" width="200">
481-
482-
### 🎯 Overall Coverage
483-
### **${{ env.COVERAGE_PERCENTAGE }}**
484-
<br>
485-
</td>
486-
<td>
487-
488-
**📈 Total Lines Covered:** `${{ env.COVERED_LINES }}` out of `${{ env.TOTAL_LINES }}`
489-
**📁 Project:** `mssql-python`
490-
491-
</td>
492-
</tr>
493-
</table>
494-
495-
---
496-
497-
${{ env.PATCH_COVERAGE_SUMMARY }}
498-
499-
---
500-
### 📋 Files Needing Attention
501-
502-
<details>
503-
<summary>📉 <strong>Files with overall lowest coverage</strong> (click to expand)</summary>
504-
<br>
505-
506-
```diff
507-
${{ env.LOW_COVERAGE_FILES }}
508-
```
509-
510-
</details>
511-
512-
---
513-
### 🔗 Quick Links
514-
515-
<table>
516-
<tr>
517-
<td align="left" width="200">
518-
<b>⚙️ Build Summary</b>
519-
</td>
520-
<td align="left">
521-
<b>📋 Coverage Details</b>
522-
</td>
523-
</tr>
524-
<tr>
525-
<td align="left" width="200">
526-
527-
[View Azure DevOps Build](${{ env.ADO_URL }})
528-
529-
</td>
530-
<td align="left">
531-
532-
[Browse Full Coverage Report](${{ env.ADO_URL }}&view=codecoverage-tab)
533-
534-
</td>
535-
</tr>
536-
</table>
468+
pr_number: ${{ github.event.pull_request.number }}
469+
coverage_percentage: ${{ env.COVERAGE_PERCENTAGE }}
470+
covered_lines: ${{ env.COVERED_LINES }}
471+
total_lines: ${{ env.TOTAL_LINES }}
472+
patch_coverage_pct: ${{ env.PATCH_COVERAGE_PCT }}
473+
low_coverage_files: ${{ env.LOW_COVERAGE_FILES }}
474+
patch_coverage_summary: ${{ env.PATCH_COVERAGE_SUMMARY }}
475+
ado_url: ${{ env.ADO_URL }}

0 commit comments

Comments
 (0)