#!/bin/bash # Run test and cleanup afterwards set -e COMPOSE_FILE="docker-compose-frontend.yml" echo "๐Ÿš€ Running HarborForge Test..." # Clean any previous containers first docker compose -f "$COMPOSE_FILE" down 2>/dev/null || true # Start services echo "๐Ÿ“ฆ Starting services..." docker compose -f "$COMPOSE_FILE" up -d # Wait for frontend to be ready (run curl inside docker network) echo "โณ Waiting for services..." MAX_RETRIES=30 RETRY_COUNT=0 until docker run --rm --network harborforgetest_test-network curlimages/curl -s -o /dev/null -w "%{http_code}" http://frontend:3000/ 2>/dev/null | grep -q "200" || [ $RETRY_COUNT -eq $MAX_RETRIES ]; do echo " Waiting for frontend... ($RETRY_COUNT/$MAX_RETRIES)" sleep 2 RETRY_COUNT=$((RETRY_COUNT+1)) done if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then echo "โŒ Frontend failed to start" docker compose -f "$COMPOSE_FILE" logs docker compose -f "$COMPOSE_FILE" down -v exit 1 fi echo "โœ… Services ready!" # Run test docker compose -f "$COMPOSE_FILE" run --rm test TEST_EXIT_CODE=$? echo "" echo "๐Ÿงน Cleaning up containers and volumes..." docker compose -f "$COMPOSE_FILE" down -v if [ $TEST_EXIT_CODE -eq 0 ]; then echo "โœ… Test passed!" else echo "โŒ Test failed with exit code: $TEST_EXIT_CODE" fi exit $TEST_EXIT_CODE