pipeline siivous ja testikattavuuden nosto (#9)
Co-authored-by: moilanik <niko.moilanen@tietoevry.com> Reviewed-on: #9
This commit is contained in:
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
WORKSPACE_VOLUME="${1:-}"
|
||||
REPORT_DIR="${2:-}"
|
||||
|
||||
[ -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"
|
||||
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
|
||||
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"
|
||||
Reference in New Issue
Block a user