-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate-and-test-all.sh
More file actions
executable file
·136 lines (118 loc) · 4.55 KB
/
Copy pathvalidate-and-test-all.sh
File metadata and controls
executable file
·136 lines (118 loc) · 4.55 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
#!/bin/bash
set -euo pipefail
# Full validation pipeline: check → bootstrap → build → deploy → test.
#
# Flags:
# --clean Clean build artifacts first
# --skip-checks Skip lint/format/typecheck phase
# --skip-bootstrap Reuse existing local network
# --skip-acceptance Skip acceptance tests
# --skip-e2e Skip E2E tests
# --include-vite-e2e Include Vite dev server E2E tests
#
# Behavior:
# Vite E2E tests are excluded by default. Pass --include-vite-e2e to run them.
source "$(dirname "$0")/scripts/constants.sh"
# 🔧 Require pinned icp-cli version (must match CI)
CURRENT_ICP_VERSION=$(icp --version 2>/dev/null | awk '{print $2}' || echo "not installed")
if [ "$CURRENT_ICP_VERSION" != "$ICP_CLI_VERSION" ]; then
echo "❌ icp-cli version mismatch: expected ${ICP_CLI_VERSION}, got ${CURRENT_ICP_VERSION}"
echo " Run: npm install -g @icp-sdk/icp-cli@${ICP_CLI_VERSION}"
exit 1
fi
# ⏱️ Per-step timing
SCRIPT_START_TIME=$(date +%s)
T_STATIC=0
T_BOOTSTRAP=0
T_BUILD=0
T_CARGO=0
T_DEPLOY=0
T_TEST=0
print_summary() {
local total=$(( $(date +%s) - SCRIPT_START_TIME ))
echo ""
if [ "$SKIP_CHECKS" != "true" ]; then
printf " 🔍 Static analysis %02d:%02d\n" $(( T_STATIC / 60 )) $(( T_STATIC % 60 ))
fi
if [ "$SKIP_BOOTSTRAP" != "true" ]; then
printf " 🌐 Bootstrap %02d:%02d\n" $(( T_BOOTSTRAP / 60 )) $(( T_BOOTSTRAP % 60 ))
fi
printf " 🔨 Build %02d:%02d\n" $(( T_BUILD / 60 )) $(( T_BUILD % 60 ))
printf " 🚀 Deploy %02d:%02d\n" $(( T_DEPLOY / 60 )) $(( T_DEPLOY % 60 ))
printf " ⚡ Cargo pre-compile %02d:%02d\n" $(( T_CARGO / 60 )) $(( T_CARGO % 60 ))
printf " 🧪 Test %02d:%02d\n" $(( T_TEST / 60 )) $(( T_TEST % 60 ))
printf " ─────────────────────────────\n"
printf " Total %02d:%02d\n" $(( total / 60 )) $(( total % 60 ))
echo ""
echo "✅ Validation finished correctly!"
}
trap print_summary EXIT
# 🚩 Parse flags
CLEAN="false"
SKIP_CHECKS="false"
SKIP_BOOTSTRAP="false"
SKIP_ACCEPTANCE="false"
SKIP_E2E="false"
INCLUDE_VITE_E2E="false"
if [[ "$*" == *"--clean"* ]]; then CLEAN="true"; fi
if [[ "$*" == *"--skip-checks"* ]]; then SKIP_CHECKS="true"; fi
if [[ "$*" == *"--skip-bootstrap"* ]]; then SKIP_BOOTSTRAP="true"; fi
if [[ "$*" == *"--skip-acceptance"* ]]; then SKIP_ACCEPTANCE="true"; fi
if [[ "$*" == *"--skip-e2e"* ]]; then SKIP_E2E="true"; fi
if [[ "$*" == *"--include-vite-e2e"* ]]; then INCLUDE_VITE_E2E="true"; fi
if [ "$CLEAN" = "true" ]; then
icp network stop local 2>/dev/null || true
./scripts/clean.sh
fi
# --- 🔍 Phase 1: Static analysis ---
if [ "$SKIP_CHECKS" != "true" ]; then
t=$(date +%s)
./scripts/01-check.sh
T_STATIC=$(( $(date +%s) - t ))
fi
# --- 🌐 Phase 2: Bootstrap local network ---
if [ "$SKIP_BOOTSTRAP" != "true" ]; then
t=$(date +%s)
./scripts/02-bootstrap.sh
T_BOOTSTRAP=$(( $(date +%s) - t ))
fi
# --- 🔨 Phase 3: Build ---
t=$(date +%s)
./scripts/03-build.sh
T_BUILD=$(( $(date +%s) - t ))
# ⚡ Pre-compile acceptance test binaries in background while deploy runs
echo "⚡ Pre-compiling acceptance test binaries..."
cargo_start=$(date +%s)
cargo build -p my-canister-dapp-cli -p demos-test &
pid_cdt=$!
# --- 🚀 Phase 4: Deploy ---
t=$(date +%s)
./scripts/04-deploy.sh
T_DEPLOY=$(( $(date +%s) - t ))
# --- 🧪 Phase 5: Test ---
echo "⏳ Waiting for acceptance test compilation..."
wait $pid_cdt
echo "✅ Acceptance test binaries compiled"
T_CARGO=$(( $(date +%s) - cargo_start ))
t=$(date +%s)
if [ "$SKIP_ACCEPTANCE" = "true" ] && [ "$SKIP_E2E" = "true" ]; then
./scripts/05-test.sh --skip-acceptance --skip-e2e
elif [ "$SKIP_ACCEPTANCE" = "true" ]; then
./scripts/05-test.sh --skip-acceptance
elif [ "$SKIP_E2E" = "true" ]; then
./scripts/05-test.sh --skip-e2e
elif [ "$INCLUDE_VITE_E2E" = "true" ]; then
./scripts/05-test.sh --include-vite-e2e
else
./scripts/05-test.sh
fi
T_TEST=$(( $(date +%s) - t ))
# 🌐 Print local canister URLs
echo ""
echo "🌐 Local canister URLs:"
icp canister status -e local --json 2>/dev/null | while IFS= read -r line; do
name=$(echo "$line" | python3 -c "import sys,json; print(json.loads(sys.stdin.read())['name'])")
id=$(echo "$line" | python3 -c "import sys,json; print(json.loads(sys.stdin.read())['id'])")
printf " %-25s http://%s.localhost:8080\n" "$name" "$id"
printf " %-25s http://%s.local.localhost:8080\n" "" "$name"
done