set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo -e "${BLUE}NeoRust CI Checks${NC}"
echo "=================="
echo ""
if [ ! -f "Cargo.toml" ]; then
echo -e "${RED}Error: Not in NeoRust root directory${NC}"
exit 1
fi
missing_tools=()
for tool in cargo rustfmt; do
if ! command -v $tool &> /dev/null; then
missing_tools+=($tool)
fi
done
if [ ${#missing_tools[@]} -ne 0 ]; then
echo -e "${RED}Missing required tools: ${missing_tools[*]}${NC}"
echo "Please install Rust toolchain"
exit 1
fi
echo -e "${YELLOW}1. Format Check${NC}"
if cargo fmt --all -- --check; then
echo -e "${GREEN}✓ Format check passed${NC}"
else
echo -e "${RED}✗ Format check failed${NC}"
echo " Run: cargo fmt --all"
exit 1
fi
echo ""
echo -e "${YELLOW}2. Clippy Linting${NC}"
if cargo clippy --workspace --all-targets --all-features --exclude neo-gui -- -D warnings; then
echo -e "${GREEN}✓ Clippy passed${NC}"
else
echo -e "${RED}✗ Clippy failed${NC}"
exit 1
fi
echo ""
echo -e "${YELLOW}3. Tests (neo3 package)${NC}"
cp Cargo.toml Cargo.toml.bak
trap "mv Cargo.toml.bak Cargo.toml 2>/dev/null || true; git checkout -- neo-gui 2>/dev/null || true" EXIT
sed -i.tmp 's/"neo-gui",//g; s/, "neo-gui"//g; s/"neo-gui"//g' Cargo.toml
rm -rf neo-gui
if NEORUST_SKIP_NETWORK_TESTS=1 cargo test --package neo3 --all-features; then
echo -e "${GREEN}✓ Tests passed${NC}"
else
echo -e "${RED}✗ Tests failed${NC}"
exit 1
fi
mv Cargo.toml.bak Cargo.toml
git checkout -- neo-gui 2>/dev/null || true
echo ""
echo -e "${GREEN}All CI checks passed! ✨${NC}"
echo "Safe to commit and push."