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
+20 -28
View File
@@ -1,37 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
WORKSPACE_VOLUME="${1:-}"
REPORT_DIR="${2:-}"
REPORT_DIR="${1:-}"
COVERAGE_DIR="${REPORT_DIR}/coverage"
[ -n "$WORKSPACE_VOLUME" ] || { echo "ERROR: workspace volume name required" >&2; exit 1; }
[ -n "$REPORT_DIR" ] || { echo "ERROR: report directory required" >&2; exit 1; }
HAS_COVERAGE=false
COVERAGE_SRC=""
if docker run --rm -v "$WORKSPACE_VOLUME":/data alpine sh -c '[ -d /data/coverage ] && ls -A /data/coverage | grep -q .' 2>/dev/null; then
COVERAGE_SRC="/data/coverage"
if [ -d coverage ]; then
mkdir -p "$COVERAGE_DIR"
cp -a coverage/. "$COVERAGE_DIR/"
fi
if [ -n "$COVERAGE_SRC" ]; then
mkdir -p "$REPORT_DIR/coverage"
docker run --rm -v "$WORKSPACE_VOLUME":/data alpine tar c -C "$COVERAGE_SRC" . | tar x -C "$REPORT_DIR/coverage"
HAS_COVERAGE=true
if [ -d "$COVERAGE_DIR" ] && [ ! -f "$COVERAGE_DIR/index.html" ]; then
SHA8="${GITHUB_SHA:0:8}"
{
echo '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
echo "<title>Coverage report ${SHA8}</title>"
echo '<style>body{font-family:sans-serif;margin:2em}h1{color:#1e293b}ul{list-style:none;padding:0}li{margin:.5em 0}a{color:#2563eb}</style>'
echo "</head><body><h1>Coverage report <code>${SHA8}</code></h1><ul>"
while IFS= read -r -d '' f; do
base=$(basename "$f")
name="${base%.*}"
name="${name//-/ }"
echo "<li><a href=\"${base}\">${name^}</a></li>"
done < <(find "$COVERAGE_DIR" -maxdepth 1 -type f \( -name '*.html' -o -name '*.txt' \) ! -name index.html -print0 2>/dev/null || true)
echo '</ul></body></html>'
} > "$COVERAGE_DIR/index.html"
fi
cat > "$REPORT_DIR/index.html" << EOF
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">
<title>Bats report ${GITHUB_SHA:0:8}</title>
<style>body{font-family:sans-serif;margin:2em;max-width:960px}
h1{color:#1e293b}a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}
</style></head><body>
<h1>Bats report <code>${GITHUB_SHA:0:8}</code></h1>
<ul>
<li><a href="test-report.html">Test results</a></li>
EOF
if [ "$HAS_COVERAGE" = true ]; then
echo '<li><a href="coverage/index.html">Coverage report</a></li>' >> "$REPORT_DIR/index.html"
fi
echo '</ul></body></html>' >> "$REPORT_DIR/index.html"