summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-16 19:46:44 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-16 19:46:44 +0000
commit17a36cc83980d278a8cab5132bf14de731b352ca (patch)
tree3eceb94fd0467492668692b1a0e4f840a941c9cf /scripts
parentc2aa026f6ce1c9e216b99d74f294fc133d5fcddd (diff)
fix: repair test regressions and add pre-commit/pre-push verification gates
Fix four pre-existing bugs exposed after resolving a build failure: - sandboxCloneSource: accept any URL scheme for origin remote (was filtering out https://) - setupSandbox callers: fix := shadow variable so sandboxDir is set on BlockedError - parseGeminiStream: parse result lines to return execution errors and cost - TestElaborateTask_InvalidJSONFromClaude: stub Gemini fallback so test is hermetic Add verification infrastructure: - scripts/verify: runs go build + go test -race, used by hooks and deploy - scripts/hooks/pre-commit: blocks commits that don't compile - scripts/hooks/pre-push: blocks pushes where tests fail - scripts/install-hooks: symlinks version-controlled hooks into .git/hooks/ - scripts/deploy: runs scripts/verify before building the binary Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/deploy13
-rw-r--r--scripts/hooks/pre-commit7
-rw-r--r--scripts/hooks/pre-push6
-rw-r--r--scripts/install-hooks23
-rw-r--r--scripts/verify17
5 files changed, 60 insertions, 6 deletions
diff --git a/scripts/deploy b/scripts/deploy
index c7ff734..206087d 100755
--- a/scripts/deploy
+++ b/scripts/deploy
@@ -31,21 +31,22 @@ if [ "$DIRTY" = false ] && [ -n "$(git status --porcelain)" ]; then
trap 'if [ "$STASHED" = true ]; then echo "==> Popping stash..."; git stash pop; fi' EXIT
fi
+echo "==> Verifying (build + tests)..."
+"${REPO_DIR}/scripts/verify"
+
echo "==> Building claudomator..."
export GOCACHE="${SITE_DIR}/cache/go-build"
export GOPATH="${SITE_DIR}/cache/gopath"
mkdir -p "${GOCACHE}" "${GOPATH}"
go build -o "${BIN_DIR}/claudomator" ./cmd/claudomator/
+chown www-data:www-data "${BIN_DIR}/claudomator"
+chmod +x "${BIN_DIR}/claudomator"
echo "==> Copying scripts..."
mkdir -p "${SITE_DIR}/scripts"
-cp "${REPO_DIR}/scripts/"* "${SITE_DIR}/scripts/"
+cp -p "${REPO_DIR}/scripts/"* "${SITE_DIR}/scripts/"
chown -R www-data:www-data "${SITE_DIR}/scripts"
-chmod +x "${SITE_DIR}/scripts/"*
-
-echo "==> Fixing permissions..."
-chown www-data:www-data "${BIN_DIR}/claudomator"
-chmod +x "${BIN_DIR}/claudomator"
+find "${SITE_DIR}/scripts" -maxdepth 1 -type f -exec chmod +x {} +
if [ -f "${BIN_DIR}/claude" ]; then
echo "==> Fixing Claude permissions..."
diff --git a/scripts/hooks/pre-commit b/scripts/hooks/pre-commit
new file mode 100644
index 0000000..faf91fc
--- /dev/null
+++ b/scripts/hooks/pre-commit
@@ -0,0 +1,7 @@
+#!/bin/bash
+# pre-commit — Reject commits that don't compile.
+set -euo pipefail
+REPO_DIR="$(git rev-parse --show-toplevel)"
+echo "pre-commit: go build ./..."
+cd "${REPO_DIR}"
+go build ./...
diff --git a/scripts/hooks/pre-push b/scripts/hooks/pre-push
new file mode 100644
index 0000000..d851332
--- /dev/null
+++ b/scripts/hooks/pre-push
@@ -0,0 +1,6 @@
+#!/bin/bash
+# pre-push — Reject pushes where tests fail.
+set -euo pipefail
+REPO_DIR="$(git rev-parse --show-toplevel)"
+echo "pre-push: running scripts/verify..."
+exec "${REPO_DIR}/scripts/verify"
diff --git a/scripts/install-hooks b/scripts/install-hooks
new file mode 100644
index 0000000..454f3cd
--- /dev/null
+++ b/scripts/install-hooks
@@ -0,0 +1,23 @@
+#!/bin/bash
+# install-hooks — Symlink version-controlled hooks into .git/hooks/
+# Usage: ./scripts/install-hooks
+# Example: ./scripts/install-hooks
+
+set -euo pipefail
+
+REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
+HOOKS_SRC="${REPO_DIR}/scripts/hooks"
+HOOKS_DST="${REPO_DIR}/.git/hooks"
+
+for hook in "${HOOKS_SRC}"/*; do
+ name="$(basename "${hook}")"
+ target="${HOOKS_DST}/${name}"
+ if [ -e "${target}" ] && [ ! -L "${target}" ]; then
+ echo " skipping ${name}: non-symlink already exists at ${target}"
+ continue
+ fi
+ ln -sf "${hook}" "${target}"
+ echo " installed ${name}"
+done
+
+echo "==> Hooks installed."
diff --git a/scripts/verify b/scripts/verify
new file mode 100644
index 0000000..4f9c52f
--- /dev/null
+++ b/scripts/verify
@@ -0,0 +1,17 @@
+#!/bin/bash
+# verify — Build and test the claudomator codebase
+# Usage: ./scripts/verify
+# Example: ./scripts/verify
+
+set -euo pipefail
+
+REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
+cd "${REPO_DIR}"
+
+echo "==> Building..."
+go build ./...
+
+echo "==> Testing (race detector on)..."
+go test -race ./...
+
+echo "==> All checks passed."