Skip to content
Open
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
57 changes: 56 additions & 1 deletion test/clean.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,65 @@
#!/bin/bash
set -e

# Parse command line arguments
FORCE_ENV=false
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont have to do this fix anymore. The more correct fix should be to amend the makefile itself, and then add all variable flags for skip building, local dir repo, etc, encapsulated in makefile itself (which is the entrypoint for running the managing the devnet)

while [[ $# -gt 0 ]]; do
case $1 in
--force-env|-f)
FORCE_ENV=true
shift
;;
--help|-h)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --force-env, -f Force update .env file from example.env"
echo " --help, -h Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done

echo " 🧹 Cleaning up Optimism test environment..."

# Stop Docker containers before handling .env file
# This ensures docker-compose has access to the current .env file
echo " 📦 Stopping Docker containers..."
[ -f .env ] && docker compose down
if [ -f .env ]; then
docker compose down 2>/dev/null || true
elif [ -f example.env ]; then
# If .env doesn't exist but example.env does, temporarily use it for docker compose down
cp example.env .env.tmp
docker compose --env-file .env.tmp down 2>/dev/null || true
rm -f .env.tmp
fi

# Handle .env file
if [ "$FORCE_ENV" = true ]; then
echo " 🔄 Force updating .env from example.env..."
if [ -f example.env ]; then
cp example.env .env
echo " ✅ .env has been force updated from example.env"
else
echo " ⚠️ example.env not found, skipping .env update"
fi
elif [ ! -f .env ]; then
echo " 📝 .env file not found, creating from example.env..."
if [ -f example.env ]; then
cp example.env .env
echo " ✅ .env created from example.env"
else
echo " ⚠️ example.env not found, please create .env manually"
fi
else
echo " ✓ .env file exists, keeping current configuration"
echo " 💡 Use --force-env flag to update .env from example.env"
fi

echo " 🗑️ Removing generated files..."
rm -rf data
Expand Down