7474 ARTEFACT_VERSION : ${{ needs.Artefact-Version.outputs.artefact_version }}
7575 run : |
7676 echo "Building with ARTEFACT_VERSION=$ARTEFACT_VERSION"
77- gradle build -DARTEFACT_VERSION=$ARTEFACT_VERSION
77+ ./gradlew build -DARTEFACT_VERSION=$ARTEFACT_VERSION
7878
7979 - name : Extract repo name
8080 id : repo_vars
8989 name : app-jar
9090 path : build/libs/${{ steps.repo_vars.outputs.artefact_name }}.jar
9191
92- api-test :
92+ API-Test-PR :
9393 if : ${{ inputs.run_api_test }}
9494 needs : [Build]
9595 runs-on : ubuntu-latest
@@ -114,13 +114,13 @@ jobs:
114114 - name : Run API Tests
115115 run : |
116116 cd apiTest
117- gradle test
117+ ../gradlew test
118118
119119 - name : Upload test reports
120120 if : always()
121121 uses : actions/upload-artifact@v6
122122 with :
123- name : api-test-reports
123+ name : api-test-pr- reports
124124 path : |
125125 apiTest/build/reports/tests/test/
126126 apiTest/build/test-results/test/
@@ -162,7 +162,7 @@ jobs:
162162
163163 echo "Publishing artefact for version: $ARTEFACT_VERSION"
164164
165- gradle publish \
165+ ./gradlew publish \
166166 -DARTEFACT_VERSION=$ARTEFACT_VERSION \
167167 -DGITHUB_REPOSITORY=${{ github.repository }} \
168168 -DGITHUB_ACTOR=${{ github.actor }} \
@@ -206,6 +206,74 @@ jobs:
206206 BASE_IMAGE=openjdk:21-jdk-slim
207207 JAR_FILENAME=${{ needs.Build.outputs.artefact_name }}.jar
208208
209+ API-Test-Main :
210+ if : ${{ inputs.trigger_docker }}
211+ needs : [Build-Docker, Artefact-Version]
212+ runs-on : ubuntu-latest
213+ steps :
214+ - name : Checkout repository
215+ uses : actions/checkout@v6
216+
217+ - name : Set up JDK
218+ uses : actions/setup-java@v5
219+ with :
220+ distribution : ' temurin'
221+ java-version : ' 21'
222+
223+ - name : Set up Gradle
224+ uses : gradle/actions/setup-gradle@v5
225+ with :
226+ gradle-version : current
227+
228+ - name : Set up Docker Buildx
229+ uses : docker/setup-buildx-action@v3
230+
231+ - name : Log in to GitHub Packages
232+ uses : docker/login-action@v3
233+ with :
234+ registry : ghcr.io
235+ username : ${{ github.actor }}
236+ password : ${{ secrets.GITHUB_TOKEN }}
237+
238+ - name : Run API Tests against published Docker image
239+ env :
240+ DOCKER_IMAGE : ghcr.io/${{ github.repository }}:${{ needs.Artefact-Version.outputs.artefact_version }}
241+ run : |
242+ cd apiTest
243+ # DOCKER_IMAGE is set via env, so docker-compose will use the image instead of building
244+ # Pull the image first to ensure it's available
245+ docker pull $DOCKER_IMAGE
246+
247+ # Start containers using the published image
248+ docker compose up -d
249+
250+ echo "Waiting for health endpoint..."
251+ for i in {1..30}; do
252+ if curl -s http://localhost:8082/actuator/health > /dev/null; then
253+ echo "App is healthy"
254+ break
255+ fi
256+ echo "Waiting for app to be healthy ($i)..."
257+ sleep 2
258+ done
259+
260+ # Run tests (containers already running via docker compose)
261+ # Skip composeUp and composeDown since we manage containers manually
262+ ../gradlew testClasses
263+ ../gradlew --no-daemon test -x composeUp -x composeDown
264+
265+ # Clean up containers manually
266+ docker compose down
267+
268+ - name : Upload test reports
269+ if : always()
270+ uses : actions/upload-artifact@v6
271+ with :
272+ name : api-test-main-reports
273+ path : |
274+ apiTest/build/reports/tests/test/
275+ apiTest/build/test-results/test/
276+
209277 Deploy :
210278 needs : [ Provider-Deploy, Build, Artefact-Version ]
211279 if : ${{ inputs.trigger_deploy }}
0 commit comments