Feature/yksinkertaistetaan raportointi logiikkaa #22

Merged
niko merged 12 commits from feature/yksinkertaistetaan-raportointi-logiikkaa into main 2026-06-18 12:55:02 +03:00
Showing only changes of commit cf71134b75 - Show all commits
+19 -5
View File
@@ -1,21 +1,35 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
REPORT_DIR="${1:-}" COVERAGE_VOLUME="${2:+${1:-}}"
REPORT_DIR="${2:-${1:-}}"
[ -n "$REPORT_DIR" ] || { echo "ERROR: report directory required" >&2; exit 1; } [ -n "$REPORT_DIR" ] || { echo "ERROR: report directory required" >&2; exit 1; }
COVERAGE_DIR="$REPORT_DIR/coverage" COVERAGE_DIR="$REPORT_DIR/coverage"
echo "DEBUG[bats-coverage]: CWD=$(pwd)" >&2 if [ -n "$COVERAGE_VOLUME" ]; then
echo "DEBUG[bats-coverage]: coverage dir exists? $([ -d coverage ] && echo YES || echo NO)" >&2 echo "DEBUG[bats-coverage]: OLD convention — extracting from volume '$1' to '$REPORT_DIR'" >&2
if docker run --rm -v "$COVERAGE_VOLUME":/data alpine sh -c '
if [ -d coverage ]; then [ -d /data/coverage ] && ls -A /data/coverage | grep -q .
' 2>/dev/null; then
echo "DEBUG[bats-coverage]: coverage found in volume $COVERAGE_VOLUME" >&2
mkdir -p "$COVERAGE_DIR"
docker run --rm -v "$COVERAGE_VOLUME":/data alpine tar c -C /data/coverage . | tar x -C "$COVERAGE_DIR"
echo "DEBUG[bats-coverage]: extracted from volume to $COVERAGE_DIR" >&2
else
echo "DEBUG[bats-coverage]: no coverage in volume $COVERAGE_VOLUME" >&2
fi
else
echo "DEBUG[bats-coverage]: NEW convention — copying from ./coverage/ to '$REPORT_DIR'" >&2
echo "DEBUG[bats-coverage]: coverage dir exists? $([ -d coverage ] && echo YES || echo NO)" >&2
if [ -d coverage ]; then
echo "DEBUG[bats-coverage]: files in coverage/: $(ls coverage/ 2>/dev/null | wc -l)" >&2 echo "DEBUG[bats-coverage]: files in coverage/: $(ls coverage/ 2>/dev/null | wc -l)" >&2
echo "DEBUG[bats-coverage]: coverage/index.html exists? $([ -f coverage/index.html ] && echo YES || echo NO)" >&2 echo "DEBUG[bats-coverage]: coverage/index.html exists? $([ -f coverage/index.html ] && echo YES || echo NO)" >&2
mkdir -p "$COVERAGE_DIR" mkdir -p "$COVERAGE_DIR"
cp -a coverage/. "$COVERAGE_DIR/" cp -a coverage/. "$COVERAGE_DIR/"
echo "DEBUG[bats-coverage]: copied to $COVERAGE_DIR" >&2 echo "DEBUG[bats-coverage]: copied to $COVERAGE_DIR" >&2
fi
fi fi
echo "DEBUG[bats-coverage]: target $COVERAGE_DIR/index.html exists? $([ -f "$COVERAGE_DIR/index.html" ] && echo YES || echo NO)" >&2 echo "DEBUG[bats-coverage]: target $COVERAGE_DIR/index.html exists? $([ -f "$COVERAGE_DIR/index.html" ] && echo YES || echo NO)" >&2