Skip to content

Commit 6a3364d

Browse files
Merge pull request #99 from igorcampos-dev/feature/spring-databases-example
Feature/spring databases example
2 parents d5ee3a9 + ccd19d8 commit 6a3364d

File tree

57 files changed

+2156
-535
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2156
-535
lines changed

.github/workflows/label.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# This workflow will triage pull requests and apply a label based on the
2-
# paths that are modified in the pull request.
3-
#
4-
# To use this workflow, you will need to set up a .github/labeler.yml
5-
# file with configuration. For more information, see:
6-
# https://github.com/actions/labeler
7-
81
name: Labeler
92
on: [pull_request_target]
103

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: spring-mysql-example CI Build
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
paths:
7+
- "spring-mysql-example/**"
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
13+
jobs:
14+
15+
integration-tests:
16+
name: Run Unit & Integration Tests
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: spring-mysql-example
21+
strategy:
22+
matrix:
23+
distribution: [ 'temurin' ]
24+
java: [ '21' ]
25+
steps:
26+
- uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set up JDK ${{ matrix.java }}
31+
uses: actions/[email protected]
32+
with:
33+
java-version: ${{ matrix.java }}
34+
distribution: ${{ matrix.distribution }}
35+
cache: 'maven'
36+
- name: Build and analyze
37+
run: ./mvnw clean verify
38+
39+
health-check:
40+
name: Health Check on Services
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout repository and submodules
44+
uses: actions/checkout@v5
45+
with:
46+
submodules: true
47+
48+
- name: Extract service names from docker compose
49+
id: services
50+
run: |
51+
echo "services<<EOF" >> $GITHUB_OUTPUT
52+
docker compose -f ./spring-mysql-example/compose.yaml config --services >> $GITHUB_OUTPUT
53+
echo "EOF" >> $GITHUB_OUTPUT
54+
55+
- name: Start containers with Compose Action
56+
uses: hoverkraft-tech/[email protected]
57+
with:
58+
compose-file: './spring-mysql-example/compose.yaml'
59+
services: ${{ steps.services.outputs.services }}
60+
up-flags: '--build'
61+
down-flags: '--volumes'
62+
63+
- name: Wait for containers to initialize
64+
run: sleep 30
65+
66+
- name: Check container health
67+
run: |
68+
./.github/scripts/check-container-health.sh "${{ steps.services.outputs.services }}"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: spring-postgres-example CI Build
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
paths:
7+
- "spring-postgres-example/**"
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
13+
jobs:
14+
15+
integration-tests:
16+
name: Run Unit & Integration Tests
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: spring-postgres-example
21+
strategy:
22+
matrix:
23+
distribution: [ 'temurin' ]
24+
java: [ '21' ]
25+
steps:
26+
- uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set up JDK ${{ matrix.java }}
31+
uses: actions/[email protected]
32+
with:
33+
java-version: ${{ matrix.java }}
34+
distribution: ${{ matrix.distribution }}
35+
cache: 'maven'
36+
- name: Build and analyze
37+
run: ./mvnw clean verify
38+
39+
health-check:
40+
name: Health Check on Services
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout repository and submodules
44+
uses: actions/checkout@v5
45+
with:
46+
submodules: true
47+
48+
- name: Extract service names from docker compose
49+
id: services
50+
run: |
51+
echo "services<<EOF" >> $GITHUB_OUTPUT
52+
docker compose -f ./spring-postgres-example/compose.yaml config --services >> $GITHUB_OUTPUT
53+
echo "EOF" >> $GITHUB_OUTPUT
54+
55+
- name: Start containers with Compose Action
56+
uses: hoverkraft-tech/[email protected]
57+
with:
58+
compose-file: './spring-postgres-example/compose.yaml'
59+
services: ${{ steps.services.outputs.services }}
60+
up-flags: '--build'
61+
down-flags: '--volumes'
62+
63+
- name: Wait for containers to initialize
64+
run: sleep 30
65+
66+
- name: Check container health
67+
run: |
68+
./.github/scripts/check-container-health.sh "${{ steps.services.outputs.services }}"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Below you will find a summary table of each subproject. For more details, please
2121
| [Spring Boot + Kafka](./spring-kafka-example) | Demonstrates a basic integration between Spring Boot and Apache Kafka. |
2222
| [Spring Boot + Keycloak](./spring-keycloak-example) | Demonstrates a basic integration between Spring Boot and Keycloak. |
2323
| [Spring Boot + Oracle](./spring-oracle-example) | Demonstrates a basic integration between Spring Boot and Oracle. |
24+
| [Spring Boot + Postgres](./spring-postgres-example) | Demonstrates a basic integration between Spring Boot and Postgres. |
25+
| [Spring Boot + Mysql](./spring-mysql-example) | Demonstrates a basic integration between Spring Boot and Mysql. |
2426
| [Spring Boot + Grafana + Prometheus](./spring-prometheus-grafana-example) | Demonstrates a basic integration between Spring Boot With Grafana and Prometheus. |
2527

