-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsetup-dev-env.sh
More file actions
executable file
·160 lines (138 loc) · 4.62 KB
/
setup-dev-env.sh
File metadata and controls
executable file
·160 lines (138 loc) · 4.62 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
# Setup script for CF Java Plugin development environment
# Installs pre-commit hooks and validates the development setup
echo "🚀 Setting up CF Java Plugin development environment"
echo "====================================================="
# Check if we're in the right directory
if [ ! -f "cf_cli_java_plugin.go" ]; then
echo "❌ Error: Not in the CF Java Plugin root directory"
exit 1
fi
echo "✅ In correct project directory"
# Install pre-commit hook
echo "📦 Installing pre-commit hooks..."
if [ ! -f ".git/hooks/pre-commit" ]; then
echo "❌ Error: Pre-commit hook file not found"
echo "This script should be run from the repository root where .git/hooks/pre-commit exists"
exit 1
fi
chmod +x .git/hooks/pre-commit
echo "✅ Pre-commit hooks installed"
# Setup Go environment
echo "🔧 Checking Go environment..."
if ! command -v go &> /dev/null; then
echo "❌ Go is not installed. Please install Go 1.23.5 or later."
exit 1
fi
GO_VERSION=$(go version | grep -o 'go[0-9]\+\.[0-9]\+' | head -1)
echo "✅ Go version: $GO_VERSION"
# Install Go dependencies
echo "📦 Installing Go dependencies..."
go mod tidy
echo "✅ Go dependencies installed"
# Install linting tools
echo "🔍 Installing linting tools..."
# Install golangci-lint
if ! command -v golangci-lint &> /dev/null; then
echo "Installing golangci-lint..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
echo "✅ golangci-lint installed"
else
echo "✅ golangci-lint already installed"
fi
# Install gofumpt for stricter formatting
if ! command -v gofumpt &> /dev/null; then
echo "Installing gofumpt..."
go install mvdan.cc/gofumpt@latest
echo "✅ gofumpt installed"
else
echo "✅ gofumpt already installed"
fi
# Install markdownlint (if npm is available)
if command -v npm &> /dev/null; then
if ! command -v markdownlint &> /dev/null; then
echo "Installing markdownlint-cli..."
npm install -g markdownlint-cli
echo "✅ markdownlint-cli installed"
else
echo "✅ markdownlint-cli already installed"
fi
else
echo "⚠️ npm not found - skipping markdownlint installation"
echo " Install Node.js and npm to enable markdown linting"
fi
echo "✅ Linting tools setup complete"
# Setup Python environment (if test suite exists)
if [ -f "test/requirements.txt" ]; then
echo "🐍 Setting up Python test environment..."
cd test
if [ ! -d "venv" ]; then
echo "Creating Python virtual environment..."
python3 -m venv venv
fi
source venv/bin/activate
pip3 install --upgrade pip
pip3 install -r requirements.txt
echo "✅ Python test environment ready"
cd ..
else
echo "⚠️ Python test suite not found - skipping Python setup"
fi
# VS Code setup validation
if [ -f "cf-java-plugin.code-workspace" ]; then
echo "✅ VS Code workspace configuration found"
if [ -f "./test-vscode-config.sh" ]; then
echo "🔧 Running VS Code configuration test..."
./test-vscode-config.sh
fi
else
echo "⚠️ VS Code workspace configuration not found"
fi
# Test the pre-commit hook
echo ""
echo "🧪 Testing pre-commit hook..."
echo "This will run all checks without committing..."
if .git/hooks/pre-commit; then
echo "✅ Pre-commit hook test passed"
else
echo "❌ Pre-commit hook test failed"
echo "Please fix the issues before proceeding"
exit 1
fi
echo ""
echo "🎉 Development Environment Setup Complete!"
echo "=========================================="
echo ""
echo "📋 What's configured:"
echo " ✅ Pre-commit hooks (run on every git commit)"
echo " ✅ Go development environment"
echo " ✅ Linting tools (golangci-lint, markdownlint)"
if [ -f "test/requirements.txt" ]; then
echo " ✅ Python test suite environment"
else
echo " ⚠️ Python test suite (not found)"
fi
if [ -f "cf-java-plugin.code-workspace" ]; then
echo " ✅ VS Code workspace with debugging support"
fi
echo "Setup Python Testing Environment:"
(cd test && ./test.sh setup)
echo ""
echo "🚀 Quick Start:"
echo " • Build plugin: make build"
if [ -f "test/requirements.txt" ]; then
echo " • Run Python tests: cd test && ./test.sh all"
echo " • VS Code debugging: code cf-java-plugin.code-workspace"
fi
echo " • Manual hook test: .git/hooks/pre-commit"
echo ""
echo "📚 Documentation:"
echo " • Main README: README.md"
if [ -f "test/README.md" ]; then
echo " • Test documentation: test/README.md"
fi
if [ -f ".vscode/README.md" ]; then
echo " • VS Code guide: .vscode/README.md"
fi
echo ""
echo "Happy coding! 🎯"