Skip to content

Commit 76bcf34

Browse files
authored
Merge pull request #104 from SakanaIsReal/feature/docker/cicd-round-2
Feature/docker/cicd round 2
2 parents c1e070d + 9b4b6e2 commit 76bcf34

1 file changed

Lines changed: 44 additions & 13 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,35 @@ jobs:
5757
run: mvn test "-Dapp.jwt.secret=${{ secrets.APP_JWT_SECRET }}"
5858

5959
# ------------------------------------------------------------------
60-
# JOB 2: E2E TESTS (Dockerized)
60+
# JOB 2: INTEGRATION TESTS (Backend + MySQL via Testcontainers)
61+
# ------------------------------------------------------------------
62+
integration-test:
63+
name: Integration Tests
64+
runs-on: self-hosted
65+
steps:
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
69+
- name: Setup Java
70+
uses: actions/setup-java@v4
71+
with:
72+
distribution: 'temurin'
73+
java-version: ${{ env.JAVA_VERSION }}
74+
cache: 'maven'
75+
76+
- name: Run Integration Tests
77+
working-directory: ./backend
78+
env:
79+
APP_JWT_SECRET: ${{ secrets.APP_JWT_SECRET }}
80+
run: mvn verify -DskipSurefireTests "-Dapp.jwt.secret=${{ secrets.APP_JWT_SECRET }}"
81+
82+
# ------------------------------------------------------------------
83+
# JOB 3: E2E TESTS (Dockerized)
6184
# ------------------------------------------------------------------
6285
e2e-test:
6386
name: E2E Tests
6487
runs-on: self-hosted
65-
# needs: unit-test
88+
needs: unit-test
6689

6790
steps:
6891
- name: Checkout code
@@ -137,12 +160,13 @@ jobs:
137160
run: docker compose down -v
138161

139162
# ------------------------------------------------------------------
140-
# JOB 3: BUILD & DEPLOY
163+
# JOB 4: BUILD & DEPLOY
141164
# ------------------------------------------------------------------
142165
build-and-deploy:
143166
name: Build & Deploy
144-
needs: [unit-test, e2e-test]
167+
needs: [unit-test, integration-test, e2e-test]
145168
if: github.ref == 'refs/heads/main'
169+
# github.ref == 'refs/heads/main'
146170
runs-on: self-hosted
147171

148172
steps:
@@ -171,17 +195,24 @@ jobs:
171195
172196
- name: Deploy to Kubernetes
173197
run: |
174-
$timestamp = Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ"
175198
$sha = "${{ github.sha }}"
176-
177-
# Update Images
199+
200+
# Pre-pull images into Minikube (avoids timeout during rollout)
201+
Write-Host "Pre-pulling images into Minikube..."
202+
minikube ssh "docker pull ${{ env.BACKEND_IMAGE }}:$sha"
203+
minikube ssh "docker pull ${{ env.FRONTEND_IMAGE }}:$sha"
204+
205+
# Update deployment images
206+
Write-Host "Updating deployment images..."
178207
kubectl set image deployment/backend backend="${{ env.BACKEND_IMAGE }}:$sha" -n smartsplit
179208
kubectl set image deployment/frontend frontend="${{ env.FRONTEND_IMAGE }}:$sha" -n smartsplit
180-
181-
# Force rollout via annotation
182-
kubectl patch deployment backend -n smartsplit -p "{`"spec`":{`"template`":{`"metadata`":{`"annotations`":{`"deployment.kubernetes.io/revision-time`":`"$timestamp`"}}}}}"
183-
kubectl patch deployment frontend -n smartsplit -p "{`"spec`":{`"template`":{`"metadata`":{`"annotations`":{`"deployment.kubernetes.io/revision-time`":`"$timestamp`"}}}}}"
184-
185-
# Wait for status
209+
210+
# Force rollout restart (cleaner than JSON patch)
211+
Write-Host "Restarting deployments..."
212+
kubectl rollout restart deployment/backend -n smartsplit
213+
kubectl rollout restart deployment/frontend -n smartsplit
214+
215+
# Wait for rollout completion
216+
Write-Host "Waiting for rollout to complete..."
186217
kubectl rollout status deployment/backend -n smartsplit --timeout=300s
187218
kubectl rollout status deployment/frontend -n smartsplit --timeout=300s

0 commit comments

Comments
 (0)