#!/usr/bin/env bash # Watch for file changes and run CI automatically # Usage: ./scripts/ci-watch.sh [quick|precommit] set -euo pipefail MODE="${1:-precommit}" case $MODE in quick) CI_SCRIPT="./scripts/ci-quick.sh" echo "👀 Watching for changes - will run quick CI..." ;; precommit) CI_SCRIPT="./scripts/ci-precommit.sh" echo "👀 Watching for changes - will run pre-commit validation..." ;; *) echo "Usage: $0 [quick|precommit]" echo " precommit - Fast build/test only" echo " quick - Quick CI pipeline" exit 1 ;; esac # Check if inotifywait is available if ! command -v inotifywait >/dev/null 2>&1; then echo "❌ inotifywait not found. Install with:" echo "sudo apt install inotify-tools" exit 1 fi echo "Watching: pkg/ internal/ cmd/ *.go" echo "Press Ctrl+C to stop" echo "" # Run initial check $CI_SCRIPT echo "" echo "👀 Watching for changes..." # Watch for changes and re-run while inotifywait -q -r -e modify,move,create,delete \ --include='.*\.go$' \ pkg/ internal/ cmd/ . 2>/dev/null; do echo "" echo "🔄 Files changed, running $MODE validation..." echo "" if $CI_SCRIPT; then echo "" echo "✅ Validation passed - watching for changes..." else echo "" echo "❌ Validation failed - fix issues and save files to retry" fi done