@@ -140,107 +140,6 @@ jobs:
140140 echo "✅ Coverage $COVERAGE% meets threshold $THRESHOLD%"
141141 fi
142142
143- - name : Generate coverage badge data
144- if : github.event_name == 'pull_request'
145- id : badge
146- run : |
147- COVERAGE=${{ steps.coverage.outputs.coverage }}
148-
149- # Determine badge color based on coverage
150- if [ $(echo "$COVERAGE >= 90" | bc -l) -eq 1 ]; then
151- COLOR="brightgreen"
152- elif [ $(echo "$COVERAGE >= 80" | bc -l) -eq 1 ]; then
153- COLOR="green"
154- elif [ $(echo "$COVERAGE >= 70" | bc -l) -eq 1 ]; then
155- COLOR="yellow"
156- elif [ $(echo "$COVERAGE >= 60" | bc -l) -eq 1 ]; then
157- COLOR="orange"
158- else
159- COLOR="red"
160- fi
161-
162- echo "color=$COLOR" >> $GITHUB_OUTPUT
163-
164- - name : Generate PR comment body
165- if : github.event_name == 'pull_request'
166- id : comment
167- env :
168- COVERAGE : ${{ steps.coverage.outputs.coverage }}
169- BADGE_COLOR : ${{ steps.badge.outputs.color }}
170- COMMIT_SHA : ${{ github.event.pull_request.head.sha }}
171- run : |
172- # Determine status
173- if [ $(echo "$COVERAGE >= 80" | bc -l) -eq 1 ]; then
174- STATUS="✅ PASSED - Coverage meets minimum threshold"
175- STATUS_EMOJI="✅"
176- else
177- STATUS="❌ FAILED - Coverage below minimum threshold"
178- STATUS_EMOJI="❌"
179- fi
180-
181- # Create comment body using heredoc
182- cat > comment_final.txt << EOF
183- ## 📊 Test Coverage Report
184-
185- **Overall Coverage:** ${COVERAGE}% 
186-
187- **Threshold:** 80% ${STATUS_EMOJI}
188-
189- <details>
190- <summary>Coverage by Package</summary>
191-
192- \`\`\`
193- $(cat coverage_report.txt)
194- \`\`\`
195-
196- </details>
197-
198- ---
199- 📈 **Coverage Status:** ${STATUS}
200-
201- <sub>Updated for commit ${COMMIT_SHA}</sub>
202- EOF
203-
204- - name : Comment on PR
205- if : github.event_name == 'pull_request'
206- continue-on-error : true # Don't fail CI if comment posting fails
207- uses : actions/github-script@v8
208- env :
209- COMMENT_BODY : ${{ steps.comment.outputs.comment_body }}
210- with :
211- script : |
212- const fs = require('fs');
213- const commentBody = fs.readFileSync('comment_final.txt', 'utf8');
214-
215- // Find existing comment
216- const { data: comments } = await github.rest.issues.listComments({
217- owner: context.repo.owner,
218- repo: context.repo.repo,
219- issue_number: context.issue.number,
220- });
221-
222- const botComment = comments.find(comment =>
223- comment.user.type === 'Bot' && comment.body.includes('📊 Test Coverage Report')
224- );
225-
226- if (botComment) {
227- // Update existing comment
228- await github.rest.issues.updateComment({
229- owner: context.repo.owner,
230- repo: context.repo.repo,
231- comment_id: botComment.id,
232- body: commentBody
233- });
234- } else {
235- // Create new comment
236- await github.rest.issues.createComment({
237- owner: context.repo.owner,
238- repo: context.repo.repo,
239- issue_number: context.issue.number,
240- body: commentBody
241- });
242- }
243-
244143 - name : Generate coverage badge for main branch
245144 if : github.ref == 'refs/heads/main' && github.event_name == 'push'
246145 env :
0 commit comments