-
Notifications
You must be signed in to change notification settings - Fork 0
212 lines (182 loc) · 6.96 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Fullstack Tasks Application Pipeline
# Trigger the workflow
on:
push:
branches:
- "**" # Matches every branch for push events
pull_request:
branches:
- "**" # Matches every branch for pull request events
jobs:
# Step: Cache and Install Frontend Dependencies
frontend:
uses: SAINIAbhishek/shared-workflows/.github/workflows/cache-install-dependencies.yml@main
with:
node-version: "20.17.0"
lock-file: "frontend/package-lock.json"
cache-path: "frontend/node_modules"
cache-key-prefix: "frontend"
working-directory: "frontend"
# Step: Cache and Install Server Dependencies
server:
uses: SAINIAbhishek/shared-workflows/.github/workflows/cache-install-dependencies.yml@main
with:
node-version: "20.17.0"
lock-file: "server/package-lock.json"
cache-path: "server/node_modules"
cache-key-prefix: "server"
working-directory: "server"
# Step: Lint the code
lint:
needs: [frontend, server] # Wait for dependencies to be installed before linting
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
# Restore Server Node.js Modules cache
- name: Restore Server Node.js Modules Cache
uses: actions/cache@v3
with:
path: server/node_modules
key: ${{ runner.os }}-server-${{ hashFiles('server/package-lock.json') }}
# Restore Frontend Node.js Modules cache
- name: Restore Frontend Node.js Modules Cache
uses: actions/cache@v3
with:
path: frontend/node_modules
key: ${{ runner.os }}-frontend-${{ hashFiles('frontend/package-lock.json') }}
# Lint the server code
- name: Lint Server Code
run: npm run eslint
working-directory: ./server
# Lint the frontend code
- name: Lint Frontend Code
run: npm run lint
working-directory: ./frontend
# # Step: Formatting job
# format:
# needs: install-dependencies # Dependencies must be installed before formatting
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v3
# - name: Setup Node.js
# uses: setup-node.yml
# # Restore Frontend Node.js Modules cache
# - name: Restore Frontend Node.js Modules Cache
# uses: actions/cache@v3
# with:
# path: frontend/node_modules
# key: ${{ runner.os }}-frontend-node-${{ hashFiles('frontend/package-lock.json') }}
# # Format the frontend code with Prettier
# - name: Check Frontend Code Formatting with Prettier
# run: npm run prettier
# working-directory: ./frontend
# # Step: Security audit for both server and frontend
# security-audit:
# needs: install-dependencies # Run only after tests have passed
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v3
# - name: Setup Node.js
# uses: ./.github/workflows/setup-node.yml
# # Restore Server Node.js Modules cache
# - name: Restore Server Node.js Modules Cache
# uses: actions/cache@v3
# with:
# path: server/node_modules
# key: ${{ runner.os }}-server-node-${{ hashFiles('server/package-lock.json') }}
# # Restore Frontend Node.js Modules cache
# - name: Restore Frontend Node.js Modules Cache
# uses: actions/cache@v3
# with:
# path: frontend/node_modules
# key: ${{ runner.os }}-frontend-node-${{ hashFiles('frontend/package-lock.json') }}
# # Run npm audit for server
# - name: Run Server npm audit
# run: npm run audit
# working-directory: ./server
# continue-on-error: true
# # Run npm audit for frontend
# - name: Run Frontend npm audit
# run: npm run audit
# working-directory: ./frontend
# continue-on-error: true
# # Step: Run unit tests
# test:
# needs: [lint, format, security-audit]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v3
# - name: Setup Node.js
# uses: ./.github/workflows/setup-node.yml
# # Restore Frontend Node.js Modules cache
# - name: Restore Frontend Node.js Modules Cache
# uses: actions/cache@v3
# with:
# path: frontend/node_modules
# key: ${{ runner.os }}-frontend-node-${{ hashFiles('frontend/package-lock.json') }}
# # Run frontend unit tests
# - name: Run Frontend Unit Tests
# run: npm run test:coverage
# working-directory: ./frontend
# env:
# CI: true # Ensures Vitest runs in Continuous Integration mode
# # Step: Build the project
# build:
# needs: test
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v3
# - name: Setup Node.js
# uses: ./.github/workflows/setup-node.yml
# # Restore Server Node.js Modules cache
# - name: Restore Server Node.js Modules Cache
# uses: actions/cache@v3
# with:
# path: server/node_modules
# key: ${{ runner.os }}-server-node-${{ hashFiles('server/package-lock.json') }}
# - name: Build Server for Production
# run: npm run build
# working-directory: ./server
# env:
# NODE_ENV: production
# PORT: ${{ vars.API_PORT }}
# MONGO_URI: ${{ vars.MONGO_URI }}
# MONGO_DB_HOST: ${{ vars.MONGO_DB_HOST }}
# TOKEN_ISSUER: ${{ vars.TOKEN_ISSUER}}
# TOKEN_AUDIENCE: ${{ vars.TOKEN_AUDIENCE}}
# CORS_URL: ${{ vars.CORS_URL}}
# FRONTEND_RESET_URL: ${{ vars.FRONTEND_RESET_URL}}
# API_VERSION: ${{ vars.API_VERSION}}
# ACCESS_TOKEN_SECRET_KEY: ${{ secrets.ACCESS_TOKEN_SECRET_KEY}}
# MAILTRAP_TESTING_PASSWORD: ${{ secrets.MAILTRAP_TESTING_PASSWORD}}
# MAILTRAP_TESTING_USERNAME: ${{ secrets.MAILTRAP_TESTING_USERNAME}}
# REFRESH_TOKEN_SECRET_KEY: ${{ secrets.REFRESH_TOKEN_SECRET_KEY}}
# # Restore Frontend Node.js Modules cache
# - name: Restore Frontend Node.js Modules Cache
# uses: actions/cache@v3
# with:
# path: frontend/node_modules
# key: ${{ runner.os }}-frontend-node-${{ hashFiles('frontend/package-lock.json') }}
# - name: Build Frontend for Production
# run: npm run build:prod
# working-directory: ./frontend
# env:
# NODE_ENV: production
# APP_API_BASE_URL: ${{ vars.APP_API_BASE_URL }}
# APP_LOGGING: ${{ vars.APP_LOGGING }}
# APP_PORT: ${{ vars.FRONTEND_APP_PORT }}
# - name: Save Server Build Artifacts
# uses: actions/upload-artifact@v4
# with:
# name: server-build
# path: server/build
# - name: Save Frontend Build Artifacts
# uses: actions/upload-artifact@v4
# with:
# name: frontend-build
# path: frontend/dist