Skip to content

Commit 08d4e5a

Browse files
authored
fix(Meta): Fixing issue with style file coverage, and step data persistence (#8814)
Fixed issue with style file coverage, and step data persistance
1 parent 216718e commit 08d4e5a

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

.github/workflows/pr-coverage.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ jobs:
8989
**/types.ts
9090
**/types.tsx
9191
**/styles.ts
92+
**/styles.tsx
93+
**/*.styles.ts
94+
**/*.styles.tsx
9295
**/constants.ts
9396
**/constants/**
9497
# Config files
@@ -143,6 +146,7 @@ jobs:
143146
if [ -z "$CHANGED_FILES" ]; then
144147
echo "No source files changed in this PR." >> $GITHUB_STEP_SUMMARY
145148
echo "coverage_status=skip" >> $GITHUB_OUTPUT
149+
printf '%s\n\n%s\n' "## 📊 Coverage Check" "No source files changed in this PR." > ./coverage-comment.md
146150
exit 0
147151
fi
148152
@@ -163,6 +167,7 @@ jobs:
163167
echo "" >> $GITHUB_STEP_SUMMARY
164168
echo "❌ **No coverage data found.** Please ensure tests generate coverage reports." >> $GITHUB_STEP_SUMMARY
165169
echo "coverage_status=no_data" >> $GITHUB_OUTPUT
170+
printf '%s\n\n%s\n' "## 📊 Coverage Check" "⚠️ No coverage data found. Please ensure tests generate coverage reports." > ./coverage-comment.md
166171
exit 0
167172
fi
168173
fi
@@ -267,6 +272,27 @@ jobs:
267272
echo "coverage_status=pass" >> $GITHUB_OUTPUT
268273
fi
269274
275+
# Build a concise PR comment with failing files
276+
{
277+
echo "## 📊 Coverage Check"
278+
echo ""
279+
if [ -n "$UNCOVERED_FILES" ] || [ -n "$PARTIAL_FILES" ]; then
280+
echo "The following changed files need attention:"
281+
echo ""
282+
if [ -n "$UNCOVERED_FILES" ]; then
283+
echo -e "$UNCOVERED_FILES"
284+
echo ""
285+
fi
286+
if [ -n "$PARTIAL_FILES" ]; then
287+
echo -e "$PARTIAL_FILES"
288+
echo ""
289+
fi
290+
echo "**Please add tests for the uncovered files before merging.**"
291+
else
292+
echo "🎉 **All changed files have adequate test coverage!**"
293+
fi
294+
} > ./coverage-comment.md
295+
270296
- name: Post coverage comment on PR
271297
if: always()
272298
uses: actions/github-script@v7
@@ -283,17 +309,18 @@ jobs:
283309
return;
284310
}
285311
286-
// Read the step summary
287-
const summaryPath = process.env.GITHUB_STEP_SUMMARY;
312+
const COMMENT_MARKER = '<!-- pr-coverage-check-comment -->';
313+
314+
// Read the coverage comment built by the coverage-check step
288315
let summary = '';
289316
try {
290-
summary = fs.readFileSync(summaryPath, 'utf8');
317+
summary = fs.readFileSync('./coverage-comment.md', 'utf8');
291318
} catch (e) {
292319
summary = '📊 Coverage check completed. See workflow run for details.';
293320
}
294321
295322
try {
296-
// Find existing comment
323+
// Find existing comment by hidden marker
297324
const { data: comments } = await github.rest.issues.listComments({
298325
owner: context.repo.owner,
299326
repo: context.repo.repo,
@@ -302,10 +329,10 @@ jobs:
302329
303330
const botComment = comments.find(comment =>
304331
comment.user.type === 'Bot' &&
305-
comment.body.includes('📊 Coverage Report for Changed Files')
332+
comment.body.includes(COMMENT_MARKER)
306333
);
307334
308-
const commentBody = summary || '📊 Coverage check completed. See workflow run for details.';
335+
const commentBody = COMMENT_MARKER + '\n' + (summary || '📊 Coverage check completed. See workflow run for details.');
309336
310337
if (botComment) {
311338
await github.rest.issues.updateComment({

0 commit comments

Comments
 (0)