Skip to content

Commit f971b9d

Browse files
Merge pull request #27 from igorcampos-dev/patch/worfklow-spring-kafka-example
Update spring-kafka-example.yml
2 parents 9956e42 + 4440314 commit f971b9d

File tree

1 file changed

+45
-7
lines changed

1 file changed

+45
-7
lines changed
Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
name: spring-kafka-example CI Build
22

33
on:
4-
push:
5-
paths:
6-
- "spring-kafka-example/**"
7-
branches: [master]
84
pull_request:
5+
branches: [master]
96
paths:
107
- "spring-kafka-example/**"
118
types:
@@ -14,7 +11,8 @@ on:
1411
- reopened
1512

1613
jobs:
17-
build:
14+
15+
integration-tests:
1816
name: Run Unit & Integration Tests
1917
runs-on: ubuntu-latest
2018
defaults:
@@ -27,7 +25,7 @@ jobs:
2725
steps:
2826
- uses: actions/checkout@v4
2927
with:
30-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
28+
fetch-depth: 0
3129

3230
- name: Set up JDK ${{ matrix.java }}
3331
uses: actions/[email protected]
@@ -36,4 +34,44 @@ jobs:
3634
distribution: ${{ matrix.distribution }}
3735
cache: 'maven'
3836
- name: Build and analyze
39-
run: ./mvnw clean verify
37+
run: ./mvnw clean verify
38+
39+
health-check:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout repository and submodules
43+
uses: actions/checkout@v3
44+
with:
45+
submodules: true
46+
47+
- name: Start containers with Compose Action
48+
uses: hoverkraft-tech/[email protected]
49+
with:
50+
compose-file: './spring-kafka-example/compose.yaml'
51+
services: |
52+
app
53+
kafka
54+
up-flags: '--build'
55+
down-flags: '--volumes'
56+
57+
- name: Wait for containers to initialize
58+
run: sleep 10
59+
60+
- name: Check container health
61+
run: |
62+
echo "Verificando saúde dos containers..."
63+
64+
APP_STATUS=$(docker inspect -f '{{.State.Running}}' app || echo "false")
65+
KAFKA_STATUS=$(docker inspect -f '{{.State.Running}}' kafka || echo "false")
66+
67+
echo "Status do app: $APP_STATUS"
68+
echo "Status do kafka: $KAFKA_STATUS"
69+
70+
if [ "$APP_STATUS" != "true" ] || [ "$KAFKA_STATUS" != "true" ]; then
71+
echo "::error ::Um ou ambos os containers estão inativos. PR não deve ser autorizado!"
72+
exit 1
73+
fi
74+
75+
# Se chegou aqui, ambos estão ativos
76+
- name: Success message
77+
run: echo "✅ Todos os containers estão rodando com sucesso!"

0 commit comments

Comments
 (0)