From 6056ec502cbf022d7489a0679248f070fb1cf6b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 23:15:54 +0000 Subject: [PATCH 1/7] Add interactive local pre-push CI prompt and setup script Agent-Logs-Url: https://github.com/PadlyApp/Padly/sessions/795fc30d-ee0e-4bc6-a187-513421b67e44 Co-authored-by: QA1S <77554399+QA1S@users.noreply.github.com> --- .githooks/pre-push | 68 ++++++++++++++++++++++++++++++++++++++ README.md | 17 ++++++++++ scripts/setup-git-hooks.sh | 11 ++++++ 3 files changed, 96 insertions(+) create mode 100755 .githooks/pre-push create mode 100755 scripts/setup-git-hooks.sh diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 0000000..8eb1662 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [[ "${PADLY_SKIP_PREPUSH_CHECKS:-0}" == "1" ]]; then + exit 0 +fi + +if [[ ! -e /dev/tty ]]; then + exit 0 +fi + +REPO_ROOT="$(git rev-parse --show-toplevel)" + +run_backend_tests() { + echo "→ Running backend tests..." + ( + cd "$REPO_ROOT/backend" + SUPABASE_URL="${SUPABASE_URL:-https://example.supabase.co}" \ + SUPABASE_ANON_KEY="${SUPABASE_ANON_KEY:-ci-only-anon-placeholder-key}" \ + SUPABASE_SERVICE_KEY="${SUPABASE_SERVICE_KEY:-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic2VydmljZV9yb2xlIn0.fake-signature-for-ci-only}" \ + PYTEST_ADDOPTS="${PYTEST_ADDOPTS:---ignore=tests/test_location_contract.py}" \ + python -m pytest tests -v + ) +} + +run_frontend_checks() { + echo "→ Running frontend checks (lint, typecheck, build)..." + ( + cd "$REPO_ROOT/frontend" + NEXT_PUBLIC_SUPABASE_URL="${NEXT_PUBLIC_SUPABASE_URL:-https://example.supabase.co}" \ + NEXT_PUBLIC_SUPABASE_ANON_KEY="${NEXT_PUBLIC_SUPABASE_ANON_KEY:-dummy-anon-key}" \ + npm run lint + NEXT_PUBLIC_SUPABASE_URL="${NEXT_PUBLIC_SUPABASE_URL:-https://example.supabase.co}" \ + NEXT_PUBLIC_SUPABASE_ANON_KEY="${NEXT_PUBLIC_SUPABASE_ANON_KEY:-dummy-anon-key}" \ + npx tsc --noEmit + NEXT_PUBLIC_SUPABASE_URL="${NEXT_PUBLIC_SUPABASE_URL:-https://example.supabase.co}" \ + NEXT_PUBLIC_SUPABASE_ANON_KEY="${NEXT_PUBLIC_SUPABASE_ANON_KEY:-dummy-anon-key}" \ + npm run build + ) +} + +echo +echo "Padly pre-push checks" +echo "Run checks before push? [a]ll / [b]ackend / [f]rontend / [n]o" +read -r -p "Choice (a/b/f/n): " choice < /dev/tty + +case "${choice,,}" in + a | all) + run_backend_tests + run_frontend_checks + ;; + b | backend) + run_backend_tests + ;; + f | frontend) + run_frontend_checks + ;; + n | no | "") + echo "Skipping local checks." + ;; + *) + echo "Invalid choice '$choice'. Push canceled." + exit 1 + ;; +esac + +echo "Pre-push checks complete. Continuing push..." diff --git a/README.md b/README.md index 4060819..410aef3 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,20 @@ Every interaction feeds back into the system. Swipe behavior refines recommendat - Interns relocating temporarily - New grads and early-career professionals moving to new cities - Anyone who needs both a home and compatible roommates + +## Optional Local Pre-Push Checks + +To prompt for local checks every time you run `git push`, enable the repository hook once: + +```bash +cd /home/runner/work/Padly/Padly +./scripts/setup-git-hooks.sh +``` + +Then on push, choose: +- `a` → backend tests + frontend lint/typecheck/build +- `b` → backend tests only +- `f` → frontend checks only +- `n` → skip checks and continue push + +You can bypass hooks anytime with `git push --no-verify`. diff --git a/scripts/setup-git-hooks.sh b/scripts/setup-git-hooks.sh new file mode 100755 index 0000000..b5674b8 --- /dev/null +++ b/scripts/setup-git-hooks.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +REPO_ROOT="$(git rev-parse --show-toplevel)" + +git config core.hooksPath "$REPO_ROOT/.githooks" +chmod +x "$REPO_ROOT/.githooks/pre-push" + +echo "Padly Git hooks are enabled." +echo "You will now be prompted for local checks on git push." From 2d6c91c611e1086fd716dbdb2986d6999cc0d584 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 23:17:45 +0000 Subject: [PATCH 2/7] Use generic repo-root path in hook setup docs Agent-Logs-Url: https://github.com/PadlyApp/Padly/sessions/795fc30d-ee0e-4bc6-a187-513421b67e44 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 410aef3..5fb7c70 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Every interaction feeds back into the system. Swipe behavior refines recommendat To prompt for local checks every time you run `git push`, enable the repository hook once: ```bash -cd /home/runner/work/Padly/Padly +cd ./scripts/setup-git-hooks.sh ``` From 3ff1197fcb244844204974c6117554a338047e40 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 23:18:03 +0000 Subject: [PATCH 3/7] Skip pre-push prompt when no interactive terminal is available Agent-Logs-Url: https://github.com/PadlyApp/Padly/sessions/795fc30d-ee0e-4bc6-a187-513421b67e44 --- .githooks/pre-push | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index 8eb1662..ef79978 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -6,7 +6,7 @@ if [[ "${PADLY_SKIP_PREPUSH_CHECKS:-0}" == "1" ]]; then exit 0 fi -if [[ ! -e /dev/tty ]]; then +if [[ ! -r /dev/tty || ! -w /dev/tty ]]; then exit 0 fi @@ -43,7 +43,10 @@ run_frontend_checks() { echo echo "Padly pre-push checks" echo "Run checks before push? [a]ll / [b]ackend / [f]rontend / [n]o" -read -r -p "Choice (a/b/f/n): " choice < /dev/tty +if ! read -r -p "Choice (a/b/f/n): " choice < /dev/tty; then + echo "No interactive terminal detected. Skipping local checks." + exit 0 +fi case "${choice,,}" in a | all) From 74f4f65f09c309f5e701a0727d65b86675f180ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 23:18:35 +0000 Subject: [PATCH 4/7] Avoid /dev/tty errors in non-interactive pre-push runs Agent-Logs-Url: https://github.com/PadlyApp/Padly/sessions/795fc30d-ee0e-4bc6-a187-513421b67e44 --- .githooks/pre-push | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index ef79978..f0b0ee9 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -6,7 +6,7 @@ if [[ "${PADLY_SKIP_PREPUSH_CHECKS:-0}" == "1" ]]; then exit 0 fi -if [[ ! -r /dev/tty || ! -w /dev/tty ]]; then +if ! exec 3<>/dev/tty 2>/dev/null; then exit 0 fi @@ -43,8 +43,9 @@ run_frontend_checks() { echo echo "Padly pre-push checks" echo "Run checks before push? [a]ll / [b]ackend / [f]rontend / [n]o" -if ! read -r -p "Choice (a/b/f/n): " choice < /dev/tty; then +if ! read -r -u 3 -p "Choice (a/b/f/n): " choice; then echo "No interactive terminal detected. Skipping local checks." + exec 3>&- exit 0 fi @@ -69,3 +70,4 @@ case "${choice,,}" in esac echo "Pre-push checks complete. Continuing push..." +exec 3>&- From b4ebac4608c46d8a5f36e29b739e188fa121a21e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 23:18:47 +0000 Subject: [PATCH 5/7] Silence non-interactive tty open errors in pre-push hook Agent-Logs-Url: https://github.com/PadlyApp/Padly/sessions/795fc30d-ee0e-4bc6-a187-513421b67e44 --- .githooks/pre-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index f0b0ee9..c949176 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -6,7 +6,7 @@ if [[ "${PADLY_SKIP_PREPUSH_CHECKS:-0}" == "1" ]]; then exit 0 fi -if ! exec 3<>/dev/tty 2>/dev/null; then +if ! { exec 3<>/dev/tty; } 2>/dev/null; then exit 0 fi From 7954616e0e7ee299487d07f85fbb4c5e6ab165de Mon Sep 17 00:00:00 2001 From: Qais A Date: Thu, 9 Apr 2026 19:29:27 -0400 Subject: [PATCH 6/7] testing hook --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fb7c70..bb5b94a 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Every interaction feeds back into the system. Swipe behavior refines recommendat ## Optional Local Pre-Push Checks -To prompt for local checks every time you run `git push`, enable the repository hook once: +To prompt for local tests/check every time you run `git push`, enable the repository hook once: ```bash cd From 76b1641e8d25696723fc8cef0fbecf8017a434a4 Mon Sep 17 00:00:00 2001 From: Qais A Date: Thu, 9 Apr 2026 19:39:22 -0400 Subject: [PATCH 7/7] updated hook visuals --- .githooks/pre-push | 65 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index c949176..01a9676 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -12,32 +12,70 @@ fi REPO_ROOT="$(git rev-parse --show-toplevel)" +prepush_abort_hint() { + echo " Fix the errors above, or bypass with: git push --no-verify" +} + run_backend_tests() { - echo "→ Running backend tests..." - ( + echo "→ Backend: tests (pytest)..." + if ! ( cd "$REPO_ROOT/backend" SUPABASE_URL="${SUPABASE_URL:-https://example.supabase.co}" \ SUPABASE_ANON_KEY="${SUPABASE_ANON_KEY:-ci-only-anon-placeholder-key}" \ SUPABASE_SERVICE_KEY="${SUPABASE_SERVICE_KEY:-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic2VydmljZV9yb2xlIn0.fake-signature-for-ci-only}" \ PYTEST_ADDOPTS="${PYTEST_ADDOPTS:---ignore=tests/test_location_contract.py}" \ python -m pytest tests -v - ) + ); then + echo "" + echo "✗ Backend tests failed — push aborted." + prepush_abort_hint + exit 1 + fi + echo " ✓ Backend tests passed" } run_frontend_checks() { - echo "→ Running frontend checks (lint, typecheck, build)..." - ( + echo "→ Frontend: lint..." + if ! ( cd "$REPO_ROOT/frontend" NEXT_PUBLIC_SUPABASE_URL="${NEXT_PUBLIC_SUPABASE_URL:-https://example.supabase.co}" \ NEXT_PUBLIC_SUPABASE_ANON_KEY="${NEXT_PUBLIC_SUPABASE_ANON_KEY:-dummy-anon-key}" \ npm run lint + ); then + echo "" + echo "✗ Frontend lint failed — push aborted." + prepush_abort_hint + exit 1 + fi + echo " ✓ Frontend lint passed" + + echo "→ Frontend: typecheck..." + if ! ( + cd "$REPO_ROOT/frontend" NEXT_PUBLIC_SUPABASE_URL="${NEXT_PUBLIC_SUPABASE_URL:-https://example.supabase.co}" \ NEXT_PUBLIC_SUPABASE_ANON_KEY="${NEXT_PUBLIC_SUPABASE_ANON_KEY:-dummy-anon-key}" \ npx tsc --noEmit + ); then + echo "" + echo "✗ Frontend typecheck failed — push aborted." + prepush_abort_hint + exit 1 + fi + echo " ✓ Frontend typecheck passed" + + echo "→ Frontend: build..." + if ! ( + cd "$REPO_ROOT/frontend" NEXT_PUBLIC_SUPABASE_URL="${NEXT_PUBLIC_SUPABASE_URL:-https://example.supabase.co}" \ NEXT_PUBLIC_SUPABASE_ANON_KEY="${NEXT_PUBLIC_SUPABASE_ANON_KEY:-dummy-anon-key}" \ npm run build - ) + ); then + echo "" + echo "✗ Frontend build failed — push aborted." + prepush_abort_hint + exit 1 + fi + echo " ✓ Frontend build passed" } echo @@ -49,7 +87,10 @@ if ! read -r -u 3 -p "Choice (a/b/f/n): " choice; then exit 0 fi -case "${choice,,}" in +# Bash 3.2 (macOS default) does not support ${var,,}; use tr for lowercase. +choice_lc=$(printf '%s' "$choice" | tr '[:upper:]' '[:lower:]') +SKIP_PREPUSH=0 +case "$choice_lc" in a | all) run_backend_tests run_frontend_checks @@ -61,7 +102,8 @@ case "${choice,,}" in run_frontend_checks ;; n | no | "") - echo "Skipping local checks." + echo "○ Skipping local checks." + SKIP_PREPUSH=1 ;; *) echo "Invalid choice '$choice'. Push canceled." @@ -69,5 +111,10 @@ case "${choice,,}" in ;; esac -echo "Pre-push checks complete. Continuing push..." +if [[ "$SKIP_PREPUSH" -eq 1 ]]; then + echo "→ Continuing push (no checks run)." +else + echo "" + echo "✓ All pre-push checks passed — continuing push." +fi exec 3>&-