Files
ai-passport/tools/validate.sh
T

64 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
mode="${1:---all}"
repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
usage() {
echo "Usage: $0 [--all|--static|--firmware]" >&2
}
run_static_checks() {
local actionlint_bin
local test_dir
python3 tools/check_repo.py
actionlint_bin="${ACTIONLINT_BIN:-}"
if [[ -z "${actionlint_bin}" ]]; then
actionlint_bin="$(command -v actionlint || true)"
fi
if [[ -z "${actionlint_bin}" || ! -x "${actionlint_bin}" ]]; then
actionlint_bin="$(./tools/install-actionlint.sh)"
fi
"${actionlint_bin}" -color .github/workflows/*.yml
test_dir="$(mktemp -d /tmp/ai-passport-host-tests.XXXXXX)"
"${CC:-cc}" -std=c11 -Wall -Wextra -Werror -Imain \
tests/test_ui_pixel_math.c main/ui_pixel_math.c \
-o "${test_dir}/test_ui_pixel_math"
"${test_dir}/test_ui_pixel_math"
rm -rf "${test_dir}"
echo "Host tests: PASS"
}
run_firmware_checks() {
if ! command -v idf.py >/dev/null 2>&1; then
echo "ERROR: idf.py is not available; activate ESP-IDF 5.5.3 first." >&2
return 1
fi
idf.py -D SDKCONFIG_DEFAULTS=sdkconfig.defaults build
idf.py merge-bin -o "${repo_root}/build/FoloToy-AI-Passport-full.bin"
python3 tools/verify_firmware.py build
echo "Firmware build: PASS"
}
cd "${repo_root}"
case "${mode}" in
--all)
run_static_checks
run_firmware_checks
;;
--static)
run_static_checks
;;
--firmware)
run_firmware_checks
;;
*)
usage
exit 2
;;
esac