diff --git a/.githooks/pre-push b/.githooks/pre-push index 04562784..73277f70 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -1,21 +1,22 @@ #!/bin/sh # -# Pre-push hook - Runs tests before pushing (supports both Sail and K8s) +# Pre-push hook - Optionally run tests before pushing # Can be skipped with: git push --no-verify # +# This is OPTIONAL - CI/CD will run comprehensive tests automatically. +# Running tests locally can catch issues faster, but it's not required. +# -echo "πŸ§ͺ Running tests before push..." -echo " (Use 'git push --no-verify' to skip)" +echo "πŸš€ Preparing to push..." echo "" # Detect which environment is running SAIL_RUNNING=false K8S_RUNNING=false -# Check if Sail is running -if docker ps --format '{{.Names}}' | grep -q "sail" 2>/dev/null; then +# Check if Sail is running (use vendor/bin/sail ps which works for all project names) +if [ -f ./vendor/bin/sail ] && ./vendor/bin/sail ps 2>/dev/null | grep -q "Up"; then SAIL_RUNNING=true - echo "πŸ“¦ Detected Sail environment" fi # Check if k8s namespace exists for this worktree @@ -24,41 +25,46 @@ K8S_NS=$(echo "$BRANCH" | sed 's/feature\//feat-/' | sed 's/bugfix\//fix-/' | se if kubectl get namespace "$K8S_NS" >/dev/null 2>&1; then K8S_RUNNING=true - echo "☸️ Detected K8s environment (namespace: $K8S_NS)" fi -# Run tests in appropriate environment -if [ "$SAIL_RUNNING" = true ]; then - ./vendor/bin/sail artisan test --parallel - TEST_EXIT_CODE=$? -elif [ "$K8S_RUNNING" = true ]; then - echo " Running tests in k8s pod..." - kubectl -n "$K8S_NS" exec deploy/web -- php artisan test - TEST_EXIT_CODE=$? -else - echo "⚠️ No environment running (Sail or K8s)" - echo " Skipping tests - please run tests manually" +# Offer to run tests if environment is available +if [ "$SAIL_RUNNING" = true ] || [ "$K8S_RUNNING" = true ]; then + echo "πŸ’‘ Tests will run automatically in CI/CD" echo "" - read -p "Continue push anyway? (y/n) " -n 1 -r + read -p "Run tests locally before push? (y/N) " -n 1 -r echo "" - if [ ! "$REPLY" = "y" ] && [ ! "$REPLY" = "Y" ]; then - echo "Push aborted" - exit 1 + echo "" + + if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ]; then + echo "πŸ§ͺ Running tests..." + echo "" + + if [ "$SAIL_RUNNING" = true ]; then + ./vendor/bin/sail artisan test --parallel + TEST_EXIT_CODE=$? + elif [ "$K8S_RUNNING" = true ]; then + kubectl -n "$K8S_NS" exec deploy/web -- php artisan test + TEST_EXIT_CODE=$? + fi + + if [ $TEST_EXIT_CODE -ne 0 ]; then + echo "" + echo "❌ Tests failed!" + echo "" + echo "Options:" + echo " 1. Fix the failing tests (recommended)" + echo " 2. Push anyway - CI will catch failures: git push --no-verify" + echo "" + exit 1 + fi + + echo "" + echo "βœ… All tests passed!" + echo "" fi - exit 0 -fi - -# Check test results -if [ $TEST_EXIT_CODE -ne 0 ]; then - echo "" - echo "❌ Tests failed!" - echo "" - echo "Options:" - echo " 1. Fix the failing tests (recommended)" - echo " 2. Push anyway with: git push --no-verify" - echo "" - exit 1 fi +echo "⚑ Pushing to remote (CI will run full test suite)..." echo "" -echo "βœ… All tests passed! Pushing..." + +exit 0 diff --git a/.gitignore b/.gitignore index 4b47727a..ad4fdfc5 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,5 @@ core.* !resources/**/*.jpg !resources/**/*.jpeg .claude/settings.local.json +storage/tmp/* +!storage/tmp/.gitignore diff --git a/docker-compose.yml b/docker-compose.yml index 83208598..712079a7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,7 @@ services: XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' IGNITION_LOCAL_SITES_PATH: '${PWD}' + TMPDIR: '/var/www/html/storage/tmp' volumes: - '.:/var/www/html' networks: diff --git a/storage/tmp/.gitignore b/storage/tmp/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/storage/tmp/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore