diff --git a/.github/workflows/complete.yml b/.github/workflows/complete.yml new file mode 100644 index 0000000..4b78ead --- /dev/null +++ b/.github/workflows/complete.yml @@ -0,0 +1,84 @@ +name: CI - Complete +on: + workflow_dispatch: + pull_request: + branches: + - main +jobs: + full-testing: + name: Complete Quality Control (Unit, Integration & System Tests) + runs-on: ubuntu-latest + services: + mysql: + image: mysql:8 + env: + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: goeventsnow_db + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=5s --health-retries=5 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: Set up Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + + - name: Install Dependencies + run: | + cd frontend + npm install + + + - name: Compile Server & Run Backend Unit, Integration & System Test + run: | + cd backend + mvn clean verify -Dtest="es.goeventsnow.backend.unit.EventTest,es.goeventsnow.backend.api.EventApiTest,es.goeventsnow.backend.integration.EventBBDDTest" + + - name: Run Frontend Unit & Integration tests + run: | + cd frontend + npx ng test --coverage + + + # --- PASO 2: PREPARACIÓN PARA TESTS DE SISTEMA (E2E) --- + + - name: Instalar herramientas de espera + run: sudo apt-get install netcat-openbsd + + - name: Arrancar Backend en segundo plano + env: + SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/goeventsnow_db?useSSL=false&serverTimezone=UTC + SPRING_DATASOURCE_PASSWORD: password + run: | + cd backend + mvn spring-boot:run & + echo "Esperando a que el backend esté listo en el puerto 8080..." + timeout 60s sh -c 'until nc -z localhost 8080; do sleep 5; done' + + - name: Arrancar Frontend en segundo plano + run: | + cd frontend + npx ng serve --host 0.0.0.0 & + echo "Esperando a que el frontend esté listo en el puerto 4200..." + timeout 60s sh -c 'until nc -z localhost 4200; do sleep 5; done' + + # --- PASO 3: EJECUCIÓN TEST DE SISTEMA (SELENIUM) --- + + - name: Ejecutar Test de Sistema (Selenium) + # Este test de Java (backend) probará la UI del frontend (localhost:4200) + # que a su vez llama al backend (localhost:8080) + run: | + cd backend + mvn test -Dtest=es.goeventsnow.backend.e2e.SeleniumTest