Skip to content

Commit 42630a8

Browse files
author
RandomCrocodile
committed
chore: auto-install reportgenerator and emit markdown coverage in local-ci
The offline CI now installs the reportgenerator global tool on demand (mirroring .github/workflows/test.yml) instead of silently skipping the coverage report when it is absent. It also emits the same report types as CI — HTML, Cobertura, TextSummary and MarkdownSummaryGithub — so a local run produces SummaryGithub.md, the offline equivalent of the coverage summary CI posts to the PR.
1 parent 760addb commit 42630a8

1 file changed

Lines changed: 33 additions & 10 deletions

File tree

scripts/local-ci.sh

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,41 @@ do_test() {
247247
echo -e " ${BOLD}Total: Passed=$total_passed Failed=$total_failed Skipped=$total_skipped${NC}"
248248
echo " ─────────────────────────────────────"
249249

250-
# Generate coverage report if reportgenerator is available
250+
# Generate coverage report. reportgenerator is required for the coverage summary;
251+
# install it on demand (mirroring the CI workflow) so local runs always produce a
252+
# report — including the same markdown summary CI posts to the PR.
251253
local reports
252254
reports=$(find "$RESULTS_DIR" -name "coverage.cobertura.xml" 2>/dev/null | tr '\n' ';')
253-
if [ -n "$reports" ] && command -v reportgenerator &>/dev/null; then
254-
step "COVERAGE — generating report"
255-
mkdir -p "$COVERAGE_DIR/report"
256-
reportgenerator "-reports:$reports" \
257-
"-targetdir:$COVERAGE_DIR/report" \
258-
"-reporttypes:TextSummary" 2>/dev/null
259-
cat "$COVERAGE_DIR/report/Summary.txt" 2>/dev/null || true
260-
elif [ -n "$reports" ]; then
261-
warn "Install reportgenerator for coverage reports: dotnet tool install -g dotnet-reportgenerator-globaltool"
255+
if [ -n "$reports" ]; then
256+
if ! command -v reportgenerator &>/dev/null; then
257+
step "COVERAGE — installing reportgenerator (dotnet global tool)"
258+
dotnet tool install -g dotnet-reportgenerator-globaltool 2>/dev/null \
259+
|| dotnet tool update -g dotnet-reportgenerator-globaltool 2>/dev/null || true
260+
# Ensure the dotnet global-tools directory is on PATH for this session.
261+
export PATH="$PATH:$HOME/.dotnet/tools"
262+
if command -v cygpath &>/dev/null && [ -n "${USERPROFILE:-}" ]; then
263+
export PATH="$PATH:$(cygpath -u "$USERPROFILE")/.dotnet/tools"
264+
fi
265+
fi
266+
267+
if command -v reportgenerator &>/dev/null; then
268+
step "COVERAGE — generating report"
269+
mkdir -p "$COVERAGE_DIR/report"
270+
# Same report types as .github/workflows/test.yml so local output matches CI:
271+
# HTML (openable offline), Cobertura, a text summary, and the GitHub markdown
272+
# summary that CI posts as the sticky PR comment.
273+
reportgenerator "-reports:$reports" \
274+
"-targetdir:$COVERAGE_DIR/report" \
275+
"-reporttypes:HtmlInline;Cobertura;TextSummary;MarkdownSummaryGithub" 2>/dev/null
276+
cat "$COVERAGE_DIR/report/Summary.txt" 2>/dev/null || true
277+
[ -f "$COVERAGE_DIR/report/SummaryGithub.md" ] \
278+
&& success "Markdown summary: $COVERAGE_DIR/report/SummaryGithub.md"
279+
[ -f "$COVERAGE_DIR/report/index.html" ] \
280+
&& success "HTML report: $COVERAGE_DIR/report/index.html"
281+
else
282+
warn "reportgenerator unavailable even after install attempt; skipping coverage report."
283+
warn "Install manually: dotnet tool install -g dotnet-reportgenerator-globaltool"
284+
fi
262285
fi
263286

264287
if [ "$any_failed" = true ]; then

0 commit comments

Comments
 (0)