diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index d7827b5..e108371 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -57,3 +57,4 @@ jobs: run: | cd frontend npx ng test --include=src/app/app.component.spec.ts --coverage + diff --git a/.github/workflows/complete.yml b/.github/workflows/complete.yml index 4b78ead..0c97aa5 100644 --- a/.github/workflows/complete.yml +++ b/.github/workflows/complete.yml @@ -1,9 +1,10 @@ name: CI - Complete + on: - workflow_dispatch: pull_request: branches: - main + jobs: full-testing: name: Complete Quality Control (Unit, Integration & System Tests) @@ -17,68 +18,103 @@ jobs: ports: - 3306:3306 options: --health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=5s --health-retries=5 - + steps: + # 1️⃣ Checkout repository completo para PR analysis - name: Checkout repository uses: actions/checkout@v4 - + with: + fetch-depth: 0 + + # 2️⃣ Configurar JDK 21 para backend - name: Set up JDK 21 uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' - + + # 3️⃣ Configurar Node.js 20 para frontend - 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: | + + # 4️⃣ Instalar dependencias frontend + - name: Install Frontend Dependencies + run: | cd frontend npm install - - - name: Compile Server & Run Backend Unit, Integration & System Test + # 5️⃣ Compilar backend y ejecutar Unit, Integration & API tests + - name: Run Backend Unit & Integration Tests 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 + # 6️⃣ Ejecutar Frontend Unit & Integration Tests + - name: Run Frontend Unit & Integration Tests run: | cd frontend - npx ng test --coverage - + npx ng test --watch=false --browsers=ChromeHeadless --code-coverage - # --- PASO 2: PREPARACIÓN PARA TESTS DE SISTEMA (E2E) --- + # 7️⃣ SonarCloud Analysis (Frontend Angular) + - name: SonarCloud Analysis (Frontend) + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }} + run: | + cd frontend + npx sonar-scanner \ + -Dsonar.projectKey=Testing_TFG_Frontend \ + -Dsonar.organization=${SONAR_ORGANIZATION} \ + -Dsonar.sources=src \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.login=${SONAR_TOKEN} \ + -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \ + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \ + -Dsonar.pullrequest.branch=${{ github.head_ref }} \ + -Dsonar.pullrequest.base=${{ github.base_ref }} - - name: Instalar herramientas de espera - run: sudo apt-get install netcat-openbsd + # 8️⃣ Preparación para E2E + - name: Install netcat for wait commands + run: sudo apt-get install -y netcat-openbsd - - name: Arrancar Backend en segundo plano + - name: Start Backend in Background 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..." + echo "Waiting for backend on port 8080..." timeout 60s sh -c 'until nc -z localhost 8080; do sleep 5; done' - - name: Arrancar Frontend en segundo plano + - name: Start Frontend in Background run: | cd frontend npx ng serve --host 0.0.0.0 & - echo "Esperando a que el frontend esté listo en el puerto 4200..." + echo "Waiting for frontend on port 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) + # 9️⃣ Ejecutar Test de Sistema (Selenium E2E) + - name: Run System Tests (Selenium) run: | cd backend mvn test -Dtest=es.goeventsnow.backend.e2e.SeleniumTest + + # 🔟 SonarCloud Analysis (Backend) + - name: SonarCloud Analysis (Backend) + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }} + run: | + cd backend + mvn verify sonar:sonar \ + -Dsonar.projectKey=Testing_TFG_Backend \ + -Dsonar.organization=${SONAR_ORGANIZATION} \ + -Dsonar.login=${SONAR_TOKEN} \ + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \ + -Dsonar.pullrequest.branch=${{ github.head_ref }} \ + -Dsonar.pullrequest.base=${{ github.base_ref }}