Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "chore: improve smokeTests environment validation and logging" #1051

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 23 additions & 29 deletions scripts/smokeTests.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/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:"
Expand Down Expand Up @@ -30,63 +27,60 @@ if (( CURRENT_NODE_VERSION < REQUIRED_NODE_VERSION )); then
fi

# Autodetect project directory relative to this script's path
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PROJECT_DIR="$0"
while [ -h "$PROJECT_DIR" ]; do
ls=$(ls -ld "$PROJECT_DIR")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' > /dev/null; then
PROJECT_DIR="$link"
else
PROJECT_DIR="$(dirname "$PROJECT_DIR")/$link"
fi
done
PROJECT_DIR="$(dirname "$PROJECT_DIR")/.."
PROJECT_DIR="$(cd "$PROJECT_DIR"; pwd)"

cd "$PROJECT_DIR"
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

echo $OUTFILE
(
# Wait for the ready message with timeout
# Wait for the ready message
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)
sleep 0.5
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)"
echo "Error: 'start' command exited with an error."
exit 1
fi

# Check if output contains expected termination message
# Check if output.txt contains "Terminating and cleaning up resources..."
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."
echo "Error: The output does not contain the expected string."
exit 1
fi
fi

# Clean up
rm "$OUTFILE"
Loading