Skip to content

Fix find -quit missing -print causing coverage report generation to silently skip#74

Merged
Chris-Wolfgang merged 2 commits intomainfrom
copilot/fix-coverage-report-generation
Mar 12, 2026
Merged

Fix find -quit missing -print causing coverage report generation to silently skip#74
Chris-Wolfgang merged 2 commits intomainfrom
copilot/fix-coverage-report-generation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

Description

find -quit terminates on first match but emits no output without -print, so the pipe to grep -q . always fails — reportgenerator never runs, CoverageReport/Summary.txt is never created, and the coverage threshold step always fails with ❌ Coverage report not generated!.

Fix: Add -print before -quit in both affected locations:

- if find ./TestResults -name "coverage.cobertura.xml" -quit 2>/dev/null | grep -q .; then
+ if find ./TestResults -name "coverage.cobertura.xml" -print -quit 2>/dev/null | grep -q .; then
  • Line 241 — Stage 1 (Linux) "Generate coverage report"
  • Line 681 — Stage 3 (macOS) "Generate coverage report"

release.yaml is unaffected — it uses PowerShell Get-ChildItem which has no equivalent issue.

Type of change

  • Bug fix

How Has This Been Tested?

  • Verified the find -print -quit | grep -q . pattern locally outputs the matched filename and returns exit code 0 when a match exists, and exit code 1 when no match exists

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Screenshots (if applicable)

Additional context

Original prompt

Bug

The "Generate coverage report" steps in .github/workflows/pr.yaml for Stage 1 (Linux) and Stage 3 (macOS) use a broken find | grep pattern that prevents the coverage report from ever being generated. This causes the subsequent "Enforce 90% coverage threshold" step to fail with ❌ Coverage report not generated!.

Root Cause

The find command uses -quit without -print, so it never outputs anything for grep to match:

# Line 241 (Stage 1) and Line 681 (Stage 3) — BROKEN:
if find ./TestResults -name "coverage.cobertura.xml" -quit 2>/dev/null | grep -q .; then

When find uses -quit, it terminates as soon as it finds the first match — but without -print, it does not output the filename. Since nothing is piped to grep, grep -q . always fails, the reportgenerator command is skipped, CoverageReport/Summary.txt is never created, and the next step fails.

Fix

Add -print before -quit in both locations so that find outputs the matched filename before quitting:

# FIXED:
if find ./TestResults -name "coverage.cobertura.xml" -print -quit 2>/dev/null | grep -q .; then

Locations to change in .github/workflows/pr.yaml

  1. Line 241 — Stage 1 (Linux) "Generate coverage report" step
  2. Line 681 — Stage 3 (macOS) "Generate coverage report" step

Both lines have the identical broken pattern and need the identical fix.

Note

The release.yaml file does NOT have this bug — it uses PowerShell Get-ChildItem instead of find, which works correctly.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Why am I getting this error on my pr.yaml

dotnet tool install -g dotnet-reportgenerator-globaltool
dotnet tool install -g dotnet-reportgenerator-globaltool
shell: /usr/bin/bash -e {0}
env:
CODECOV_MINIMUM: 90
DOTNET_ROOT: /usr/share/dotnet
You can invoke the tool using the following command: reportgenerator
Tool 'dotnet-reportgenerator-globaltool' (version '5.5.3') was successfully installed.
0s
0s
Run if [ ! -f "CoverageReport/Summary.txt" ]; then
if [ ! -f "CoverageReport/Summary.txt" ]; then
echo "❌ Coverage report not generated!"
exit 1
fi

echo "Coverage Summary:"
cat CoverageReport/Summary.txt
echo ""

THRESHOLD=${CODECOV_MINIMUM:-90}
FAILED=0

while IFS= read -r line; do
if echo "$line" | grep -qE '^[^ ]+.*[0-9]+%$' && ! echo "$line" | grep -q '^Summary'; then
MODULE=$(echo "$line" | grep -oP '^[^ ]+')
PERCENT=$(echo "$line" | grep -oP '[0-9]+(?=%)' | tail -1)
echo "Checking module: '$MODULE' - Coverage: ${PERCENT}%"
if [ "$PERCENT" -lt "$THRESHOLD" ]; then
echo " ❌ FAIL: Below ${THRESHOLD}% threshold"
FAILED=1
else
echo " ✅ PASS: Meets ${THRESHOLD}% threshold"
fi
fi
done < CoverageReport/Summary.txt

if [ "$FAILED" -ne 0 ]; then
echo ""
echo "=========================================="
echo "❌ COVERAGE GATE FAILED"
echo "=========================================="
echo "One or more modules are below ${THRESHOLD}% coverage."
echo "Stage 1 failed. Windows and macOS tests will NOT run."
exit 1
fi

echo ""
echo "=========================================="
echo "✅ COVERAGE GATE PASSED"
echo "=========================================="
echo "All modules meet ${THRESHOLD}% coverage threshold."
echo "Proceeding to Stage 2 (Windows tests)."
shell: /usr/bin/bash -e {0}
env:
CODECOV_MINIMUM: 90
DOTNET_ROOT: /usr/share/dotnet
❌ Coverage report not generated!
Error: Process completed with exit code 1.

Assistant:

Let me look at your PR workflow file and test configuration to understand why the coverage report isn't being generated.

Assistant: Now let me check if there's a coverlet.runsettings file and what the test projects look like:

Assistant: The issue is in Stage 1 (Linux), specifically in the "Generate coverage report" step (lines 239–248). Here's the root cause:

The Problem: find | grep doesn't work as expected

      - name: Generate coverage report
        run: |
          if find ./TestResults -name "coverage.cobertura.xml" -quit 2>/dev/null | grep -q .; then
            reportgenerator \
              -reports:"TestResults/**/coverage.cobertura.xml" \
              -targetdir:"CoverageReport" \
              -reporttypes:"Html;TextSummary;MarkdownSummaryGithub;CsvSummary"
          else
            echo "ℹ️  No coverage files found - skipping report generation"
          fi

The command find ... -quit | grep -q . is flawed. When find uses -quit, it terminates as soon as it finds the first match — but it doesn't print anything because there's no -print action. The -quit action tells `...

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Chris-Wolfgang <210299580+Chris-Wolfgang@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix coverage report generation in CI for macOS and Linux Fix find -quit missing -print causing coverage report generation to silently skip Mar 11, 2026
@Chris-Wolfgang Chris-Wolfgang marked this pull request as ready for review March 11, 2026 23:40
Copilot AI review requested due to automatic review settings March 11, 2026 23:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes CI coverage report generation in .github/workflows/pr.yaml by correcting the find usage so the “Generate coverage report” step actually detects coverage files and runs reportgenerator.

Changes:

  • Add -print before -quit in the Linux (Stage 1) coverage-file detection.
  • Add -print before -quit in the macOS (Stage 3) coverage-file detection.

You can also share your feedback on Copilot code review. Take the survey.

@Chris-Wolfgang Chris-Wolfgang merged commit e2b50b2 into main Mar 12, 2026
11 of 12 checks passed
@Chris-Wolfgang Chris-Wolfgang deleted the copilot/fix-coverage-report-generation branch March 12, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants