File tree Expand file tree Collapse file tree
src/main/resources/META-INF Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Build, Test, and Validate with PostgreSQL
2+
13on :
24 push :
35 branches :
4- - develop # Aciona a ação ao enviar mudanças para a branch "develop"
6+ - docker-postgres-cicd # Aciona a ação ao enviar mudanças para a branch "develop"
57
68jobs :
79 build :
810 runs-on : ubuntu-latest
911
10- env :
12+ services :
13+ postgres :
14+ image : postgres:15 # Versão do PostgreSQL
15+ ports :
16+ - 5432:5432 # Porta padrão do PostgreSQL
17+ env :
18+ POSTGRES_USER : engstrategy # Usuário do banco
19+ POSTGRES_PASSWORD : engstrategy1234@ # Senha do banco
20+ POSTGRES_DB : db_mundo_animal # Banco de dados usado nos testes
1121
1222 steps :
1323 - name : Checkout code
2232 - name : Setup Maven
2333 run : mvn -version # Verifica a versão do Maven
2434
35+ - name : Configure persistence.xml for tests
36+ run : |
37+ sed -i 's|<property name="jakarta.persistence.jdbc.url" value=".*"/>|<property name="jakarta.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/db_mundo_animal"/>|' src/main/resources/META-INF/persistence.xml
38+ sed -i 's|<property name="jakarta.persistence.jdbc.user" value=".*"/>|<property name="jakarta.persistence.jdbc.user" value="engstrategy"/>|' src/main/resources/META-INF/persistence.xml
39+ sed -i 's|<property name="jakarta.persistence.jdbc.password" value=".*"/>|<property name="jakarta.persistence.jdbc.password" value="engstrategy1234@"/>|' src/main/resources/META-INF/persistence.xml
40+
41+ - name : Wait for PostgreSQL
42+ run : |
43+ for i in {1..15}; do
44+ if pg_isready -h localhost -p 5432 -U engstrategy; then
45+ echo "PostgreSQL is ready!"
46+ exit 0
47+ fi
48+ echo "Waiting for PostgreSQL..."
49+ sleep 2
50+ done
51+ echo "PostgreSQL failed to start"
52+ exit 1
53+
54+ - name : Show PostgreSQL Logs
55+ run : docker logs $(docker ps -q --filter "name=postgres")
2556
2657 - name : Run Tests
2758 run : mvn test
Original file line number Diff line number Diff line change 1+ services :
2+ postgres :
3+ image : postgres:latest
4+ container_name : postgres_mundo_animal
5+ restart : always
6+ environment :
7+ POSTGRES_USER : engstrategy
8+ POSTGRES_PASSWORD : engstrategy1234@
9+ POSTGRES_DB : db_mundo_animal
10+ ports :
11+ - " 5432:5432"
12+ volumes :
13+ - postgres_data:/var/lib/postgresql/data
14+ networks :
15+ - app-network
16+
17+ pgadmin :
18+ image : dpage/pgadmin4
19+ container_name : pgadmin
20+ environment :
21+ PGADMIN_DEFAULT_EMAIL : admin@admin.com
22+ PGADMIN_DEFAULT_PASSWORD : admin
23+ ports :
24+ - " 5050:80"
25+ depends_on :
26+ - postgres
27+ networks :
28+ - app-network
29+
30+ volumes :
31+ postgres_data :
32+
33+ networks :
34+ app-network :
35+ driver : bridge
Original file line number Diff line number Diff line change 1212 <class >com.carvalhotechsolutions.mundoanimal.model.Servico</class >
1313 <properties >
1414 <!-- Altere os valores de acordo com as configurações do seu postgres -->
15- <property name =" jakarta.persistence.jdbc.url" value =" jdbc:postgresql://localhost:5432/mundoanimal" />
1615 <property name =" jakarta.persistence.jdbc.driver" value =" org.postgresql.Driver" />
17- <property name =" jakarta.persistence.jdbc.user" value =" postgres" />
18- <property name =" jakarta.persistence.jdbc.password" value =" password" />
16+ <property name =" jakarta.persistence.jdbc.url" value =" jdbc:postgresql://localhost:5432/db_mundo_animal" />
17+ <property name =" jakarta.persistence.jdbc.user" value =" engstrategy" />
18+ <property name =" jakarta.persistence.jdbc.password" value =" engstrategy1234@" />
1919
20+ <property name =" hibernate.dialect" value =" org.hibernate.dialect.PostgreSQLDialect" />
21+ <property name =" hibernate.hbm2ddl.auto" value =" create-drop" />
2022 <property name =" hibernate.show_sql" value =" true" />
2123 <property name =" hibernate.format_sql" value =" true" />
22- <property name =" hibernate.hbm2ddl.auto" value =" update" />
2324 <!-- Deixei a propriedade DDL auto como create-drop para facilitar
2425 os testes no banco de dados, fica ao critério de cada um do @Back
2526 <property name="hibernate.hbm2ddl.auto" value="update" /> -->
You can’t perform that action at this time.
0 commit comments