beads/scripts/migration-test/lib/report.sh
matt wilkie e4fca03f6b
feat: add migration test harness for cross-era upgrade fidelity (#3067)
* wip: add migration test harness for cross-era upgrade fidelity

Rich dataset generator, field-level fidelity checker, and migration
recipes for SQLite/Dolt-server/embedded-Dolt eras. Addresses GH#2938
upgrade pain by testing and documenting working upgrade paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: snapshot JSON format handling and self-test mode

- show --json returns array, not object — use jq array concatenation
- Field is issue_type not type in bd JSON output
- Normalize empty comment_count to 0 (show vs list field differences)
- Add --self-test flag for harness validation without old binaries
- Fix local variable outside function in self-test block

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: re-trigger Kilo Code Review

* address review: timeouts, env var docs, quoting

- Add BD_OP_TIMEOUT (30s) for bd operations via timeout(1)
- Add DOWNLOAD_TIMEOUT (60s) for curl binary downloads
- Document all environment variables in run.sh header
- Convert init_flags from word-split string to proper bash array

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: fall back to source build when release binary has missing shared libs

Downloaded release binaries dynamically link ICU (libicui18n.so.74),
which isn't available on all systems. Now download_binary verifies the
binary actually runs, and falls back to building from source with
gms_pure_go tag when it doesn't. Also applies gms_pure_go to
build_candidate for consistency.

Ref: gastownhall/beads#3065

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 14:30:35 -07:00

144 lines
4.8 KiB
Bash
Executable file

#!/bin/bash
# Results tracking and report generation.
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BOLD='\033[1m'
NC='\033[0m'
# Parallel arrays for tracking results
declare -a RESULT_PATHS=()
declare -a RESULT_STATUSES=() # AUTO, MANUAL, BLOCKED, SKIP
declare -a RESULT_DETAILS=()
declare -a RESULT_RECIPES=() # recipe name if MANUAL
declare -a RESULT_VIOLATIONS=() # fidelity violation count
record_result() {
local path="$1" # e.g. "v0.49.6 → candidate" or "v0.49.6 → v0.57.0 → candidate"
local status="$2" # AUTO, MANUAL, BLOCKED, SKIP
local detail="$3" # human-readable detail
local recipe="${4:-}"
local violations="${5:-0}"
RESULT_PATHS+=("$path")
RESULT_STATUSES+=("$status")
RESULT_DETAILS+=("$detail")
RESULT_RECIPES+=("$recipe")
RESULT_VIOLATIONS+=("$violations")
}
print_results_table() {
echo ""
echo -e "${BOLD}Migration Test Results${NC}"
echo ""
printf "%-40s %-8s %-4s %s\n" "Upgrade Path" "Status" "Viol" "Detail"
printf "%-40s %-8s %-4s %s\n" "------------" "------" "----" "------"
for i in "${!RESULT_PATHS[@]}"; do
local path="${RESULT_PATHS[$i]}"
local status="${RESULT_STATUSES[$i]}"
local detail="${RESULT_DETAILS[$i]}"
local violations="${RESULT_VIOLATIONS[$i]}"
case "$status" in
AUTO) printf "%-40s ${GREEN}%-8s${NC} %-4s %s\n" "$path" "$status" "$violations" "$detail" ;;
MANUAL) printf "%-40s ${YELLOW}%-8s${NC} %-4s %s\n" "$path" "$status" "$violations" "$detail" ;;
BLOCKED) printf "%-40s ${RED}%-8s${NC} %-4s %s\n" "$path" "$status" "$violations" "$detail" ;;
SKIP) printf "%-40s ${YELLOW}%-8s${NC} %-4s %s\n" "$path" "$status" "$violations" "$detail" ;;
esac
done
}
# Print stepping-stone instructions for paths that need manual steps.
print_upgrade_instructions() {
local has_manual=false
for i in "${!RESULT_STATUSES[@]}"; do
if [ "${RESULT_STATUSES[$i]}" = "MANUAL" ]; then
has_manual=true
break
fi
done
if ! $has_manual; then return; fi
echo ""
echo -e "${BOLD}Upgrade Instructions${NC}"
echo ""
for i in "${!RESULT_PATHS[@]}"; do
local status="${RESULT_STATUSES[$i]}"
[ "$status" != "MANUAL" ] && continue
local path="${RESULT_PATHS[$i]}"
local recipe="${RESULT_RECIPES[$i]}"
local detail="${RESULT_DETAILS[$i]}"
echo -e " ${YELLOW}${path}${NC}"
echo " Recipe: $recipe"
echo " Detail: $detail"
echo ""
done
}
# GitHub Actions markdown summary
print_ci_summary() {
if [ -z "${GITHUB_STEP_SUMMARY:-}" ]; then
return
fi
local auto=0 manual=0 blocked=0 skip=0
for status in "${RESULT_STATUSES[@]}"; do
case "$status" in
AUTO) auto=$((auto + 1)) ;;
MANUAL) manual=$((manual + 1)) ;;
BLOCKED) blocked=$((blocked + 1)) ;;
SKIP) skip=$((skip + 1)) ;;
esac
done
{
echo "## Migration Test Results"
echo ""
echo "| Upgrade Path | Status | Violations | Detail |"
echo "|---|---|---|---|"
for i in "${!RESULT_PATHS[@]}"; do
local path="${RESULT_PATHS[$i]}"
local status="${RESULT_STATUSES[$i]}"
local detail="${RESULT_DETAILS[$i]}"
local violations="${RESULT_VIOLATIONS[$i]}"
local icon=""
case "$status" in
AUTO) icon="✅" ;;
MANUAL) icon="🔧" ;;
BLOCKED) icon="❌" ;;
SKIP) icon="⏭️" ;;
esac
echo "| ${path} | ${icon} ${status} | ${violations} | ${detail} |"
done
echo ""
echo "**${auto} auto, ${manual} manual, ${blocked} blocked, ${skip} skipped**"
} >> "$GITHUB_STEP_SUMMARY"
}
print_summary_line() {
local auto=0 manual=0 blocked=0 skip=0
for status in "${RESULT_STATUSES[@]}"; do
case "$status" in
AUTO) auto=$((auto + 1)) ;;
MANUAL) manual=$((manual + 1)) ;;
BLOCKED) blocked=$((blocked + 1)) ;;
SKIP) skip=$((skip + 1)) ;;
esac
done
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
local total=$((auto + manual + blocked + skip))
if [ "$blocked" -eq 0 ]; then
echo -e " ${GREEN}${auto} auto${NC}, ${YELLOW}${manual} manual${NC}, ${blocked} blocked, ${skip} skipped (of ${total})"
else
echo -e " ${auto} auto, ${manual} manual, ${RED}${blocked} BLOCKED${NC}, ${skip} skipped (of ${total})"
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
}