Fix macOS grep -P incompatibility in Stage 3 coverage threshold enforcement (pr.yaml)#78
Merged
Chris-Wolfgang merged 4 commits intocopilot/add-coverlet-collector-referencefrom Mar 12, 2026
Conversation
Co-authored-by: Chris-Wolfgang <210299580+Chris-Wolfgang@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix GitHub Actions workflow by replacing grep with awk
Fix macOS grep -P incompatibility in coverage threshold enforcement (pr.yaml)
Mar 12, 2026
Chris-Wolfgang
requested changes
Mar 12, 2026
Owner
Chris-Wolfgang
left a comment
There was a problem hiding this comment.
This change should only be applied to stage 3. stage 1 works fine
…Stage 3 only Co-authored-by: Chris-Wolfgang <210299580+Chris-Wolfgang@users.noreply.github.com>
Contributor
Author
Reverted in 7d66b76 — Stage 1 is back to the original |
Copilot
AI
changed the title
Fix macOS grep -P incompatibility in coverage threshold enforcement (pr.yaml)
Fix macOS grep -P incompatibility in Stage 3 coverage threshold enforcement (pr.yaml)
Mar 12, 2026
…fix-grep-issues-in-workflow
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
You can also share your feedback on Copilot code review. Take the survey.
5db3174
into
copilot/add-coverlet-collector-reference
1 check passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
macOS BSD
grepdoes not support-P(Perl-compatible regex), causing Stage 3 (macOS) to fail with an invalid option error during coverage gate enforcement — even when coverage is 100%. Thewhile/grep -oPblock inpr.yamlthat parsesCoverageReport/Summary.txtin the Stage 3 (macOS) coverage gate is replaced with a portable POSIXawkimplementation. Stage 1 (Linux) is unchanged, as GNU grep supports-Pon Ubuntu runners.Changes —
.github/workflows/pr.yaml:while IFS= read -r line; do ... grep -oP ... donewith a singleawkcommandnumber%occurrences per line to match the originalgrep -oP ... | tail -1(last-match) behavior\047) and emoji to avoid shell quoting issues inside the awk single-quoted program^[^ ]+.*[0-9]+%$, skipsSummarylinesType of change
How Has This Been Tested?
Summary.txtcontent: all-pass, mixed pass/fail,Summary-line exclusion, and empty-file cases all produce correct output and exit codes.Checklist
Screenshots (if applicable)
N/A
Additional context
Only the Stage 3 (macOS) Bash coverage parsing logic is changed. Stage 1 (Linux) retains the original
grep -oPimplementation, which works correctly on Ubuntu runners. No test projects, coverage config, or other workflow steps are modified. Thegrep -oPusages on lines 150 and 201 are framework-detection logic that runs exclusively on Ubuntu and are also unaffected.Original prompt
The GitHub Actions workflow for Stage 3 (macOS) fails due to the use of GNU-specific 'grep -P' and 'grep -oP' in the Bash coverage threshold enforcement logic. On macOS, grep does not support these options, causing an invalid option error even when coverage is 100%.
Solution:
No test or coverage config changes are needed, only the Bash parsing logic.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: This worked before and the pr.yaml was recently updated. Compare the current pr.yaml to the previous version
Assistant: The current and previous versions of your
.github/workflows/pr.yamlare identical, at least as far as the linted output and job structure for test project discovery in the Linux/Stage 1 step are concerned.Here’s the relevant block from both versions:
The search looks in
./testsrecursively for any.csprojfile, which matches your actual structure.What might be different?
If you are suddenly getting the "No test projects found in ./tests directory!" error, but the workflow didn't change, consider:
mapfileis Bash-specific)GLOBIGNORE,.dockerignore, or CI env oversight that preventsfindfrom matching anything?What to do next
1. Confirm the Bash Shell
Make your test step explicit (add this if missing!):
2. Add Debug Output
Add this debug just before the
mapfilestep to catch directory structure issues:3. Confirm the path exists at runtime (sometimes checkouts or job matrixes mess up working dirs).
Summary
There is no detectable difference in the discovery logic between the current and previous PR workflow YAML. All code is still searching for test projects in
./testsas before.If you want, I can generate a patched step for debugging this issue further!
User: The pr.yaml is still failing on step 1 linux on the code coverage.
if find ./TestResults -name "coverage.cobertura.xml" -print -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
shell: /usr/bin/bash -e {0}
env:
CODECOV_MINIMUM: 90
DOTNET_ROOT: /usr/share/dotnet
ℹ️ No coverage files found - skipping report generation
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
e...
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.