#!/usr/bin/env bash
set -euo pipefail
repo_root=$(git rev-parse --show-toplevel)
mapfile -t scripts < <(find "$repo_root/modules/ci" -type f -name '*.sh' -print | sort)
for script in "${scripts[@]}"; do bash -n "$script"; done
echo "bash syntax: PASS (${#scripts[@]} scripts)"
bash "$repo_root/modules/ci/tests/cache-key.test.sh"
bash "$repo_root/modules/ci/tests/install-arc.test.sh"
bash "$repo_root/modules/ci/tests/runner-image.test.sh"
if command -v kubeconform >/dev/null; then
  kubeconform -strict -summary "$repo_root/modules/ci/k8s"/*.yaml
elif command -v bun >/dev/null; then
  bun "$repo_root/modules/ci/tests/manifest.test.ts"
else
  echo "manifest validation unavailable: install kubeconform or Bun" >&2
  exit 2
fi
