-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-dev.sh
More file actions
executable file
·107 lines (88 loc) · 3.65 KB
/
setup-dev.sh
File metadata and controls
executable file
·107 lines (88 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Development environment setup script for Kavya
# This script sets up linting tools and pre-commit hooks
set -e
echo "🚀 Setting up Kavya development environment..."
# Check if we're in a virtual environment
if [ -z "$VIRTUAL_ENV" ]; then
echo "⚠️ Not in a virtual environment. Creating one..."
if [ ! -d "venv" ]; then
echo "🔨 Creating virtual environment..."
python3 -m venv venv
fi
echo "📁 To activate the virtual environment, run:"
echo " source venv/bin/activate"
echo ""
echo "Then run this script again:"
echo " ./setup-dev.sh"
exit 0
fi
echo "✅ Virtual environment detected: $VIRTUAL_ENV"
# Install development dependencies
echo "📦 Installing development dependencies..."
pip install -r requirements-dev.txt
# Install main dependencies
echo "📦 Installing main dependencies..."
pip install -r requirements.txt
# Install pre-commit hooks using the framework (if available)
if command -v pre-commit >/dev/null 2>&1; then
echo "🔗 Installing pre-commit hooks using pre-commit framework..."
pre-commit install
echo "🧪 Running pre-commit on all files to test setup..."
pre-commit run --all-files || echo "⚠️ Some pre-commit checks failed, but setup is complete"
else
echo "⚠️ pre-commit command not found, using manual hook only"
fi
# Test the smart pre-commit hook
echo "🧪 Testing smart pre-commit hook..."
if [ -x ".git/hooks/pre-commit" ]; then
echo "✅ Smart pre-commit hook is installed and executable"
# Test the hook with no staged files (should be fast)
echo "🔍 Testing hook behavior with no staged files..."
.git/hooks/pre-commit || echo "⚠️ Hook test completed with warnings"
else
echo "❌ Smart pre-commit hook is not executable"
chmod +x .git/hooks/pre-commit
fi
# Test linting tools
echo "🔍 Testing linting tools..."
echo "🖤 Black version:"
python3 -m black --version
echo "📦 isort version:"
python3 -m isort --version
# Test API (if server is running)
echo "🌐 Testing basic API connectivity..."
if curl -s http://localhost:8080/health > /dev/null 2>&1; then
echo "✅ API server is running and reachable"
# Run a quick test
echo "🧪 Running a quick API test..."
if [ -x "tests/non-streaming-completion.sh" ]; then
tests/non-streaming-completion.sh || echo "⚠️ API test failed - check server status"
fi
else
echo "⚠️ API server not running on localhost:8080"
echo "💡 Start the server with: python -m kavya.openai_server --port 8080"
fi
echo ""
echo "🎉 Smart pre-commit development environment setup complete!"
echo ""
echo "📋 Next steps:"
echo " 1. Make sure your API server is running: python -m kavya.openai_server --port 8080"
echo " 2. Make some changes and commit - the smart hook will run automatically!"
echo ""
echo "🎯 Smart Hook Features:"
echo " - 📄 Documentation changes: Fast commits (no API tests)"
echo " - 📝 Python changes: Full linting + core API tests"
echo " - 🌐 Web search changes: + specialized web search tests"
echo " - 🔄 Controller changes: + fallback/provider tests"
echo " - ⚙️ Config changes: Full test suite"
echo " - 🔄 Auto-activates your virtual environment"
echo ""
echo "🔧 Manual commands (if needed):"
echo " - Format code: python -m black ."
echo " - Sort imports: python -m isort ."
echo " - Run all pre-commit hooks: pre-commit run --all-files"
echo " - Test specific functionality: ./tests/streaming-completion.sh"
echo " - Test web search: ./tests/web-search-streaming.sh"
echo ""
echo "💡 Pro tip: The hook automatically fixes formatting and includes fixes in your commit!"