#!/usr/bin/env bash # # 回归闸门:CI 与本地跑的是**同一份**,避免「CI 挂了、本地不知道怎么复现」。 # # 守的三条就是 CLAUDE.md 里的铁律,不多不少: # 1. 全量测试必须带 --features secure(不带会漏掉 36 条,其中曾有坏的) # 2. 零 rustc 告警(-Dwarnings,warning 直接变 error) # 3. nax-core 必须能 no_std 编译(TEE / armv7 那条路) # # 用法:tools/ci.sh 正常跑 # tools/ci.sh --fast 跳过测试,只编译(改完想快速确认能编过时用) # set -euo pipefail cd "$(dirname "$0")/.." FAST=0 for a in "$@"; do case "$a" in --fast) FAST=1 ;; -h|--help) sed -n '2,12p' "$0"; exit 0 ;; *) echo "不认识的参数: $a" >&2; exit 2 ;; esac done step() { printf '\n\033[1m== %s ==\033[0m\n' "$1"; } ok() { printf '\033[32m ok\033[0m\n'; } if [ "$FAST" -eq 0 ]; then step "1/3 全量测试(含 secure 特性)" cargo test --workspace --features secure ok fi step "2/3 零告警构建(所有目标)" # -Dwarnings 同时作用于本地 crate 的 test / bench / example 目标, # 所以「测试代码里有 unused」也会被拦下 —— 这正是想要的。 RUSTFLAGS="${RUSTFLAGS:+${RUSTFLAGS} }-Dwarnings" \ cargo build --workspace --all-targets --features secure ok step "3/3 nax-core no_std 守线" cargo build -p nax-core --no-default-features ok printf '\n\033[32m\033[1m全部通过\033[0m\n'