@@ -2,16 +2,86 @@ name: Build and Push Docker Images
22
33on :
44 push :
5- branches : [ main, master ] # Adjust branch names as needed
5+ branches : [ main, master ]
66 pull_request :
77 branches : [ main, master ]
88
99env :
1010 DOCKER_HUB_USERNAME : ${{ secrets.DOCKER_HUB_USERNAME }}
1111
1212jobs :
13+ test-backend :
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Checkout code
18+ uses : actions/checkout@v4
19+
20+ - name : Set up Node.js
21+ uses : actions/setup-node@v4
22+ with :
23+ node-version : ' 18'
24+ cache : ' npm'
25+ cache-dependency-path : backend/package-lock.json
26+
27+ - name : Install backend dependencies
28+ run : |
29+ cd backend
30+ npm ci
31+
32+ - name : Run backend tests
33+ run : |
34+ cd backend
35+ npm test
36+ env :
37+ NODE_ENV : test
38+ JWT_SECRET : test_jwt_secret
39+ MONGODB_URI : mongodb://localhost:27017/glow_test
40+
41+ - name : Upload backend test results
42+ uses : actions/upload-artifact@v4 # Changed from v3 to v4
43+ if : always()
44+ with :
45+ name : backend-test-results
46+ path : backend/coverage/
47+
48+ test-frontend :
49+ runs-on : ubuntu-latest
50+
51+ steps :
52+ - name : Checkout code
53+ uses : actions/checkout@v4
54+
55+ - name : Set up Node.js
56+ uses : actions/setup-node@v4
57+ with :
58+ node-version : ' 18'
59+ cache : ' npm'
60+ cache-dependency-path : frontend/package-lock.json
61+
62+ - name : Install frontend dependencies
63+ run : |
64+ cd frontend
65+ npm ci
66+
67+ - name : Run frontend tests
68+ run : |
69+ cd frontend
70+ npm test -- --coverage --watchAll=false
71+ env :
72+ NEXT_PUBLIC_API_URL : http://localhost:5000/api
73+ CI : true
74+
75+ - name : Upload frontend test results
76+ uses : actions/upload-artifact@v4 # Changed from v3 to v4
77+ if : always()
78+ with :
79+ name : frontend-test-results
80+ path : frontend/coverage/
81+
1382 build-backend :
1483 runs-on : ubuntu-latest
84+ needs : [test-backend] # Only build if tests pass
1585
1686 steps :
1787 - name : Checkout code
57127
58128 build-frontend :
59129 runs-on : ubuntu-latest
130+ needs : [test-frontend] # Only build if tests pass
60131
61132 steps :
62133 - name : Checkout code
88159 context : ./frontend
89160 file : ./frontend/Dockerfile
90161 push : true
162+ build-args : |
163+ NEXT_PUBLIC_API_URL=https://glow-backend-v4-0-0.onrender.com/api
91164 tags : ${{ steps.meta-frontend.outputs.tags }}
92165 labels : ${{ steps.meta-frontend.outputs.labels }}
93166 cache-from : type=gha
0 commit comments