#!/bin/bash
# Pre-commit hook for Skillz
# Run: chmod +x .github/hooks/pre-commit && ln -sf ../../.github/hooks/pre-commit .git/hooks/pre-commit

set -e

echo "🔍 Running pre-commit checks..."

# Format check
echo "📝 Checking formatting..."
cargo fmt --all -- --check
if [ $? -ne 0 ]; then
    echo "❌ Formatting check failed. Run 'cargo fmt --all' to fix."
    exit 1
fi

# Clippy
echo "🔎 Running clippy..."
cargo clippy --all-targets -- -D warnings
if [ $? -ne 0 ]; then
    echo "❌ Clippy check failed. Fix the warnings above."
    exit 1
fi

# Tests
echo "🧪 Running tests..."
cargo test --release -- --test-threads=1
if [ $? -ne 0 ]; then
    echo "❌ Tests failed."
    exit 1
fi

echo "✅ All checks passed!"

