From 8cd3ffda4ffc29b5f1097d21135ae993f09783fd Mon Sep 17 00:00:00 2001 From: AlbertoML1999 <146851709+AlbertoML1999@users.noreply.github.com> Date: Fri, 19 Dec 2025 10:14:54 +0100 Subject: [PATCH 1/4] Add SonarCloud analysis for frontend and backend --- .github/workflows/basic.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index d7827b5..caab86d 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -32,6 +32,14 @@ jobs: run: | cd backend mvn clean verify -Dtest="es.goeventsnow.backend.unit.EventTest" + - name: SonarCloud Analysis (Backend) + run: | + cd backend + mvn sonar:sonar \ + -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY_BACKEND }} \ + -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.login=${{ secrets.SONAR_TOKEN }} client-quality: name: Client - Basic CI @@ -57,3 +65,13 @@ jobs: run: | cd frontend npx ng test --include=src/app/app.component.spec.ts --coverage + - name: SonarCloud Analysis (Frontend) + uses: SonarSource/sonarcloud-github-action@v2 + with: + projectBaseDir: frontend + args: > + -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY_FRONTEND }} + -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} + -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 85fef1f2de4b5d216fa3b6002bc4ee86d6b248c0 Mon Sep 17 00:00:00 2001 From: AlbertoML1999 <146851709+AlbertoML1999@users.noreply.github.com> Date: Fri, 19 Dec 2025 10:18:37 +0100 Subject: [PATCH 2/4] Update SonarCloud project keys in workflow --- .github/workflows/basic.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index caab86d..9e20b35 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -36,7 +36,7 @@ jobs: run: | cd backend mvn sonar:sonar \ - -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY_BACKEND }} \ + -Dsonar.projectKey=Testing_TFG \ -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=${{ secrets.SONAR_TOKEN }} @@ -70,7 +70,7 @@ jobs: with: projectBaseDir: frontend args: > - -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY_FRONTEND }} + -Dsonar.projectKey=Testing_TFG -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info env: From fa2be3e4059def21dfd4a499c6d5d9806e861717 Mon Sep 17 00:00:00 2001 From: AlbertoML1999 <146851709+AlbertoML1999@users.noreply.github.com> Date: Fri, 19 Dec 2025 10:25:51 +0100 Subject: [PATCH 3/4] Remove SonarCloud analysis from CI workflow Removed SonarCloud analysis steps for both backend and frontend. --- .github/workflows/basic.yml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index 9e20b35..e108371 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -32,14 +32,6 @@ jobs: run: | cd backend mvn clean verify -Dtest="es.goeventsnow.backend.unit.EventTest" - - name: SonarCloud Analysis (Backend) - run: | - cd backend - mvn sonar:sonar \ - -Dsonar.projectKey=Testing_TFG \ - -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=${{ secrets.SONAR_TOKEN }} client-quality: name: Client - Basic CI @@ -65,13 +57,4 @@ jobs: run: | cd frontend npx ng test --include=src/app/app.component.spec.ts --coverage - - name: SonarCloud Analysis (Frontend) - uses: SonarSource/sonarcloud-github-action@v2 - with: - projectBaseDir: frontend - args: > - -Dsonar.projectKey=Testing_TFG - -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} - -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + From 05981c696ae4dc94e1fe961d0de60485afba8165 Mon Sep 17 00:00:00 2001 From: AlbertoML1999 <146851709+AlbertoML1999@users.noreply.github.com> Date: Fri, 19 Dec 2025 10:34:30 +0100 Subject: [PATCH 4/4] Refactor CI workflow and enhance comments Removed workflow_dispatch trigger and added detailed comments for each step in the CI pipeline. --- .github/workflows/complete.yml | 84 ++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 24 deletions(-) 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 }}