From 2b1cb60ec7946096a39614e1a85ddb026a93a6f4 Mon Sep 17 00:00:00 2001 From: jesussmariscal Date: Fri, 27 Dec 2024 17:07:00 +0100 Subject: [PATCH] bug fixed --- .github/workflows/testBackend.yml | 25 +++++++++++++------ .../resources/application-test.properties | 2 +- .../classes/application-test.properties | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/testBackend.yml b/.github/workflows/testBackend.yml index 44243e6eb..bbee6a192 100644 --- a/.github/workflows/testBackend.yml +++ b/.github/workflows/testBackend.yml @@ -1,22 +1,22 @@ name: CI/CD Backend on: - push: # Se ejecuta en cada push a cualquier rama - workflow_dispatch: # Permite ejecutar el workflow manualmente + push: + workflow_dispatch: jobs: build-and-test: runs-on: ubuntu-latest + services: mysql: - image: mysql:8.0.31 + image: mysql:8.0.31 env: - MYSQL_ROOT_PASSWORD: 12345678 - MYSQL_DATABASE: tfgdb + MYSQL_ROOT_PASSWORD: 12345678 + MYSQL_DATABASE: tfgdb ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=10s --health-retries=5 steps: - name: Checkout code @@ -28,9 +28,18 @@ jobs: java-version: '17' distribution: 'temurin' + - name: Download wait-for-it + run: | + wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -O ./wait-for-it.sh + chmod +x ./wait-for-it.sh + - name: Build and Test with Maven run: | cd ./Backend + # Espera a que MySQL esté listo + echo "--- Waiting for MySQL to be ready ---" + /home/runner/work/2024-ReURJC/2024-ReURJC/Backend/wait-for-it.sh mysql:3306 -t 60 + # Ejecutar Maven mvn clean install -DskipTests mvn test -Dspring.profiles.active=test diff --git a/Backend/src/main/resources/application-test.properties b/Backend/src/main/resources/application-test.properties index de195de24..c31490b2c 100644 --- a/Backend/src/main/resources/application-test.properties +++ b/Backend/src/main/resources/application-test.properties @@ -1,5 +1,5 @@ # Database Configuration (Ajusta el nombre del servicio si usas Docker Compose) -spring.datasource.url=jdbc:mysql://reurjc_mysql_1:3306/tfgdb +spring.datasource.url=jdbc:mysql://mysql:3306/tfgdb spring.datasource.username=root spring.datasource.password=12345678 jwt.secret=change_me diff --git a/Backend/target/classes/application-test.properties b/Backend/target/classes/application-test.properties index de195de24..c31490b2c 100644 --- a/Backend/target/classes/application-test.properties +++ b/Backend/target/classes/application-test.properties @@ -1,5 +1,5 @@ # Database Configuration (Ajusta el nombre del servicio si usas Docker Compose) -spring.datasource.url=jdbc:mysql://reurjc_mysql_1:3306/tfgdb +spring.datasource.url=jdbc:mysql://mysql:3306/tfgdb spring.datasource.username=root spring.datasource.password=12345678 jwt.secret=change_me