#!/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) echo "DEBUG[ci-report]: REPORT_DIR=$REPORT_DIR" >&2 echo "DEBUG[ci-report]: files found (${#FILES[@]}): ${FILES[*]:-}" >&2 echo "DEBUG[ci-report]: subdirs with index.html (${#SUBDIRS[@]}): ${SUBDIRS[*]:-}" >&2 echo "DEBUG[ci-report]: TOTAL=$(( ${#FILES[@]} + ${#SUBDIRS[@]} ))" >&2 echo "DEBUG[ci-report]: ls -la $REPORT_DIR/:" >&2 find "$REPORT_DIR" -maxdepth 2 -not -path '*/\.*' 2>/dev/null | while IFS= read -r p; do if [ -f "$p" ]; then echo " FILE $(basename "$p")" >&2 elif [ -d "$p" ] && [ "$p" != "$REPORT_DIR" ]; then echo " DIR $(basename "$p")/ has-index.html=$([ -f "$p/index.html" ] && echo YES || echo NO)" >&2 fi done 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='
' html+="