Add reports index generation
This commit is contained in:
parent
6a5003ffda
commit
0d332dfe85
2 changed files with 73 additions and 1 deletions
|
|
@ -27,7 +27,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li>Script: <code>scripts/run-test-suite.sh</code></li>
|
<li>Script: <code>scripts/run-test-suite.sh</code></li>
|
||||||
<li>Runs: <code>npm audit</code> (high), Trivy fs scan, ZAP baseline.</li>
|
<li>Runs: <code>npm audit</code> (high), Trivy fs scan, ZAP baseline.</li>
|
||||||
<li>Outputs: <code>reports/runs/<timestamp>/summary.html</code> with links to all tool reports and a textual summary printed to the console.</li>
|
<li>Outputs: <code>reports/runs/<timestamp>/summary.html</code> with links to all tool reports and a textual summary printed to the console. Index of all runs: <code>reports/index.html</code>.</li>
|
||||||
<li>Config:
|
<li>Config:
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>TARGET</code>: ZAP target URL (default test env).</li>
|
<li><code>TARGET</code>: ZAP target URL (default test env).</li>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ mkdir -p "$RUN_DIR"
|
||||||
|
|
||||||
SUMMARY_ROWS=()
|
SUMMARY_ROWS=()
|
||||||
SUMMARY_TEXT_ROWS=()
|
SUMMARY_TEXT_ROWS=()
|
||||||
|
PASS_COUNT=0
|
||||||
|
FAIL_COUNT=0
|
||||||
|
SKIP_COUNT=0
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
echo "[$(date +"%H:%M:%S")] $*"
|
echo "[$(date +"%H:%M:%S")] $*"
|
||||||
|
|
@ -34,6 +37,64 @@ record_result() {
|
||||||
local detail_text="$1"; shift
|
local detail_text="$1"; shift
|
||||||
SUMMARY_ROWS+=("<tr><td>${name}</td><td>${status}</td><td>${detail}</td></tr>")
|
SUMMARY_ROWS+=("<tr><td>${name}</td><td>${status}</td><td>${detail}</td></tr>")
|
||||||
SUMMARY_TEXT_ROWS+=("${name}: ${status}${detail_text:+ - ${detail_text}}")
|
SUMMARY_TEXT_ROWS+=("${name}: ${status}${detail_text:+ - ${detail_text}}")
|
||||||
|
case "$status" in
|
||||||
|
PASS) PASS_COUNT=$((PASS_COUNT + 1)) ;;
|
||||||
|
FAIL) FAIL_COUNT=$((FAIL_COUNT + 1)) ;;
|
||||||
|
SKIP) SKIP_COUNT=$((SKIP_COUNT + 1)) ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
update_index() {
|
||||||
|
local runs_dir="reports/runs"
|
||||||
|
local index_file="reports/index.html"
|
||||||
|
local items=""
|
||||||
|
|
||||||
|
if [ -d "$runs_dir" ]; then
|
||||||
|
while IFS= read -r run_dir; do
|
||||||
|
local meta_file="${runs_dir}/${run_dir}/meta.txt"
|
||||||
|
[ -f "$meta_file" ] || continue
|
||||||
|
|
||||||
|
local run_ts target pass fail skip
|
||||||
|
run_ts=$(grep -E '^RUN_TS=' "$meta_file" | head -n1 | cut -d= -f2-)
|
||||||
|
target=$(grep -E '^TARGET=' "$meta_file" | head -n1 | cut -d= -f2-)
|
||||||
|
pass=$(grep -E '^PASS_COUNT=' "$meta_file" | head -n1 | cut -d= -f2-)
|
||||||
|
fail=$(grep -E '^FAIL_COUNT=' "$meta_file" | head -n1 | cut -d= -f2-)
|
||||||
|
skip=$(grep -E '^SKIP_COUNT=' "$meta_file" | head -n1 | cut -d= -f2-)
|
||||||
|
|
||||||
|
run_ts="${run_ts:-$run_dir}"
|
||||||
|
target="${target:-unknown}"
|
||||||
|
pass="${pass:-0}"
|
||||||
|
fail="${fail:-0}"
|
||||||
|
skip="${skip:-0}"
|
||||||
|
|
||||||
|
items+=$'\n'" <li><div class=\"run\"><a href=\"runs/${run_ts}/summary.html\">${run_ts}</a></div><div class=\"meta\">Target: ${target} | Pass: ${pass} | Fail: ${fail} | Skip: ${skip}</div></li>"
|
||||||
|
done < <(ls "$runs_dir" 2>/dev/null | sort -r)
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >"$index_file" <<EOF
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Lomavuokraus Test Suite Runs</title>
|
||||||
|
<style>
|
||||||
|
body { font-family: Arial, sans-serif; padding: 16px; background: #0b0d11; color: #e9ecf1; }
|
||||||
|
a { color: #7cc7ff; text-decoration: none; }
|
||||||
|
a:hover { text-decoration: underline; }
|
||||||
|
ul { list-style: none; padding: 0; }
|
||||||
|
li { margin-bottom: 10px; padding: 10px; border: 1px solid #1f2937; border-radius: 6px; background: #111827; }
|
||||||
|
.run { font-weight: bold; }
|
||||||
|
.meta { font-size: 0.95em; color: #cfd6e0; margin-top: 2px; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Test Suite Runs</h1>
|
||||||
|
<ul>
|
||||||
|
${items:-" <li>No runs found.</li>"}
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# 1) npm audit
|
# 1) npm audit
|
||||||
|
|
@ -137,6 +198,17 @@ cat >"$SUMMARY_FILE" <<EOF
|
||||||
</html>
|
</html>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
META_FILE="$RUN_DIR/meta.txt"
|
||||||
|
cat >"$META_FILE" <<EOF
|
||||||
|
RUN_TS=${RUN_TS}
|
||||||
|
TARGET=${TARGET}
|
||||||
|
PASS_COUNT=${PASS_COUNT}
|
||||||
|
FAIL_COUNT=${FAIL_COUNT}
|
||||||
|
SKIP_COUNT=${SKIP_COUNT}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
update_index
|
||||||
|
|
||||||
log "Summary:"
|
log "Summary:"
|
||||||
for row in "${SUMMARY_TEXT_ROWS[@]}"; do
|
for row in "${SUMMARY_TEXT_ROWS[@]}"; do
|
||||||
echo " - ${row}"
|
echo " - ${row}"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue