Skip to content

feat(reports): --report-md and automatic $GITHUB_STEP_SUMMARY output #1015

Description

@Chemaclass

Problem

Every existing report format targets a machine: JUnit XML, TAP, JSON, LCOV, plus an HTML file that has to be uploaded as an artifact and downloaded to be read. There is no format aimed at the place a developer actually looks first — the pull request page.

GitHub Actions renders anything appended to $GITHUB_STEP_SUMMARY as Markdown directly on the job page. GitLab and Azure have equivalent surfaces that consume Markdown.

Proposal

--report-md <file>    Write a Markdown summary

Plus: when GITHUB_STEP_SUMMARY is set and no explicit path is given, append the summary there automatically (same auto-detect posture as the annotations issue).

Content, in order:

  1. One-line verdict: ✅ 412 passed / ❌ 3 failed, 409 passed with total duration.
  2. A counts table (passed / failed / skipped / incomplete / risky / snapshot, and flaky if that lands).
  3. A failures section: test name, file:line, and the failure message in a fenced block — this is the part that saves a click into the raw log.
  4. Coverage percentage when --coverage ran.
  5. Slowest tests when --profile is on (BASHUNIT_PROFILE_COUNT, default 10).

ANSI must be stripped (bashunit::reports::__strip_ansi, src/reports/collect.sh:9) and Markdown special characters escaped in test names.

Where to change

Acceptance criteria

  • --report-md out.md writes a valid Markdown file
  • With GITHUB_STEP_SUMMARY set and no flag, the summary is appended (not truncated) to that file
  • Failure messages appear inside fenced code blocks with ANSI stripped
  • Test names containing |, *, _ or backticks do not break the table
  • Coverage percentage appears only when coverage ran
  • Slowest-tests section appears only with --profile
  • A fully passing run produces a short summary with no failures section
  • Report is populated under --parallel (regression guard for fix(reports): every report format is empty under --parallel #1004)
  • --report-md /unwritable/path fails fast with a clear error (A missing --env bootstrap or an unwritable report path fails silently and exits 0 #875)
  • Unit tests in tests/unit/reports/ plus an acceptance test

Repo checklist (agent)

  • TDD: RED → GREEN → REFACTOR. Write the failing test first.
  • Bash 3.0+ only: no printf -v, no += append, no declare -A, no [[ ]], no ${var,,}, no &>>, no ${arr[-1]}. Expanding a possibly-empty array under set -u needs ${arr[@]+"${arr[@]}"}.
  • A new CLI flag must be wired in all of these or a parity test fails:
  • Gates: make sa, make lint, ./bashunit tests/, ./bashunit --parallel tests/. Never run shfmt -w.
  • Docs: update docs/command-line.md. Editing docs/assertions.md invalidates the bashunit doc acceptance snapshot — regenerate it.
  • CHANGELOG.md: add one line under ## Unreleased.
  • Fixtures under tests/acceptance/fixtures/ must not end in *test.sh.
  • One issue = one PR.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions