chore: add test runner to pre-commit hook with failure-only output
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m58s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m58s
This commit is contained in:
@@ -13,6 +13,13 @@ if [ -n "$STAGED_FILES" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run tests — only failing tests are printed to keep output focused
|
||||
echo "🧪 Running tests..."
|
||||
bash .husky/scripts/run-tests.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Generate project structure
|
||||
echo "🗺️ Updating project structure..."
|
||||
node .husky/scripts/generate-project-tree.js
|
||||
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# Run all tests and display only failing tests (plus a summary).
|
||||
# Keeps output focused so commit context isn't bloated.
|
||||
#
|
||||
# NOTE: It doesn't matter if you didn't introduce the failing tests —
|
||||
# they should be handled before committing. A red main branch helps no one.
|
||||
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
echo "🧪 Running tests (only failures will be shown)..."
|
||||
|
||||
# Disable TTY progress bars for clean pre-commit output.
|
||||
# Use `--reporter=default` which prints only failures + the final summary.
|
||||
CI=true npx vitest run --reporter=default 2>&1
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -ne 0 ]; then
|
||||
echo ""
|
||||
echo "⛔ Commit blocked: failing tests found."
|
||||
echo " It doesn't matter if you didn't introduce the failing tests —"
|
||||
echo " they should be handled before committing."
|
||||
fi
|
||||
|
||||
exit $EXIT_CODE
|
||||
Reference in New Issue
Block a user