-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathvalidate-ci.sh
More file actions
92 lines (77 loc) · 2.41 KB
/
validate-ci.sh
File metadata and controls
92 lines (77 loc) · 2.41 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
#!/bin/bash
# Local CI/CD Validation Script
# This script runs the same checks as the GitHub Actions workflow
echo "🔄 Running CI/CD Pipeline Validation locally..."
echo
# Set environment variable
export CARGO_TERM_COLOR=always
echo "📦 Installing Rust toolchain and dependencies..."
rustup target add wasm32-unknown-unknown
cargo install cargo-fuzz 2>/dev/null || echo "⚠️ cargo-fuzz already installed"
echo
echo "🔍 Running code quality checks..."
# Check formatting
echo " 📝 Checking code formatting..."
if cargo fmt --all -- --check; then
echo " ✅ Code formatting: PASSED"
else
echo " ❌ Code formatting: FAILED"
echo " Run 'cargo fmt' to fix formatting issues"
exit 1
fi
# Run clippy
echo " 🔍 Running clippy linting..."
if cargo clippy --target wasm32-unknown-unknown -- -D warnings; then
echo " ✅ Clippy linting: PASSED"
else
echo " ❌ Clippy linting: FAILED"
echo " Fix clippy warnings before committing"
exit 1
fi
echo
echo "🏗️ Building contract..."
# Build WASM contract
echo " 🏗️ Building WASM contract..."
if cargo build --target wasm32-unknown-unknown --release; then
echo " ✅ WASM build: PASSED"
else
echo " ❌ WASM build: FAILED"
exit 1
fi
echo
echo "🧪 Running tests..."
# Run unit tests
echo " 🧪 Running unit tests..."
if cargo test; then
echo " ✅ Unit tests: PASSED"
else
echo " ❌ Unit tests: FAILED"
exit 1
fi
# Check fuzz tests
echo " 🔍 Checking fuzz tests..."
if [ -d "contracts/utility_contracts/fuzz" ]; then
echo " ✅ Fuzz tests: AVAILABLE"
echo " 📁 Fuzz test directory found"
# List available fuzz targets
if [ -f "contracts/utility_contracts/fuzz/Cargo.toml" ]; then
echo " 🎯 Available fuzz targets:"
grep -A 1 "\[\[bin\]" contracts/utility_contracts/fuzz/Cargo.toml | grep "name" | sed 's/.*name = "//g' | sed 's/"//g' | sed 's/^/ - /'
fi
else
echo " ⚠️ Fuzz tests: NOT FOUND"
fi
echo
echo "📊 Pipeline Summary:"
echo " ✅ Code formatting: PASSED"
echo " ✅ Clippy linting: PASSED"
echo " ✅ WASM build: PASSED"
echo " ✅ Unit tests: PASSED"
if [ -d "contracts/utility_contracts/fuzz" ]; then
echo " ✅ Fuzz tests: AVAILABLE"
else
echo " ⚠️ Fuzz tests: NOT AVAILABLE"
fi
echo
echo "🎉 All checks passed! Your code is ready for commit/PR."
echo "💡 Run this script before committing to ensure CI/CD will pass."