From c9efcd12c37150450f3dfed1b2c4754d16b907b2 Mon Sep 17 00:00:00 2001 From: Ricardo Carneiro Date: Tue, 17 Jun 2025 17:04:48 -0300 Subject: [PATCH] fix: tests --- .gitea/workflows/deploy.yml | 42 ++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 7b2186c..18ddfa2 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -46,14 +46,42 @@ jobs: # Iniciar container de teste docker run -d --name test-container -p 8080:80 ${{ steps.meta.outputs.LATEST_TAG }} - # Aguardar container iniciar - sleep 10 + # Aguardar nginx inicializar completamente + echo "⏳ Waiting for nginx to start..." + sleep 20 - # Testar se está respondendo - curl -f http://localhost:8080 || exit 1 - curl -f http://localhost:8080/robots.txt || exit 1 - curl -f http://localhost:8080/sitemap.xml || exit 1 - curl -f http://localhost:8080/en/ || exit 1 + # Verificar se container está rodando + echo "📋 Container status:" + docker ps | grep test-container + + # Mostrar logs para debug + echo "📋 Container logs:" + docker logs test-container + + # Verificar se nginx está rodando + echo "🔍 Checking nginx process:" + docker exec test-container ps aux | grep nginx + + # Teste interno primeiro (mais confiável) + echo "🔍 Testing internal connectivity:" + docker exec test-container wget -q --spider http://localhost/ && echo "✅ Internal test OK" || exit 1 + + # Teste externo com retry + echo "🔍 Testing external connectivity:" + for i in {1..5}; do + if curl -f http://localhost:8080; then + echo "✅ External test OK on attempt $i" + break + else + echo "⚠️ Attempt $i failed, retrying..." + sleep 5 + fi + if [ $i -eq 5 ]; then + echo "❌ All attempts failed" + docker logs test-container + exit 1 + fi + done # Parar container de teste docker stop test-container