-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
347 lines (311 loc) · 11 KB
/
install.sh
File metadata and controls
347 lines (311 loc) · 11 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#!/bin/bash
# CodeFlow Engine - Simple Installation Script
# Usage: curl -sSL https://raw.githubusercontent.com/JustAGhosT/codeflow-engine/master/engine/install.sh | bash
# Or: ./engine/install.sh [--full|--dev|--minimal]
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Print with color
print_status() { echo -e "${BLUE}[*]${NC} $1"; }
print_success() { echo -e "${GREEN}[+]${NC} $1"; }
print_warning() { echo -e "${YELLOW}[!]${NC} $1"; }
print_error() { echo -e "${RED}[-]${NC} $1"; }
# Banner
echo ""
echo " ___ _ ____ ____ _____ _ "
echo " / _ \ | | | _ \| _ \ | ____|_ __ __ _(_)_ __ ___ "
echo "| |_| |_ _| |_ ___ | |_) | |_) | | _| | '_ \ / _\` | | '_ \ / _ \\"
echo "| _ | | | | __/ _ \| __/| _ < | |___| | | | (_| | | | | | __/"
echo "|_| |_|\__,_|\__\___/|_| |_| \_\ |_____|_| |_|\__, |_|_| |_|\___|"
echo " |___/ "
echo ""
echo "AI-Powered GitHub PR Automation and Issue Management"
echo ""
# Version
VERSION="1.0.0"
# Detect installation type
INSTALL_TYPE="standard"
if [ "$1" = "--full" ]; then
INSTALL_TYPE="full"
elif [ "$1" = "--dev" ]; then
INSTALL_TYPE="dev"
elif [ "$1" = "--minimal" ]; then
INSTALL_TYPE="minimal"
elif [ "$1" = "--docker" ]; then
INSTALL_TYPE="docker"
elif [ "$1" = "--action" ]; then
INSTALL_TYPE="action"
elif [ "$1" = "--version" ] || [ "$1" = "-v" ]; then
echo "CodeFlow Engine Installer v${VERSION}"
exit 0
elif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
# Show banner in help output
echo ""
echo " ___ _ ____ ____ _____ _ "
echo " / _ \ | | | _ \| _ \ | ____|_ __ __ _(_)_ __ ___ "
echo "| |_| |_ _| |_ ___ | |_) | |_) | | _| | '_ \ / _\` | | '_ \ / _ \\"
echo "| _ | | | | __/ _ \| __/| _ < | |___| | | | (_| | | | | | __/"
echo "|_| |_|\__,_|\__\___/|_| |_| \_\ |_____|_| |_|\__, |_|_| |_|\___|"
echo " |___/ "
echo ""
echo "CodeFlow - AI-Powered GitHub PR Automation and Issue Management"
echo ""
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --minimal Install core package only (no extras)"
echo " --standard Install with common features (default)"
echo " --full Install with all features and integrations"
echo " --dev Install for development (includes dev tools)"
echo " --docker Set up Docker-based installation"
echo " --action Set up GitHub Action workflow in current repo"
echo " --version Show installer version"
echo " --help Show this help message"
echo ""
exit 0
fi
# Check prerequisites
check_prerequisites() {
print_status "Checking prerequisites..."
# Check Python version
if command -v python3 &> /dev/null; then
PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
PYTHON_MAJOR=$(echo "$PYTHON_VERSION" | cut -d. -f1)
PYTHON_MINOR=$(echo "$PYTHON_VERSION" | cut -d. -f2)
# Check for Python 3.12+ (or Python 4+)
if [ "$PYTHON_MAJOR" -gt 3 ]; then
print_success "Python $PYTHON_VERSION detected"
elif [ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -ge 12 ]; then
print_success "Python $PYTHON_VERSION detected"
else
print_error "Python 3.12+ required (found $PYTHON_VERSION)"
exit 1
fi
else
print_error "Python 3 not found. Please install Python 3.12+"
exit 1
fi
# Check pip
if ! command -v pip3 &> /dev/null && ! command -v pip &> /dev/null; then
print_error "pip not found. Please install pip"
exit 1
fi
print_success "pip detected"
# Check Docker for docker install type
if [ "$INSTALL_TYPE" = "docker" ]; then
if ! command -v docker &> /dev/null; then
print_error "Docker not found. Please install Docker"
exit 1
fi
print_success "Docker detected"
if command -v docker-compose &> /dev/null || docker compose version &> /dev/null; then
print_success "Docker Compose detected"
else
print_warning "Docker Compose not found. Some features may be limited"
fi
fi
}
# Install via pip
install_pip() {
print_status "Installing CodeFlow Engine via pip..."
# Recommend virtual environment
if [ -z "$VIRTUAL_ENV" ] && [ "$INSTALL_TYPE" != "minimal" ]; then
print_warning "Consider using a virtual environment: python3 -m venv venv && source venv/bin/activate"
fi
case "$INSTALL_TYPE" in
"minimal")
print_status "Installing minimal package (core only, no extras)..."
pip3 install --no-deps codeflow-engine || {
print_error "Installation failed"
exit 1
}
;;
"standard")
print_status "Installing standard package with common dependencies..."
pip3 install codeflow-engine || {
print_error "Installation failed"
exit 1
}
;;
"full")
print_status "Installing full package with all features..."
pip3 install "codeflow-engine[full]" || {
print_error "Installation failed"
exit 1
}
;;
"dev")
print_status "Installing development package..."
if [ -f "pyproject.toml" ]; then
# We're in the repo
pip3 install -e ".[dev]" || {
print_error "Installation failed"
exit 1
}
else
# Clone and install
print_status "Cloning repository..."
CLONE_DIR=$(mktemp -d)
if git clone https://github.com/JustAGhosT/codeflow-engine.git "${CLONE_DIR}/codeflow-engine"; then
cd "${CLONE_DIR}/codeflow-engine/engine"
pip3 install -e ".[dev]" || {
print_error "Installation failed"
rm -rf "${CLONE_DIR}"
exit 1
}
print_status "Repository cloned to: ${CLONE_DIR}/codeflow-engine/engine"
else
print_error "Failed to clone repository"
rm -rf "${CLONE_DIR}"
exit 1
fi
fi
;;
esac
print_success "CodeFlow Engine installed successfully!"
}
# Install via Docker
install_docker() {
print_status "Setting up Docker installation..."
# Create directory if not in repo
if [ ! -f "docker-compose.yml" ]; then
print_status "Creating CodeFlow directory..."
mkdir -p codeflow-engine && cd codeflow-engine || {
print_error "Failed to create directory"
exit 1
}
# Download docker-compose.yml with retry
print_status "Downloading Docker Compose configuration..."
for i in 1 2 3; do
if curl -sSL --fail https://raw.githubusercontent.com/JustAGhosT/codeflow-engine/master/engine/docker-compose.yml -o docker-compose.yml; then
break
fi
if [ "$i" -eq 3 ]; then
print_error "Failed to download docker-compose.yml after 3 attempts"
exit 1
fi
print_warning "Download failed, retrying... ($i/3)"
sleep 2
done
for i in 1 2 3; do
if curl -sSL --fail https://raw.githubusercontent.com/JustAGhosT/codeflow-engine/master/engine/configs/.env.example -o .env.example; then
break
fi
if [ "$i" -eq 3 ]; then
print_error "Failed to download .env.example after 3 attempts"
exit 1
fi
print_warning "Download failed, retrying... ($i/3)"
sleep 2
done
fi
# Create .env file if it doesn't exist
if [ ! -f ".env" ]; then
print_status "Creating .env file from template..."
cp .env.example .env
print_warning "Please edit .env file with your API keys before starting"
fi
print_success "Docker setup complete!"
echo ""
print_status "To start CodeFlow Engine:"
echo " 1. Edit .env with your API keys"
echo " 2. Run: docker compose up -d"
}
# Create environment file
setup_env() {
if [ ! -f ".env" ] && [ -f ".env.example" ]; then
print_status "Creating .env from template..."
cp .env.example .env
print_warning "Remember to edit .env with your API keys!"
fi
}
# Post-install instructions
show_next_steps() {
echo ""
echo "=========================================="
print_success "Installation Complete!"
echo "=========================================="
echo ""
echo "Next steps:"
echo ""
echo " 1. Set up your API keys:"
echo " export GITHUB_TOKEN=ghp_your_token"
echo " export OPENAI_API_KEY=sk-your_key"
echo ""
echo " 2. Run CodeFlow CLI:"
echo " CodeFlow --help"
echo ""
echo " 3. Add to your GitHub repo:"
echo " CodeFlow init # Creates .github/workflows/codeflow.yml"
echo ""
echo " 4. Or use Docker:"
echo " docker-compose up -d"
echo ""
echo "Documentation: https://github.com/JustAGhosT/codeflow-engine"
echo ""
}
# GitHub Action setup helper
setup_github_action() {
print_status "Setting up GitHub Action workflow..."
mkdir -p .github/workflows
cat > .github/workflows/codeflow.yml << 'EOF'
# CodeFlow Engine - AI-Powered PR Analysis
# Generated by install.sh
name: CodeFlow Analysis
on:
pull_request:
types: [opened, synchronize, reopened]
issue_comment:
types: [created]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
analyze:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install CodeFlow Engine
run: pip install codeflow-engine
- name: Run PR Analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
CodeFlow analyze \
--repo ${{ github.repository }} \
--pr ${{ github.event.pull_request.number }}
EOF
print_success "Created .github/workflows/codeflow.yml"
print_warning "Remember to add OPENAI_API_KEY to your repository secrets!"
}
# Main installation flow
main() {
case "$INSTALL_TYPE" in
"action")
setup_github_action
;;
"docker")
check_prerequisites
install_docker
;;
*)
check_prerequisites
install_pip
setup_env
show_next_steps
;;
esac
}
# Run main
main