-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-workflows.sh
More file actions
executable file
·377 lines (331 loc) · 9.74 KB
/
custom-workflows.sh
File metadata and controls
executable file
·377 lines (331 loc) · 9.74 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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#!/usr/bin/env bash
# Custom Workflow Examples
# Add these to your ~/.zshrc or ~/.bashrc after sourcing rust-bundles.sh
# ============================================================================
# PROJECT-SPECIFIC WORKFLOWS
# ============================================================================
# Database workflow
cdb() {
echo "🗄️ Database Workflow" &&
cargo run --bin migrate reset &&
cargo run --bin migrate up &&
cargo run --bin seed &&
echo "✅ Database ready!"
}
# API server workflow
capi() {
echo "🌐 Starting API server..." &&
cargo fmt &&
cargo clippy -- -D warnings &&
cargo test &&
cargo run --bin api-server
}
# Deploy workflow
cdeploy() {
echo "🚀 Deploying..." &&
cci &&
cargo build --release --target x86_64-unknown-linux-musl &&
scp target/x86_64-unknown-linux-musl/release/myapp server:/opt/apps/ &&
ssh server "systemctl restart myapp" &&
echo "✅ Deployed!"
}
# ============================================================================
# TEAM WORKFLOWS
# ============================================================================
# Before standup
cmystandup() {
echo "📊 Standup Prep" &&
git fetch &&
git status &&
chealth &&
cargo build --release &&
echo "✅ Ready for standup!"
}
# Code review workflow
creview() {
local branch=${1:-main}
echo "👀 Reviewing changes from $branch..." &&
git diff "$branch"...HEAD --stat &&
cci &&
cargo semver-checks &&
echo "✅ Review complete!"
}
# Pair programming setup
cpair() {
echo "👥 Pair Programming Setup" &&
cargo clean &&
cargo build &&
cargo test &&
cwatchdev
}
# ============================================================================
# LIBRARY-SPECIFIC WORKFLOWS
# ============================================================================
# Library release workflow
clibrelease() {
echo "📦 Library Release Workflow" &&
cprelease &&
cargo doc --open &&
read -p "Documentation looks good? (y/n): " confirm &&
if [[ $confirm == [yY] ]]; then
crelease "$1" &&
cargo publish
fi
}
# Check all examples
cexamples() {
echo "📚 Checking all examples..." &&
for example in examples/*.rs; do
local name
name=$(basename "$example" .rs)
echo "▸ Testing example: $name" &&
cargo run --example "$name" || return 1
done &&
echo "✅ All examples work!"
}
# ============================================================================
# PERFORMANCE WORKFLOWS
# ============================================================================
# Optimization workflow
copt() {
echo "⚡ Optimization Workflow" &&
cargo build --release &&
cargo bloat --release --crates &&
cargo criterion --bench "$1" &&
cargo flamegraph --bin "$2" &&
echo "✅ Optimization analysis complete!"
}
# Compare performance
ccompare() {
echo "📊 Performance Comparison" &&
git stash &&
cargo criterion --bench "$1" --save-baseline before &&
git stash pop &&
cargo criterion --bench "$1" --baseline before &&
echo "✅ Comparison complete!"
}
# ============================================================================
# DOCUMENTATION WORKFLOWS
# ============================================================================
# Documentation workflow
cdocs() {
echo "📚 Documentation Workflow" &&
cargo doc --all-features --document-private-items --open &&
cargo test --doc &&
echo "✅ Documentation ready!"
}
# Update README examples
creadme() {
echo "📝 Testing README examples..." &&
cargo test --doc &&
cargo run --example readme_example &&
echo "✅ README examples verified!"
}
# ============================================================================
# TESTING WORKFLOWS
# ============================================================================
# Integration test workflow
cintegration() {
echo "🔗 Integration Tests" &&
docker-compose up -d &&
sleep 5 &&
cargo test --test integration &&
docker-compose down &&
echo "✅ Integration tests complete!"
}
# End-to-end test workflow
ce2e() {
echo "🎭 E2E Tests" &&
cargo build --release &&
./scripts/start-test-env.sh &&
cargo test --test e2e -- --test-threads=1 &&
./scripts/stop-test-env.sh &&
echo "✅ E2E tests complete!"
}
# Stress test
cstress() {
echo "💪 Stress Testing" &&
cargo build --release &&
cargo bench --bench stress_test &&
echo "✅ Stress test complete!"
}
# ============================================================================
# SPECIALIZED WORKFLOWS
# ============================================================================
# WASM build workflow
cwasm() {
echo "🌐 WASM Build" &&
cargo build --target wasm32-unknown-unknown &&
wasm-pack build --target web &&
echo "✅ WASM build complete!"
}
# Cross-compilation workflow
ccross() {
echo "🌍 Cross-Compilation" &&
cargo build --target x86_64-unknown-linux-gnu &&
cargo build --target x86_64-apple-darwin &&
cargo build --target x86_64-pc-windows-gnu &&
echo "✅ Cross-compilation complete!"
}
# Mobile build
cmobile() {
echo "📱 Mobile Build" &&
cargo build --target aarch64-linux-android &&
cargo build --target aarch64-apple-ios &&
echo "✅ Mobile builds complete!"
}
# ============================================================================
# CONTINUOUS INTEGRATION WORKFLOWS
# ============================================================================
# Local CI simulation (advanced)
ccilocal() {
echo "🤖 Advanced CI Simulation" &&
echo "Running in clean container..." &&
docker run --rm -v "$(pwd)":/app -w /app rust:latest bash -c "
cargo fmt -- --check &&
cargo clippy --all-targets --all-features -- -D warnings &&
cargo test --all-features &&
cargo doc --no-deps &&
cargo build --release
" &&
echo "✅ Local CI complete!"
}
# PR checks
cprcheck() {
echo "✅ PR Checks" &&
git fetch origin main &&
cargo fmt -- --check &&
cargo clippy --all-targets --all-features -- -D warnings &&
cargo test --all-features &&
cargo semver-checks check-release &&
git diff origin/main...HEAD --name-only &&
echo "✅ PR ready!"
}
# ============================================================================
# CLEANUP WORKFLOWS
# ============================================================================
# Deep clean
cdeepclean() {
echo "🧹 Deep Clean" &&
cargo clean &&
rm -rf target/ &&
rm -f Cargo.lock &&
cargo build &&
cargo test &&
echo "✅ Deep clean complete!"
}
# Clean old artifacts
ccleanold() {
echo "🧹 Cleaning old artifacts..." &&
cargo sweep --time 30 &&
echo "✅ Old artifacts cleaned!"
}
# ============================================================================
# DEBUG WORKFLOWS
# ============================================================================
# Debug build and run with logging
cdebug() {
echo "🐛 Debug Mode" &&
RUST_BACKTRACE=1 RUST_LOG=debug cargo run "$@"
}
# Debug with full backtrace
cdebugfull() {
echo "🐛 Debug Mode (Full Backtrace)" &&
RUST_BACKTRACE=full RUST_LOG=trace cargo run "$@"
}
# Run with profiler
cprofile() {
echo "📊 Profiling..." &&
cargo build --release &&
perf record -g ./target/release/"$1" &&
perf report &&
echo "✅ Profiling complete!"
}
# ============================================================================
# UTILITY WORKFLOWS
# ============================================================================
# Quick benchmark
cqbench() {
echo "⏱️ Quick Benchmark" &&
cargo build --release &&
hyperfine './target/release/'"$1"
}
# Size optimization
csize() {
echo "📦 Size Optimization" &&
cargo build --release &&
strip target/release/"$1" &&
upx --best --lzma target/release/"$1" &&
ls -lh target/release/"$1" &&
echo "✅ Size optimized!"
}
# License check
clicense() {
echo "⚖️ License Check" &&
cargo license &&
cargo deny check licenses &&
echo "✅ Licenses OK!"
}
# ============================================================================
# COLLABORATIVE WORKFLOWS
# ============================================================================
# Before PR review
cprreview() {
echo "👀 Before PR Review" &&
git pull origin main &&
cargo update &&
cci &&
echo "✅ Ready to review PRs!"
}
# Merge preparation
cmerge() {
local branch=${1:-main}
echo "🔀 Merge Preparation" &&
git fetch origin "$branch" &&
git merge "origin/$branch" &&
cargo update &&
cargo test &&
echo "✅ Ready to merge!"
}
# ============================================================================
# CUSTOM HELP FUNCTION
# ============================================================================
# Show custom workflows
cmyhelp() {
echo "🛠️ Custom Workflows"
echo ""
echo "Project:"
echo " cdb Database workflow"
echo " capi API server workflow"
echo " cdeploy Deploy workflow"
echo ""
echo "Team:"
echo " cmystandup Standup preparation"
echo " creview Code review workflow"
echo " cpair Pair programming setup"
echo ""
echo "Library:"
echo " clibrelease Library release workflow"
echo " cexamples Check all examples"
echo ""
echo "Performance:"
echo " copt Optimization workflow"
echo " ccompare Compare performance"
echo ""
echo "Testing:"
echo " cintegration Integration tests"
echo " ce2e End-to-end tests"
echo ""
echo "Specialized:"
echo " cwasm WASM build"
echo " ccross Cross-compilation"
echo ""
echo "Debug:"
echo " cdebug Debug with logging"
echo " cprofile Profile application"
echo ""
}
# ============================================================================
# INITIALIZATION MESSAGE
# ============================================================================
echo "✅ Custom workflows loaded! Type 'cmyhelp' for a list."