diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 00000000..416e1439 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Pre-push hook: runs the full CI-mirror suite before allowing a push. +# Prevents broken builds from reaching GitHub. +# +# Auto-activated by `make install` via git core.hooksPath. + +set -e + +echo "Running pre-push gate (tox -e pre-push — mirrors CI exactly)..." +tox -e pre-push + +exit_code=$? + +if [ "$exit_code" -ne 0 ]; then + echo "" + echo "BLOCKED: pre-push gate failed. Fix the issues above before pushing." + exit 1 +fi diff --git a/deploy/com.timmy.tick.plist b/deploy/com.timmy.tick.plist new file mode 100644 index 00000000..f49a4836 --- /dev/null +++ b/deploy/com.timmy.tick.plist @@ -0,0 +1,26 @@ + + + + + Label + com.timmy.tick + + ProgramArguments + + __PROJECT_DIR__/deploy/timmy-tick-mac.sh + + + WorkingDirectory + __PROJECT_DIR__ + + StartInterval + 300 + + StandardOutPath + __PROJECT_DIR__/data/tick.log + + StandardErrorPath + __PROJECT_DIR__/data/tick-error.log + + diff --git a/deploy/install-mac-timer.sh b/deploy/install-mac-timer.sh new file mode 100755 index 00000000..4cda3199 --- /dev/null +++ b/deploy/install-mac-timer.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Install the Timmy tick timer on macOS via launchd. +# Usage: ./deploy/install-mac-timer.sh +set -e + +PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)" +PLIST_SRC="$PROJECT_DIR/deploy/com.timmy.tick.plist" +PLIST_DST="$HOME/Library/LaunchAgents/com.timmy.tick.plist" +LABEL="com.timmy.tick" + +# Ensure data dir exists for logs +mkdir -p "$PROJECT_DIR/data" + +# Make wrapper executable +chmod +x "$PROJECT_DIR/deploy/timmy-tick-mac.sh" + +# Unload if already installed +if launchctl list "$LABEL" >/dev/null 2>&1; then + echo "Unloading existing $LABEL..." + launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null || true +fi + +# Fill in project path and install +sed "s|__PROJECT_DIR__|$PROJECT_DIR|g" "$PLIST_SRC" > "$PLIST_DST" + +# Load +launchctl bootstrap "gui/$(id -u)" "$PLIST_DST" + +echo "Installed! Timmy will tick every 5 minutes." +echo " Logs: $PROJECT_DIR/data/tick.log" +echo " Check: launchctl list | grep timmy" +echo " Stop: launchctl bootout gui/\$(id -u)/com.timmy.tick" diff --git a/deploy/timmy-tick-mac.sh b/deploy/timmy-tick-mac.sh new file mode 100755 index 00000000..544bb089 --- /dev/null +++ b/deploy/timmy-tick-mac.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Wrapper script for the launchd tick timer on macOS. +# Ensures PATH is set so tox/python can be found. +export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH" +cd "$(dirname "$0")/.." || exit 1 +exec tox -e dev -- timmy tick diff --git a/tox.ini b/tox.ini index acc4beba..4fffd6c9 100644 --- a/tox.ini +++ b/tox.ini @@ -145,6 +145,22 @@ commands = -p no:xdist \ -m "not ollama and not docker and not selenium and not external_api" +# ── Pre-commit (fast local gate) ──────────────────────────────────────────── + +[testenv:pre-commit] +description = Fast pre-commit gate — format check + unit tests (30s budget) +deps = + black + isort +commands = + black --check --line-length 100 src/ tests/ + isort --check-only --profile black --line-length 100 src/ tests/ + pytest tests/ -q --tb=short \ + --ignore=tests/e2e \ + --ignore=tests/functional \ + -m "not ollama and not docker and not selenium and not external_api and not skip_ci" \ + -n auto --dist worksteal + # ── Dev Server ─────────────────────────────────────────────────────────────── [testenv:dev]