Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 45 additions & 7 deletions .github/workflows/spring-kafka-example.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: spring-kafka-example CI Build

on:
push:
paths:
- "spring-kafka-example/**"
branches: [master]
pull_request:
branches: [master]
paths:
- "spring-kafka-example/**"
types:
Expand All @@ -14,7 +11,8 @@ on:
- reopened

jobs:
build:

integration-tests:
name: Run Unit & Integration Tests
runs-on: ubuntu-latest
defaults:
Expand All @@ -27,7 +25,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0

- name: Set up JDK ${{ matrix.java }}
uses: actions/[email protected]
Expand All @@ -36,4 +34,44 @@ jobs:
distribution: ${{ matrix.distribution }}
cache: 'maven'
- name: Build and analyze
run: ./mvnw clean verify
run: ./mvnw clean verify

health-check:
runs-on: ubuntu-latest
steps:
Comment on lines +39 to +41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Run health-check only after tests finish

Unless there is a strong reason to run both jobs in parallel, chaining them makes the pipeline shorter (containers are started only if the Maven build succeeded) and surfaces failures earlier.

   health-check:
-    runs-on: ubuntu-latest
+    needs: integration-tests
+    runs-on: ubuntu-latest
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
health-check:
runs-on: ubuntu-latest
steps:
health-check:
needs: integration-tests
runs-on: ubuntu-latest
steps:
# … existing steps …
🤖 Prompt for AI Agents
In .github/workflows/spring-kafka-example.yml around lines 39 to 41, the
health-check job currently runs in parallel with other jobs. Modify the workflow
to make the health-check job depend on the successful completion of the test job
by adding a 'needs' attribute referencing the test job. This ensures the
health-check runs only after tests finish, optimizing pipeline execution and
failure visibility.

- name: Checkout repository and submodules
uses: actions/checkout@v3
with:
submodules: true
Comment on lines +42 to +45
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Bump actions/checkout to v4 to avoid deprecation/runtime errors

actionlint already warns that v3 runners are considered legacy and may eventually break.
You are already using v4 in the integration-tests job, so keeping versions consistent is a quick win.

-      - name: Checkout repository and submodules
-        uses: actions/checkout@v3
+      - name: Checkout repository and submodules
+        uses: actions/checkout@v4
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Checkout repository and submodules
uses: actions/checkout@v3
with:
submodules: true
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: true
🧰 Tools
🪛 actionlint (1.7.7)

43-43: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
In .github/workflows/spring-kafka-example.yml at lines 42 to 45, the
actions/checkout version is set to v3, which is deprecated and may cause runtime
errors. Update the version from v3 to v4 in the uses field to align with the
integration-tests job and avoid potential issues.


- name: Start containers with Compose Action
uses: hoverkraft-tech/[email protected]
with:
compose-file: './spring-kafka-example/compose.yaml'
services: |
app
kafka
up-flags: '--build'
down-flags: '--volumes'

- name: Wait for containers to initialize
run: sleep 10

- name: Check container health
run: |
echo "Verificando saúde dos containers..."

APP_STATUS=$(docker inspect -f '{{.State.Running}}' app || echo "false")
KAFKA_STATUS=$(docker inspect -f '{{.State.Running}}' kafka || echo "false")

echo "Status do app: $APP_STATUS"
echo "Status do kafka: $KAFKA_STATUS"

if [ "$APP_STATUS" != "true" ] || [ "$KAFKA_STATUS" != "true" ]; then
echo "::error ::Um ou ambos os containers estão inativos. PR não deve ser autorizado!"
exit 1
fi

# Se chegou aqui, ambos estão ativos
- name: Success message
run: echo "✅ Todos os containers estão rodando com sucesso!"