#!/usr/bin/env bash # verify.sh —— 一键验收(本仓只有业务,所以判据也只剩两类) # # 用法: # bash scripts/verify.sh # 全量:静态 + cargo test + 两把运行时尺子 # bash scripts/verify.sh --fast # 只静态 + cargo test(不起服务) # # 退出码:0 = 全绿 / 1 = 有步骤失败 # # 🔴 **为什么没有「平台对不对」的判据**:平台在已发布的 `sspf` 包里, # 它自己的 14 步验收在**平台仓**跑。本仓只证明两件事: # ① 本仓没有把平台抄回来(`check-scaffold.py`,6 条 + 反自证 6/6); # ② 业务是真的能跑(`cargo test` + 面 A / 面 B 两把运行时尺子)。 # # 🔴 运行时尺子默认读 `target/release/ssw-jnpf-lite-rust` # ⇒ 改了源码**必须先** `cargo build --release`,否则打的是旧二进制。 # 本脚本在跑尺子前会自己 build 一次(省一次「假绿」)。 set -u ROOT="$(cd "$(dirname "$0")/.." && pwd)" MODE="full" if [ "${1:-}" = "--fast" ]; then MODE="fast" elif [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then sed -n '2,14p' "$0" | sed 's/^# \{0,1\}//' exit 0 elif [ -n "${1:-}" ]; then echo "未知参数:${1}(只认 --fast)" exit 2 fi PASS=0 FAIL=0 SLOW=() step() { local name="$1" shift local t0 t1 rc t0="$(python3 -c 'import time;print(int(time.time()*1000))')" echo echo "▶ ${name}" "$@" rc=$? t1="$(python3 -c 'import time;print(int(time.time()*1000))')" local ms=$((t1 - t0)) if [ "${rc}" -eq 0 ]; then PASS=$((PASS + 1)) echo " ✅ ${name}($((ms / 1000)).$(((ms % 1000) / 100))s)" else FAIL=$((FAIL + 1)) echo " ❌ ${name}($((ms / 1000)).$(((ms % 1000) / 100))s,rc=${rc})" fi SLOW+=("${ms}|${name}") } t_all0="$(python3 -c 'import time;print(int(time.time()*1000))')" # ---- 1. 生成物(加包忘了跑 pack-sync 会在这里红)---- step "pack-sync --check" python3 "${ROOT}/scripts/pack-sync.py" --check # ---- 2. 脚手架判据(本仓只准有业务)---- step "check-scaffold" python3 "${ROOT}/scripts/check-scaffold.py" # ---- 3. 反自证(尺子自己也得被尺子量)---- step "check-scaffold --self-test" python3 "${ROOT}/scripts/check-scaffold.py" --self-test # ---- 4. 全量测试 ---- step "cargo test --workspace" bash -c "cd '${ROOT}' && cargo test --workspace" if [ "${MODE}" = "full" ]; then # ---- 5. release 二进制(运行时尺子读它)---- step "cargo build --release" bash -c "cd '${ROOT}' && cargo build --release" # ---- 6. 面 A:权限闭环 ---- step "perm-smoke(面 A)" bash "${ROOT}/scripts/perm-smoke.sh" # ---- 7. 面 B:官方形状 ---- step "perm-smoke-jnpf(面 B)" bash "${ROOT}/scripts/perm-smoke-jnpf.sh" fi t_all1="$(python3 -c 'import time;print(int(time.time()*1000))')" TOTAL=$((t_all1 - t_all0)) echo echo "──────────────────────────────────────────" echo "总耗时 $((TOTAL / 1000)).$(((TOTAL % 1000) / 100))s(模式 ${MODE},$((PASS + FAIL)) 个步骤)" if [ "${FAIL}" -eq 0 ]; then echo echo "全 ✅ (${PASS}/${PASS})" exit 0 fi echo echo "有失败 ❌ (PASS=${PASS} FAIL=${FAIL})" exit 1