forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmokeTests.sh
executable file
·92 lines (69 loc) · 2.03 KB
/
smokeTests.sh
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
# Strict mode, exit on error, undefined variables, and pipe failures
set -euo pipefail
# Print some information about the environment to aid in case of troubleshooting
echo "node version:"
node --version
echo "python version:"
python3 --version
echo "make version:"
make --version
echo "gcc version:"
gcc --version
echo "g++ version:"
g++ --version
# Check Node.js version
REQUIRED_NODE_VERSION=23
CURRENT_NODE_VERSION=$(node -v | cut -d'.' -f1 | sed 's/v//')
if (( CURRENT_NODE_VERSION < REQUIRED_NODE_VERSION )); then
echo "Error: Node.js version must be $REQUIRED_NODE_VERSION or higher. Current version is $CURRENT_NODE_VERSION."
exit 1
fi
# Autodetect project directory relative to this script's path
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$PROJECT_DIR"
cp .env.example .env
pnpm install -r
pnpm build
# Create temp file and ensure cleanup
OUTFILE="$(mktemp)"
trap 'rm -f "$OUTFILE"' EXIT
echo "Using temporary output file: $OUTFILE"
# Add timeout configuration
TIMEOUT=30
INTERVAL=0.5
TIMER=0
(
# Wait for the ready message with timeout
while true; do
if [[ $TIMER -ge $TIMEOUT ]]; then
echo "Error: Timeout waiting for application to start after $TIMEOUT seconds"
kill $$
exit 1
fi
if grep -q "Chat started" "$OUTFILE"; then
echo "exit"; sleep 2
break
fi
sleep $INTERVAL
TIMER=$(echo "$TIMER + $INTERVAL" | bc)
done
) | pnpm start --character=characters/trump.character.json > "$OUTFILE" &
# Wait for process to finish
wait $!
RESULT=$?
echo "----- OUTPUT START -----"
cat "$OUTFILE"
echo "----- OUTPUT END -----"
# Check the exit code of the last command
if [[ $RESULT -ne 0 ]]; then
echo "Error: 'start' command exited with an error (code: $RESULT)"
exit 1
fi
# Check if output contains expected termination message
if grep -q "Terminating and cleaning up resources..." "$OUTFILE"; then
echo "Script completed successfully."
else
echo "Error: The output does not contain the expected termination message."
exit 1
fi