Repository navigation
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·287 lines (239 loc) · 7.98 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·287 lines (239 loc) · 7.98 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
#!/bin/bash
# Backtide Development Workflow Helper
# This script provides shortcuts for common development tasks
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
# Function to print colored output
print_color() {
local color=$1
local message=$2
echo -e "${color}${message}${NC}"
}
# Function to show usage
usage() {
echo "Backtide Development Workflow Helper"
echo ""
echo "Usage: ./dev.sh <command> [options]"
echo ""
echo "Commands:"
echo " start <feature> Start new feature branch"
echo " test Run tests and quality checks"
echo " build Build and verify binary"
echo " pr Create PR checklist"
echo " release Prepare for release"
echo " status Show current development status"
echo " help Show this help"
echo ""
echo "Examples:"
echo " ./dev.sh start add-s3-provider"
echo " ./dev.sh test"
echo " ./dev.sh pr"
}
# Function to start new feature
start_feature() {
local feature_name=$1
if [[ -z "$feature_name" ]]; then
print_color $RED "Error: Feature name required"
echo "Usage: ./dev.sh start <feature-name>"
exit 1
fi
local branch_name="feature/$feature_name"
print_color $BLUE "Starting new feature: $feature_name"
# Ensure we're on develop
git checkout develop
git pull origin develop
# Create feature branch
git checkout -b "$branch_name"
print_color $GREEN "✓ Created feature branch: $branch_name"
print_color $YELLOW "You're now on branch: $branch_name"
echo ""
print_color $BLUE "Next steps:"
echo " 1. Make your changes"
echo " 2. Run: ./dev.sh test"
echo " 3. Run: ./dev.sh pr (when ready)"
}
# Function to run tests
run_tests() {
print_color $BLUE "Running quality checks and tests..."
# Check if we're on a feature branch
current_branch=$(git branch --show-current)
if [[ "$current_branch" == "main" || "$current_branch" == "develop" ]]; then
print_color $YELLOW "⚠️ You're on $current_branch branch. Consider using a feature branch."
fi
# Format code
print_color $BLUE "Formatting code..."
make fmt
# Run linters
print_color $BLUE "Running linters..."
make vet
# Run tests
print_color $BLUE "Running tests..."
make test
# Build binary
print_color $BLUE "Building binary..."
make build
# Test binary functionality
print_color $BLUE "Testing binary..."
./backtide --help > /dev/null
./backtide version > /dev/null
print_color $GREEN "✓ All checks passed!"
echo ""
print_color $YELLOW "Ready for commit and PR creation."
}
# Function to build and verify
build_binary() {
print_color $BLUE "Building and verifying binary..."
make clean
make build
print_color $BLUE "Testing binary functionality:"
./backtide version
./backtide --help | head -10
print_color $GREEN "✓ Build successful!"
}
# Function to create PR checklist
create_pr_checklist() {
current_branch=$(git branch --show-current)
print_color $BLUE "PR Preparation Checklist for: $current_branch"
echo ""
# Check if we're on a feature branch
if [[ ! "$current_branch" =~ ^feature/ ]]; then
print_color $YELLOW "⚠️ You're not on a feature branch. PRs should typically be from feature/* branches."
fi
echo "✅ Before creating PR, ensure:"
echo " [ ] All tests pass: ./dev.sh test"
echo " [ ] Code is properly formatted: make fmt"
echo " [ ] Binary builds successfully: ./dev.sh build"
echo " [ ] Commit messages follow conventional format"
echo " [ ] Documentation updated if needed"
echo " [ ] No merge conflicts with develop"
echo ""
echo "📝 PR Creation:"
echo " 1. Push branch: git push -u origin $current_branch"
echo " 2. Go to: https://github.com/mitexleo/backtide/pull/new/$current_branch"
echo " 3. Set base: develop"
echo " 4. Use conventional commit format for title"
echo " 5. Add detailed description"
echo ""
echo "🔍 PR Review Checklist:"
echo " [ ] Code follows project conventions"
echo " [ ] Tests cover new functionality"
echo " [ ] Documentation is updated"
echo " [ ] No breaking changes (unless intentional)"
echo " [ ] Cross-platform compatibility considered"
echo ""
# Check if branch is pushed
if git ls-remote --heads origin "$current_branch" | grep -q "$current_branch"; then
print_color $GREEN "✓ Branch is already pushed to remote"
else
print_color $YELLOW "⚠️ Branch not pushed yet. Run: git push -u origin $current_branch"
fi
}
# Function to prepare for release
prepare_release() {
print_color $BLUE "Release Preparation Checklist"
echo ""
# Ensure we're on develop
current_branch=$(git branch --show-current)
if [[ "$current_branch" != "develop" ]]; then
print_color $RED "Error: Must be on develop branch for release preparation"
echo "Run: git checkout develop"
exit 1
fi
echo "🚀 Preparing for release from develop → main"
echo ""
echo "✅ Pre-release checks:"
echo " [ ] All PRs merged to develop"
echo " [ ] CI tests passing on develop"
echo " [ ] CHANGELOG.md updated (will be auto-updated)"
echo " [ ] Manual testing completed"
echo " [ ] Documentation reviewed"
echo ""
echo "📋 Release process:"
echo " 1. Merge develop to main:"
echo " git checkout main"
echo " git pull origin main"
echo " git merge develop"
echo " git push origin main"
echo " 2. GitHub Actions will automatically:"
echo " - Determine version from commits"
echo " - Create release with binaries"
echo " - Update CHANGELOG.md"
echo ""
# Show recent commits for version estimation
print_color $BLUE "Recent commits (for version estimation):"
git log --oneline -10 --decorate
echo ""
print_color $YELLOW "Note: Version will be automatically determined based on commit types:"
echo " feat: → minor version bump"
echo " fix: → patch version bump"
echo " BREAKING CHANGE: → major version bump"
}
# Function to show development status
show_status() {
current_branch=$(git branch --show-current)
print_color $BLUE "Development Status - Branch: $current_branch"
echo ""
# Show branch info
if [[ "$current_branch" == "main" ]]; then
print_color $GREEN "📍 You're on main (production) branch"
elif [[ "$current_branch" == "develop" ]]; then
print_color $BLUE "📍 You're on develop (integration) branch"
elif [[ "$current_branch" =~ ^feature/ ]]; then
print_color $YELLOW "📍 You're on feature branch: $current_branch"
else
print_color $YELLOW "📍 You're on branch: $current_branch"
fi
echo ""
# Show uncommitted changes
if [[ -n $(git status --porcelain) ]]; then
print_color $YELLOW "📝 You have uncommitted changes:"
git status --porcelain
else
print_color $GREEN "📝 No uncommitted changes"
fi
echo ""
# Show recent commits
print_color $BLUE "Recent commits:"
git log --oneline -5 --decorate
echo ""
# Show version info
if [[ -f "./backtide" ]]; then
print_color $BLUE "Binary version:"
./backtide version 2>/dev/null || echo "Not built with version info"
fi
}
# Main script logic
case $1 in
start)
start_feature "$2"
;;
test)
run_tests
;;
build)
build_binary
;;
pr)
create_pr_checklist
;;
release)
prepare_release
;;
status)
show_status
;;
help|--help|-h|"")
usage
;;
*)
print_color $RED "Error: Unknown command '$1'"
usage
exit 1
;;
esac
# Development workflow automation - Backtide