diff --git a/.githooks/pre-push b/.githooks/pre-push index 5e10ec0..c71bab9 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -6,64 +6,33 @@ #export GIT_TRACE_PERFORMANCE=1 #export GIT_SSH_COMMAND="ssh -vvv" -set -euo pipefail +set -eu set -x +# Only run for specific branches +read_branches() { + while IFS=' ' read -r _ _ remote_ref _; do + case "$remote_ref" in + refs/heads/testing|refs/heads/staging|refs/heads/main|refs/heads/production) + return 0 + ;; + esac + done + return 1 +} -COMMIT_HASH=$(git rev-parse HEAD) -pwd -if ! "./scripts/pre-push-tests.sh" "$COMMIT_HASH"; then - echo "Tests failed. Aborting push." - exit 1 +if ! read_branches; then + echo "Skipping tests: not pushing testing, staging, main, or production." +else + COMMIT_HASH=$(git rev-parse HEAD) + + if ! "./scripts/pre-push-tests.sh" "$COMMIT_HASH"; then + echo "Tests failed. Aborting push." + exit 1 + fi fi -# # Run Mocha directly, fail if any test fails -# if ! node_modules/.bin/mocha "test/**/*.unit.test.js" "test/**/*.property.test.js"; then -# echo "Initial test suite failed. Skipping prepush and aborting push." - -# if kill -0 "$APP_PID" 2>/dev/null; then -# echo "Stopping app (PID: $APP_PID)..." -# kill "$APP_PID" -# sleep 1 -# if kill -0 "$APP_PID" 2>/dev/null; then -# kill -9 "$APP_PID" 2>/dev/null || true -# fi -# fi - -# wait "$APP_PID" 2>/dev/null || true -# exit 1 -# fi - -# node src/app.js >/dev/null 2>&1 & -# APP_PID=$! - -# sleep 2 - -# npm run test:prepush -# TEST_RESULT=$? - -# # Clean up the app process -# if kill -0 $APP_PID 2>/dev/null; then -# echo "Stopping app (PID: $APP_PID)..." -# kill $APP_PID -# # Give it time to shut down gracefully -# sleep 1 -# # Force kill if still running -# if kill -0 $APP_PID 2>/dev/null; then -# kill -9 $APP_PID 2>/dev/null || true -# fi -# fi - -# # Wait for process to fully terminate -# wait $APP_PID 2>/dev/null || true - - -# if [ $TEST_RESULT -ne 0 ]; then -# echo "Tests failed. Push aborted." -# exit 1 -# fi - cd content git push "$remote" main cd .. diff --git a/.gitignore b/.gitignore index 9ea2e52..8fb06ba 100755 --- a/.gitignore +++ b/.gitignore @@ -78,6 +78,7 @@ data/* !data/.gitkeep .last_tested_commit +.last_unit_tested_commit certs/* test/logs/*