#!/usr/bin/env bash set -euo pipefail REPORT_DIR="${1:-reports/bats}" INPUT="$REPORT_DIR/results.txt" OUTPUT="$REPORT_DIR/test-report.html" [ -f "$INPUT" ] || { echo "ERROR: $INPUT not found" >&2; exit 1; } TOTAL=$(grep -cE '^(ok|not ok) ' "$INPUT" 2>/dev/null || echo 0) PASS=$(grep -c '^ok ' "$INPUT" 2>/dev/null || echo 0) FAIL=$((TOTAL - PASS)) { echo '' echo "Bats test report ${GITHUB_SHA:0:8}" echo '' echo "

Bats test report ${GITHUB_SHA:0:8}

" echo "

Total: ${TOTAL} | Passed: ${PASS} | Failed: ${FAIL}

" echo '' while IFS=' ' read -r status num rest; do case "$status" in ok) echo "" ;; not) echo "" ;; esac done < <(grep -E '^(ok|not ok) ' "$INPUT") echo '
#StatusTest
${num}PASS${rest}
${num}FAIL${rest}
' } > "$OUTPUT" echo "$OUTPUT"