Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroGlezC committed Apr 26, 2024
2 parents a182530 + be1e4a1 commit 571eca2
Show file tree
Hide file tree
Showing 132 changed files with 4,178 additions and 249 deletions.
54 changes: 37 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,48 @@ on:
push:
branches:
- master
- develop
pull_request:
types: [opened, synchronize, reopened]
jobs:
unit-tests:
backend-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: syg-backend
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build with Maven
run: mvn clean verify

# Mover el reporte de cobertura a la raíz del proyecto
# - name: Move coverage report to project root
# run: |
# mkdir -p coverage
# cp -r SYG-bootstrap/target/site/jacoco-aggregate/jacoco.csv coverage/
# cp -r SYG-bootstrap/target/site/jacoco-aggregate/index.html coverage/

# - name: Configurar Git para el commit
# run: |
# git config --global user.name "AlvaroGlezC"
# git config --global user.email "[email protected]"

# - name: Hacer commit y push de la cobertura
# run: |
# git add -f coverage
# git commit -m "Agregar reporte de cobertura"
# git push

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
files: SYG-bootstrap/target/site/jacoco-aggregate/jacoco.xml

128 changes: 0 additions & 128 deletions .github/workflows/release.yml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Deploy on release](https://github.com/Arquisoft/wiq_es1d/actions/workflows/release.yml/badge.svg)](https://github.com/Arquisoft/wiq_es1d/actions/workflows/release.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es1d&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es1d)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es1d&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es1d)
[![Codecov](https://codecov.io/gh/tu-usuario/tu-repositorio/branch/main/graph/badge.svg)](https://codecov.io/gh/tu-usuario/tu-repositorio)

This is a base repo for the [Software Architecture course](http://arquisoft.github.io/) in [2023/2024 edition](https://arquisoft.github.io/course2324.html).

Expand Down
54 changes: 45 additions & 9 deletions syg-backend/SYG-bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand All @@ -31,19 +30,43 @@
<optional>true</optional>
</dependency>

<!-- POSTGRESQL -->
<!-- <dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>-->

<!-- MYSQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>

<!-- TEST DEPENDENCIES -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>

<!-- SYG MODULES -->
<dependency>
Expand All @@ -62,7 +85,7 @@
<version>0.0.1-SNAPSHOT</version>
</dependency>

<!-- SEGURIDAD KYECLOAK -->
<!-- SEGURIDAD KEYCLOAK -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
Expand Down Expand Up @@ -98,6 +121,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@SpringBootApplication
@ComponentScan(basePackages = "syg.**")
@EnableJpaRepositories("syg.mysql.repositories")
@EntityScan(basePackages = "syg.mysql.entities")
@PropertySource(value = "classpath:mysql.properties")
public class BootstrapApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ app.security.auth.certificates.url=http://localhost:8090/realms/syg/protocol/ope

app.security.cors.allowed-origins = *
app.security.cors.allowed-methods = GET,POST,PUT,DELETE
app.security.cors.mapping = /**
app.security.cors.mapping = /**

spring.datasource.url=jdbc:mysql://localhost:3306/syg-db
spring.datasource.username=sygAdmin
spring.datasource.password=sygAdmin
9 changes: 8 additions & 1 deletion syg-backend/SYG-bootstrap/src/sql/scheme.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ CREATE TABLE answers(
CREATE TABLE users(
id varchar(36) PRIMARY KEY,
name varchar(255) NOT NULL,
password varchar(255) NOT NULL,
total_games NUMERIC NOT NULL default 0,
correct_answers NUMERIC NOT NULL default 0,
incorrect_answers NUMERIC NOT NULL default 0,
Expand All @@ -31,5 +30,13 @@ CREATE TABLE users(
UNIQUE KEY unique_name_password (name)
);

INSERT INTO users (ID, NAME, total_games, correct_answers, incorrect_answers, total_questions_answered, last_category_played) VALUES ('4366fdc8-b32d-46bc-9df8-2e8ce68f0743', 'alvaro', 10, 24, 10, 100, 'deportes');

INSERT INTO categories (ID, NAME) VALUES (1, 'Deportes');
INSERT INTO categories (ID, NAME) VALUES (2, 'Paises');
INSERT INTO categories (ID, NAME) VALUES (3, 'Ciencia');
INSERT INTO categories (ID, NAME) VALUES (4, 'Cine');
INSERT INTO categories (ID, NAME) VALUES (5, 'Videojuegos');

CREATE USER 'sygAdmin'@'%' IDENTIFIED BY 'sygAdmin';
GRANT ALL PRIVILEGES ON `syg-db`.* TO 'sygAdmin'@'%';
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package syg.bootstrap;

import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.MySQLContainer;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;

/**
* Test que arranca un contenedor con una base de datos mySQL.
*
* Dado que los tests se ejecutan en un contexto transaccional no se afectan
* unos a otros.
*
*
* Los datos iniciales se cargan de una imagen.
*
*/
@Testcontainers
public abstract class SYGdbContainer {

static final MySQLContainer<?> sygdbContainer;

static {
sygdbContainer = new MySQLContainer<>(
DockerImageName.parse("mysql:8.0.36").asCompatibleSubstituteFor("mysql"))
.withDatabaseName("syg-db")
.withUsername("sygAdmin")
.withPassword("sygAdmin")
.withInitScript("db/initial-data-bootstrap.sql");
sygdbContainer.start();
}

/**
* Asignamos las propiedades del DataSource de Spring utilizando las del
* contenedor
*/
@DynamicPropertySource
static void mysqlProperties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", sygdbContainer::getJdbcUrl);
registry.add("spring.datasource.password", sygdbContainer::getPassword);
registry.add("spring.datasource.username", sygdbContainer::getUsername);
registry.add("spring.datasource.driver-class-name", sygdbContainer::getDriverClassName);
}

}
Loading

0 comments on commit 571eca2

Please sign in to comment.