Skip to content

Commit b39aa61

Browse files
takyyonclaude
andauthored
fix(ci): Improve PR coverage check workflow accuracy (#8692)
- Add exclusions for apps/Standalone and apps/docs (no tests) - Add exclusions for manifest and swagger directories (config/data files) - Use full relative path matching instead of basename for accurate file matching in lcov reports - Add explicit list of packages that require coverage - Fail when files in covered packages have no coverage data - Report skipped files for packages not configured for coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a7bb16d commit b39aa61

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

.github/workflows/pr-coverage.yml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ jobs:
100100
**/node_modules/**
101101
**/dist/**
102102
**/build/**
103+
# Standalone app (dev environment, not covered by tests)
104+
apps/Standalone/**
105+
# Documentation site
106+
apps/docs/**
107+
# Manifest and swagger files (configuration/data, not logic)
108+
**/manifest/**
109+
**/manifests/**
110+
**/swagger/**
103111
104112
- name: Check coverage on changed files
105113
id: coverage-check
@@ -141,6 +149,10 @@ jobs:
141149
UNCOVERED_FILES=""
142150
COVERED_FILES=""
143151
PARTIAL_FILES=""
152+
SKIPPED_FILES=""
153+
154+
# Define packages that require coverage (libs with vitest configs)
155+
COVERED_PACKAGES="libs/designer libs/designer-ui libs/designer-v2 libs/logic-apps-shared libs/data-mapper libs/data-mapper-v2 libs/chatbot libs/a2a-core libs/vscode-extension apps/vs-code-designer apps/vs-code-react apps/iframe-app"
144156
145157
for file in $CHANGED_FILES; do
146158
# Skip if file doesn't exist (might have been deleted)
@@ -153,11 +165,24 @@ jobs:
153165
PKG_DIR=$(echo "$file" | sed 's|/src/.*||')
154166
LCOV_FILE="$PKG_DIR/coverage/lcov.info"
155167
168+
# Check if this package requires coverage
169+
PKG_REQUIRES_COVERAGE=false
170+
for pkg in $COVERED_PACKAGES; do
171+
if [ "$PKG_DIR" = "$pkg" ]; then
172+
PKG_REQUIRES_COVERAGE=true
173+
break
174+
fi
175+
done
176+
156177
if [ -f "$LCOV_FILE" ]; then
157-
# Check if this file is mentioned in the coverage report
158-
if grep -q "SF:.*$(basename $file)" "$LCOV_FILE" 2>/dev/null; then
159-
# Get line coverage for this file
160-
FILE_SECTION=$(awk "/SF:.*$(basename $file)/,/end_of_record/" "$LCOV_FILE" 2>/dev/null || true)
178+
# Get the absolute path pattern to match in lcov (lcov uses paths relative to package root or absolute)
179+
# Extract the path after PKG_DIR to match against lcov SF entries
180+
FILE_RELATIVE_PATH=$(echo "$file" | sed "s|^$PKG_DIR/||")
181+
182+
# Check if this file is mentioned in the coverage report using the relative path
183+
if grep -q "SF:.*${FILE_RELATIVE_PATH}$" "$LCOV_FILE" 2>/dev/null; then
184+
# Get line coverage for this file - use the full relative path for accurate matching
185+
FILE_SECTION=$(awk "/SF:.*${FILE_RELATIVE_PATH//\//\\/}\$/,/end_of_record/" "$LCOV_FILE" 2>/dev/null || true)
161186
162187
if [ -n "$FILE_SECTION" ]; then
163188
LINES_FOUND=$(echo "$FILE_SECTION" | grep "^LF:" | cut -d: -f2 || echo "0")
@@ -177,9 +202,12 @@ jobs:
177202
else
178203
UNCOVERED_FILES="$UNCOVERED_FILES\n❌ \`$file\` - Not covered by tests"
179204
fi
205+
elif [ "$PKG_REQUIRES_COVERAGE" = true ]; then
206+
# Package should have coverage but doesn't - this is a problem
207+
UNCOVERED_FILES="$UNCOVERED_FILES\n❌ \`$file\` - No coverage data (package should have tests)"
180208
else
181-
# No coverage file found for this package - might be acceptable
182-
echo "ℹ️ No coverage data for package: $PKG_DIR" >> $GITHUB_STEP_SUMMARY
209+
# Package doesn't require coverage (not in the list)
210+
SKIPPED_FILES="$SKIPPED_FILES\n⏭️ \`$file\` - Package not configured for coverage"
183211
fi
184212
done
185213
@@ -198,6 +226,12 @@ jobs:
198226
echo "" >> $GITHUB_STEP_SUMMARY
199227
fi
200228
229+
if [ -n "$SKIPPED_FILES" ]; then
230+
echo "#### ⏭️ Skipped (package not configured for coverage):" >> $GITHUB_STEP_SUMMARY
231+
echo -e "$SKIPPED_FILES" >> $GITHUB_STEP_SUMMARY
232+
echo "" >> $GITHUB_STEP_SUMMARY
233+
fi
234+
201235
if [ -n "$UNCOVERED_FILES" ]; then
202236
echo "#### ❌ Not Covered:" >> $GITHUB_STEP_SUMMARY
203237
echo -e "$UNCOVERED_FILES" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)