2628
---

pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
<module>spring-prometheus-grafana-example</module>
1717
<module>spring-keycloak-example</module>
1818
<module>spring-jasper-example</module>
19-
<module>spring-oracle-example</module>
2019
<module>spring-multimodule-example</module>
20+
<module>spring-mysql-example</module>
21+
<module>spring-postgres-example</module>
22+
<module>spring-oracle-example</module>
2123
</modules>
2224

2325
</project>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
!**/src/main/**/target/
2+
!**/src/test/**/target/
3+
!**/.idea
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
.sts4-cache
13+
14+
### IntelliJ IDEA ###
15+
.idea
16+
*.iws
17+
*.iml
18+
*.ipr
19+
20+
### NetBeans ###
21+
/nbproject/private/
22+
/nbbuild/
23+
/dist/
24+
/nbdist/
25+
/.nb-gradle/
26+
build/
27+
!**/src/main/**/build/
28+
!**/src/test/**/build/
29+
30+
### VS Code ###
31+
.vscode/

spring-mysql-example/.dockerignore

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.DS_Store
8+
**/.classpath
9+
**/.dockerignore
10+
**/.env
11+
**/.factorypath
12+
**/.git
13+
**/.gitignore
14+
**/.idea
15+
**/.project
16+
**/.sts4-cache
17+
**/.settings
18+
**/.toolstarget
19+
**/.vs
20+
**/.vscode
21+
**/.next
22+
**/.cache
23+
**/*.dbmdl
24+
**/*.jfm
25+
**/charts
26+
**/docker-compose*
27+
**/compose.y*ml
28+
**/Dockerfile*
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
**/vendor
32+
LICENSE
33+
README.md
34+
**/*.class
35+
**/*.iml
36+
**/*.ipr
37+
**/*.iws
38+
**/*.log
39+
**/.apt_generated
40+
**/.gradle
41+
**/.gradletasknamecache
42+
**/.nb-gradle
43+
**/.springBeans
44+
**/build
45+
**/dist
46+
**/gradle-app.setting
47+
**/nbbuild
48+
**/nbdist
49+
**/nbproject/private
50+
**/target
51+
*.ctxt
52+
.mtj.tmp
53+
.mvn/timing.properties
54+
buildNumber.properties
55+
dependency-reduced-pom.xml
56+
hs_err_pid*
57+
pom.xml.next
58+
pom.xml.releaseBackup
59+
pom.xml.tag
60+
pom.xml.versionsBackup
61+
release.properties
62+
replay_pid*
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI Build
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
distribution: [ 'temurin' ]
15+
java: [ '21' ]
16+
steps:
17+
- uses: actions/checkout@v5
18+
19+
- name: Setup Java 21
20+
uses: actions/setup-java@v5
21+
with:
22+
java-version: ${{ matrix.java }}
23+
distribution: ${{ matrix.distribution }}
24+
cache: 'maven'
25+
26+
- name: Grant execute permission for mvnw
27+
run: chmod +x mvnw
28+
29+
- name: Build with Maven
30+
run: ./mvnw clean verify

spring-mysql-example/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
target/
2+
.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### STS ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
15+
### IntelliJ IDEA ###
16+
.idea
17+
*.iws
18+
*.iml
19+
*.ipr
20+
21+
### NetBeans ###
22+
/nbproject/private/
23+
/nbbuild/
24+
/dist/
25+
/nbdist/
26+
/.nb-gradle/
27+
build/
28+
!**/src/main/**/build/
29+
!**/src/test/**/build/
30+
31+
### VS Code ###
32+
.vscode/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
wrapperVersion=3.3.4
2+
distributionType=only-script
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

0 commit comments

Comments
 (0)