set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_step() {
echo -e "${BLUE}▶${NC} $1"
}
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1"
}
echo ""
echo "========================================="
echo " pot-head - Local CI Verification"
echo "========================================="
echo ""
print_step "Checking code formatting..."
cargo fmt --all -- --check
print_success "Code formatting OK (main library)"
if [ -d "examples/filtering" ]; then
print_step " Checking filtering example formatting..."
(cd examples/filtering && cargo fmt -- --check)
print_success " filtering formatting OK"
else
print_warning " filtering example not found, skipping"
fi
if [ -d "examples/interactive" ]; then
print_step " Checking interactive example formatting..."
(cd examples/interactive && cargo fmt -- --check)
print_success " interactive formatting OK"
else
print_warning " interactive example not found, skipping"
fi
if [ -d "tools/benchmark/rp2040" ]; then
print_step " Checking benchmark/rp2040 formatting..."
(cd tools/benchmark/rp2040 && cargo fmt -- --check)
print_success " benchmark/rp2040 formatting OK"
else
print_warning " benchmark/rp2040 not found, skipping"
fi
if [ -d "tools/benchmark/rp2350" ]; then
print_step " Checking benchmark/rp2350 formatting..."
(cd tools/benchmark/rp2350 && cargo fmt -- --check)
print_success " benchmark/rp2350 formatting OK"
else
print_warning " benchmark/rp2350 not found, skipping"
fi
if [ -d "tools/binary-analyzer/test-binary" ]; then
print_step " Checking binary-analyzer/test-binary formatting..."
(cd tools/binary-analyzer/test-binary && cargo fmt -- --check)
print_success " binary-analyzer/test-binary formatting OK"
else
print_warning " binary-analyzer/test-binary not found, skipping"
fi
if [ -d "tools/sizeof-calculator" ]; then
print_step " Checking sizeof-calculator formatting..."
(cd tools/sizeof-calculator && cargo fmt -- --check)
print_success " sizeof-calculator formatting OK"
else
print_warning " sizeof-calculator not found, skipping"
fi
echo ""
print_step "Running Clippy (no default features)..."
cargo clippy --lib --no-default-features -- -D warnings
print_success "Clippy passed (no features)"
echo ""
print_step "Running Clippy (all features)..."
cargo clippy --lib --all-features -- -D warnings
print_success "Clippy passed (all features)"
echo ""
print_step "Running tests (no default features)..."
cargo test --no-default-features
print_success "Tests passed (no features)"
echo ""
print_step "Building documentation (all features)..."
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
print_success "Documentation built successfully"
echo ""
print_step "Building documentation (no default features)..."
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --no-default-features
print_success "Documentation built successfully"
echo ""
print_step "Checking no_std compatibility..."
if rustup target list --installed | grep -q "thumbv6m-none-eabi"; then
print_step " Building for thumbv6m-none-eabi (no FPU)..."
cargo build --target thumbv6m-none-eabi --lib --release --no-default-features
print_success " no_std build OK (no features)"
cargo build --target thumbv6m-none-eabi --lib --release --no-default-features --features "std-math"
print_success " no_std build OK (std-math)"
cargo build --target thumbv6m-none-eabi --lib --release --no-default-features --features "moving-average"
print_success " no_std build OK (moving-average)"
cargo build --target thumbv6m-none-eabi --lib --release --no-default-features --features "grab-mode"
print_success " no_std build OK (grab-mode)"
else
print_warning " thumbv6m-none-eabi target not installed, skipping"
echo " Install with: rustup target add thumbv6m-none-eabi"
fi
if rustup target list --installed | grep -q "thumbv7em-none-eabihf"; then
print_step " Building for thumbv7em-none-eabihf (with FPU)..."
cargo build --target thumbv7em-none-eabihf --lib --release --no-default-features
print_success " no_std build OK (no features)"
cargo build --target thumbv7em-none-eabihf --lib --release --no-default-features --features "std-math"
print_success " no_std build OK (std-math)"
cargo build --target thumbv7em-none-eabihf --lib --release --no-default-features --features "moving-average"
print_success " no_std build OK (moving-average)"
cargo build --target thumbv7em-none-eabihf --lib --release --no-default-features --features "grab-mode"
print_success " no_std build OK (grab-mode)"
else
print_warning " thumbv7em-none-eabihf target not installed, skipping"
echo " Install with: rustup target add thumbv7em-none-eabihf"
fi
echo ""
print_step "Building example: filtering..."
if [ -d "examples/filtering" ]; then
(cd examples/filtering && cargo build --release)
print_success "filtering example built"
else
print_warning "filtering example not found, skipping"
fi
echo ""
print_step "Building example: interactive..."
if [ -d "examples/interactive" ]; then
(cd examples/interactive && cargo build --release)
print_success "interactive example built"
else
print_warning "interactive example not found, skipping"
fi
echo ""
print_step "Checking git status..."
if [ -n "$(git status --porcelain)" ]; then
print_warning "There are uncommitted changes:"
git status --short
else
print_success "No uncommitted changes"
fi
echo ""
echo "========================================="
echo -e "${GREEN}✓ All CI checks passed!${NC}"
echo "========================================="
echo ""
echo "You can now push your changes with confidence."
echo ""