test: implement unit testing suite with pytest and add pre-push verification hook
CI/CD Pipeline / Lint & Check (push) Successful in 10s
CI/CD Pipeline / Build & Push Docker Image (push) Successful in 1m21s

This commit is contained in:
2026-05-13 00:12:32 +02:00
parent 8e9e4c01d4
commit 99fd37fc12
8 changed files with 392 additions and 20 deletions
+17 -8
View File
@@ -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
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# pre-push hook: runs unit tests before every git push
# To bypass: git push --no-verify
echo "🧪 Running unit tests..."
uv run pytest tests/unit/ -q
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo ""
echo "❌ Unit tests failed. Push aborted."
echo " To bypass: git push --no-verify"
exit 1
fi
echo "✅ All unit tests passed."
exit 0