-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
269 lines (225 loc) Β· 8.92 KB
/
deploy.sh
File metadata and controls
269 lines (225 loc) Β· 8.92 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
#!/bin/bash
#
# Hydra CI/CD Integration - One-Step Deployment Script
#
# This script deploys the complete CI/CD infrastructure to your Hydra repository.
# Run this from your Hydra project root directory.
#
# Usage:
# cd /path/to/hydra
# bash <(curl -s https://raw.githubusercontent.com/.../deploy.sh)
#
# Or if you have the integration package:
# cd /path/to/hydra
# /path/to/integration/deploy-to-hydra.sh
#
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
# Fancy output
print_header() {
echo ""
echo -e "${BLUE}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${BLUE}β${NC} $1"
echo -e "${BLUE}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
}
print_success() {
echo -e "${GREEN}β${NC} $1"
}
print_error() {
echo -e "${RED}β${NC} $1"
}
print_warning() {
echo -e "${YELLOW}β ${NC} $1"
}
print_info() {
echo -e "${CYAN}βΉ${NC} $1"
}
# Banner
clear
echo -e "${CYAN}"
cat << "EOF"
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β βββ ββββββ ββββββββββ βββββββ ββββββ β
β βββ βββββββ ββββββββββββββββββββββββββββ β
β ββββββββ βββββββ βββ βββββββββββββββββββ β
β ββββββββ βββββ βββ βββββββββββββββββββ β
β βββ βββ βββ βββββββββββ ββββββ βββ β
β βββ βββ βββ βββββββ βββ ββββββ βββ β
β β
β CI/CD Integration Deployment Script β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
EOF
echo -e "${NC}"
# Check if we're in a git repository
if [ ! -d ".git" ]; then
print_error "This doesn't appear to be a git repository."
print_info "Please run this script from your Hydra project root directory."
exit 1
fi
print_success "Found git repository"
# Get the script directory (where integration files are)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
print_info "Integration files location: $SCRIPT_DIR"
# Check if integration files exist
if [ ! -f "$SCRIPT_DIR/.github-workflows-ci.yml" ]; then
print_error "Cannot find integration files in $SCRIPT_DIR"
print_info "Please ensure you've extracted the integration package."
exit 1
fi
print_success "Found integration files"
# Confirm deployment
print_header "Deployment Confirmation"
echo ""
echo "This script will deploy CI/CD integration to:"
echo " Repository: $(pwd)"
echo " Integration: $SCRIPT_DIR"
echo ""
echo "The following will be created/modified:"
echo " β’ .github/workflows/ci.yml"
echo " β’ patches/qemu-hydra-device.patch"
echo " β’ scripts/build.sh"
echo " β’ scripts/guest-utils/hydra-test-suite"
echo " β’ sim/verilator_socket_server.cpp"
echo " β’ docs/INTEGRATION.md"
echo ""
read -p "Continue? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_warning "Deployment cancelled"
exit 0
fi
print_header "Step 1: Creating Directory Structure"
# Create directories
mkdir -p .github/workflows
print_success "Created .github/workflows/"
mkdir -p patches
print_success "Created patches/"
mkdir -p scripts/guest-utils
print_success "Created scripts/guest-utils/"
mkdir -p sim
print_success "Created sim/"
mkdir -p docs
print_success "Created docs/"
print_header "Step 2: Copying GitHub Actions Workflow"
cp "$SCRIPT_DIR/.github-workflows-ci.yml" .github/workflows/ci.yml
print_success "Installed GitHub Actions workflow"
print_info "Location: .github/workflows/ci.yml"
print_header "Step 3: Installing QEMU Patch"
cp "$SCRIPT_DIR/patches/qemu-hydra-device.patch" patches/
print_success "Installed QEMU device patch"
print_info "Location: patches/qemu-hydra-device.patch"
print_header "Step 4: Installing Build Automation"
cp "$SCRIPT_DIR/scripts/build.sh" scripts/
chmod +x scripts/build.sh
print_success "Installed build automation script"
print_info "Location: scripts/build.sh"
print_header "Step 5: Installing Test Suite"
cp "$SCRIPT_DIR/scripts/guest-utils/hydra-test-suite" scripts/guest-utils/
chmod +x scripts/guest-utils/hydra-test-suite
print_success "Installed TinyCore test suite"
print_info "Location: scripts/guest-utils/hydra-test-suite"
print_header "Step 6: Installing Verilator Backend"
cp "$SCRIPT_DIR/sim/verilator_socket_server.cpp" sim/
print_success "Installed Verilator socket server"
print_info "Location: sim/verilator_socket_server.cpp"
print_header "Step 7: Installing Documentation"
cp "$SCRIPT_DIR/INTEGRATION.md" docs/
print_success "Installed technical documentation"
print_info "Location: docs/INTEGRATION.md"
if [ -f "$SCRIPT_DIR/DEPLOYMENT.md" ]; then
cp "$SCRIPT_DIR/DEPLOYMENT.md" docs/
print_success "Installed deployment guide"
print_info "Location: docs/DEPLOYMENT.md"
fi
if [ -f "$SCRIPT_DIR/QUICKREF.txt" ]; then
cp "$SCRIPT_DIR/QUICKREF.txt" docs/
print_success "Installed quick reference"
print_info "Location: docs/QUICKREF.txt"
fi
print_header "Step 8: Verifying RTL Interface"
if [ -f "rtl/hydra_top.sv" ]; then
print_success "Found rtl/hydra_top.sv"
# Check for required ports
has_clk=$(grep -c "input.*clk" rtl/hydra_top.sv || echo 0)
has_rst=$(grep -c "input.*rst" rtl/hydra_top.sv || echo 0)
has_cam=$(grep -c "cam_pos\|cam_dir" rtl/hydra_top.sv || echo 0)
if [ "$has_clk" -gt 0 ] && [ "$has_rst" -gt 0 ]; then
print_success "Basic clock and reset found"
else
print_warning "Could not verify clock/reset signals"
fi
if [ "$has_cam" -gt 0 ]; then
print_success "Camera interface signals found"
else
print_warning "Camera interface may need adjustment"
print_info "Expected ports: cam_pos_x, cam_pos_y, cam_pos_z, cam_dir_x, cam_dir_y, cam_dir_z"
print_info "See docs/INTEGRATION.md for complete interface specification"
fi
else
print_warning "rtl/hydra_top.sv not found"
print_info "You may need to create a top-level wrapper"
print_info "See docs/INTEGRATION.md for required interface"
fi
print_header "Step 9: Git Status"
echo ""
echo "New files to be committed:"
git status --short | grep -E "^\?\?" || echo " (no untracked files)"
echo ""
echo "Modified files:"
git status --short | grep -E "^.M" || echo " (no modified files)"
echo ""
read -p "Add files to git? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
git add .github/workflows/ci.yml
git add patches/
git add scripts/
git add sim/
git add docs/
print_success "Files added to git"
else
print_info "Skipped git add. Run manually: git add .github patches scripts sim docs"
fi
print_header "Deployment Complete!"
echo ""
print_success "CI/CD integration successfully deployed!"
echo ""
echo -e "${CYAN}Next Steps:${NC}"
echo ""
echo "1. Review the changes:"
echo " git status"
echo " git diff --cached"
echo ""
echo "2. Test locally (recommended):"
echo " ./scripts/build.sh all"
echo " ./scripts/build.sh test"
echo ""
echo "3. Commit and push:"
echo " git commit -m \"Add CI/CD integration infrastructure\""
echo " git push origin main"
echo ""
echo "4. Monitor the CI pipeline:"
echo " β’ Go to GitHub β Actions tab"
echo " β’ Watch the first build (will take ~60 min)"
echo " β’ Subsequent builds will be ~25 min (cached)"
echo ""
echo -e "${CYAN}Documentation:${NC}"
echo " β’ Quick reference: cat docs/QUICKREF.txt"
echo " β’ Technical details: cat docs/INTEGRATION.md"
echo " β’ Deployment guide: cat docs/DEPLOYMENT.md"
echo ""
echo -e "${CYAN}Local Testing:${NC}"
echo " ./scripts/build.sh --help # See all commands"
echo " ./scripts/build.sh all # Build everything"
echo " ./scripts/build.sh test # Run integration test"
echo ""
echo -e "${GREEN}π Your Hydra project now has professional CI/CD automation! π${NC}"
echo ""