test: implement unit testing suite with pytest and add pre-push verification hook
This commit is contained in:
@@ -1,26 +1,35 @@
|
||||
#!/bin/sh
|
||||
# pre-commit hook: runs ruff check on staged Python files before every commit
|
||||
# pre-commit hook: runs ruff check (lint) and ruff format --check on staged Python files
|
||||
# To bypass: git commit --no-verify
|
||||
|
||||
# Get list of staged Python files
|
||||
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')
|
||||
|
||||
if [ -z "$STAGED_FILES" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "🔍 Running ruff check on staged files..."
|
||||
FAILED=0
|
||||
|
||||
echo "🔍 Running ruff check (lint)..."
|
||||
uv run ruff check $STAGED_FILES
|
||||
exit_code=$?
|
||||
if [ $? -ne 0 ]; then
|
||||
echo " ↳ Fix with: uv run ruff check --fix"
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
echo "🎨 Running ruff format --check..."
|
||||
uv run ruff format --check $STAGED_FILES
|
||||
if [ $? -ne 0 ]; then
|
||||
echo " ↳ Fix with: uv run ruff format"
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
if [ $FAILED -ne 0 ]; then
|
||||
echo ""
|
||||
echo "❌ ruff check failed. Commit aborted."
|
||||
echo " Fix the issues above or run: uv run ruff check --fix"
|
||||
echo "❌ Pre-commit checks failed. Commit aborted."
|
||||
echo " To bypass: git commit --no-verify"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ ruff check passed."
|
||||
echo "✅ All checks passed."
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user