Feature/yksinkertaistetaan raportointi logiikkaa (#22)
unit-tests Bats test report
CI Main / Bats tests (push) Successful in 1m21s
ci-docker-build-push Docker build & push 0.2.9 OK
CI Main / Build & Push Docker (push) Successful in 40s
CI Main / Report Summary (push) Successful in 5s
CI Main / Move provider version tag (push) Successful in 12s
CI Main / Load example-gitea-env.conf to pipeline env (push) Successful in 18s
CI Main / Check existing artifact (push) Successful in 12s
acc-tests Cucumber test report
CI Main / Cucumber tests (push) Successful in 2m3s

Co-authored-by: moilanik <niko.moilanen@tietoevry.com>
Reviewed-on: #22
This commit was merged in pull request #22.
This commit is contained in:
2026-06-18 12:55:02 +03:00
parent 65d385f9b9
commit 737b2fc3f2
11 changed files with 357 additions and 180 deletions
+86
View File
@@ -0,0 +1,86 @@
#!/usr/bin/env bash
set -euo pipefail
DESCRIPTION="${1:-}"
CONTEXT="${2:-}"
SUITE="${3:-}"
[ -n "$DESCRIPTION" ] || { echo "ERROR: description argument required" >&2; exit 1; }
[ -n "$CONTEXT" ] || { echo "ERROR: context argument required" >&2; exit 1; }
[ -n "$SUITE" ] || { echo "ERROR: suite argument required" >&2; exit 1; }
REPORT_DIR="reports/${SUITE}"
if [ ! -d "$REPORT_DIR" ]; then
echo "ERROR: $REPORT_DIR not found" >&2
bash .ci/scripts/report-status.sh failure "$DESCRIPTION" "$CONTEXT"
exit 1
fi
FILES=()
while IFS= read -r -d '' f; do
FILES+=("$(basename "$f")")
done < <(find "$REPORT_DIR" -maxdepth 1 -type f ! -name index.html -print0 2>/dev/null || true)
SUBDIRS=()
while IFS= read -r -d '' d; do
name="${d#$REPORT_DIR/}"
[ -f "$d/index.html" ] && SUBDIRS+=("$name")
done < <(find "$REPORT_DIR" -maxdepth 1 -type d ! -name . -print0 2>/dev/null || true)
TOTAL=$(( ${#FILES[@]} + ${#SUBDIRS[@]} ))
if [ "$TOTAL" -eq 0 ]; then
echo "ERROR: no reportable items in $REPORT_DIR" >&2
bash .ci/scripts/report-status.sh failure "$DESCRIPTION" "$CONTEXT"
exit 1
fi
SHA8="${GITHUB_SHA:0:8}"
humanize() {
local name="$1"
name="${name%.*}"
name="${name//-/ }"
name="${name//_/ }"
echo "${name^}"
}
generate_index() {
local html
html='<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
html+="<title>$DESCRIPTION</title>"
html+='<style>body{font-family:sans-serif;margin:2em;max-width:960px}h1{color:#1e293b}ul{list-style:none;padding:0}li{margin:.5em 0;padding:.5em;background:#f8fafc;border-radius:6px}a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}</style>'
html+="</head><body><h1>$DESCRIPTION</h1><ul>"
for f in "${FILES[@]}"; do
html+="<li><a href=\"$f\">$(humanize "$f")</a></li>"
done
for d in "${SUBDIRS[@]}"; do
html+="<li><a href=\"$d/index.html\">${d^}</a></li>"
done
html+='</ul></body></html>'
printf '%s' "$html" > "$REPORT_DIR/index.html"
}
STAGED="reports/${SHA8}/${SUITE}"
mkdir -p "$STAGED"
if [ "$TOTAL" -eq 1 ]; then
cp -a "$REPORT_DIR/." "$STAGED/"
bash .ci/scripts/publish-git-pages.sh "$SUITE"
if [ ${#FILES[@]} -eq 1 ]; then
ENTRY="${FILES[0]}"
else
ENTRY="${SUBDIRS[0]}/index.html"
fi
URL="${GIT_PAGES_URL}/${GITHUB_REPOSITORY}/reports/${SHA8}/${SUITE}/${ENTRY}"
bash .ci/scripts/report-status.sh success "$DESCRIPTION" "$CONTEXT" "" "$URL"
else
generate_index
cp -a "$REPORT_DIR/." "$STAGED/"
bash .ci/scripts/publish-git-pages.sh "$SUITE"
bash .ci/scripts/report-status.sh success "$DESCRIPTION" "$CONTEXT" "$SUITE"
fi
rm -rf "$STAGED"
+36 -1
View File
@@ -33,7 +33,42 @@ else
fi
mkdir -p "$TARGET"
cp -a "$REPORT_DIR/." "$TARGET/"
cat > "$WORK/${OWNER}/${REPO}/reports/${SHA8}/.meta" <<EOF
if [ ! -f "$TARGET/index.html" ]; then
items=()
while IFS= read -r -d '' f; do
items+=("$(basename "$f")")
done < <(find "$TARGET" -maxdepth 1 -type f ! -name index.html -print0 2>/dev/null || true)
while IFS= read -r -d '' d; do
name=$(basename "$d")
[ -f "$d/index.html" ] && items+=("$name")
done < <(find "$TARGET" -maxdepth 1 -type d ! -name . -print0 2>/dev/null || true)
if [ ${#items[@]} -gt 1 ]; then
{
echo '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
echo "<title>Test report ${SHA8}</title>"
echo '<style>body{font-family:sans-serif;margin:2em;max-width:960px}'
echo 'h1{color:#1e293b}ul{list-style:none;padding:0}'
echo 'li{margin:.5em 0;padding:.5em;background:#f8fafc;border-radius:6px}'
echo 'a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}'
echo '</style></head><body>'
echo "<h1>Test report <code>${SHA8}</code></h1><ul>"
for item in "${items[@]}"; do
label="${item%.*}"
label="${label//-/ }"
label="${label//_/ }"
if [ -f "$TARGET/$item" ]; then
echo "<li><a href=\"$item\">${label^}</a></li>"
else
echo "<li><a href=\"$item/index.html\">${label^}</a></li>"
fi
done
echo '</ul></body></html>'
} > "$TARGET/index.html"
fi
fi
cat > "$TARGET/.meta" <<EOF
{"branch":"${GITHUB_REF_NAME:-}","sha":"${GITHUB_SHA}","published_at":"$(date -u +%Y-%m-%dT%H:%M:%SZ)"}
EOF
find "$WORK/$OWNER" \( -type f -o -type l \) -print | sed "s|^${WORK}/||" | tar -cf "$TAR" -C "$WORK" -T -