Files
gitea-ci-library/.gitea/scripts/bats-report.sh
T
moilanik fa4af77877
CI / load-config (push) Failing after 0s
CI / feature (push) Has been skipped
CI / main (push) Has been skipped
feat: refactor config flow and directory structure
- Create config-provider.yml (reusable workflow, conf→JSON)
- Replace duplicated job env blocks with workflow env + fromJson
- Move provider workflows to workflows/ directory
- Move consumer scripts to .gitea/scripts/
- Move feature-env.conf to .gitea/workflows/
- Add bats-report.sh for TAP→HTML conversion
- Update ci.yml with setup→needs→with pattern
- Add ADR 0006 directory ownership
- Document cross-job config propagation in ci-pipeline-practices.md
- Remove config.yaml, scripts/load-config.sh unused
2026-06-13 15:18:02 +03:00

37 lines
1.4 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
REPORT_DIR="${1:-reports/bats}"
INPUT="$REPORT_DIR/results.txt"
OUTPUT="$REPORT_DIR/index.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 '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
echo "<title>Bats test report ${GITHUB_SHA:0:8}</title>"
echo '<style>body{font-family:sans-serif;margin:2em;max-width:960px}'
echo 'h1{color:#1e293b}.pass{color:#059669}.fail{color:#dc2626}'
echo 'table{width:100%;border-collapse:collapse;margin-top:1em}'
echo 'th,td{border:1px solid #e2e8f0;padding:8px;text-align:left}'
echo 'th{background:#f8fafc}</style></head><body>'
echo "<h1>Bats test report <code>${GITHUB_SHA:0:8}</code></h1>"
echo "<p>Total: ${TOTAL} | Passed: <span class='pass'>${PASS}</span> | Failed: <span class='fail'>${FAIL}</span></p>"
echo '<table><tr><th>#</th><th>Status</th><th>Test</th></tr>'
while IFS=' ' read -r status num rest; do
case "$status" in
ok) echo "<tr><td>${num}</td><td class='pass'>PASS</td><td>${rest}</td></tr>" ;;
not) echo "<tr><td>${num}</td><td class='fail'>FAIL</td><td>${rest}</td></tr>" ;;
esac
done < <(grep -E '^(ok|not ok) ' "$INPUT")
echo '</table></body></html>'
} > "$OUTPUT"
echo "$OUTPUT"