-
Notifications
You must be signed in to change notification settings - Fork 9
203 lines (172 loc) · 5.39 KB
/
Copy pathci.yml
File metadata and controls
203 lines (172 loc) · 5.39 KB
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
name: CI Pipeline
on:
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
jobs:
build:
name: Build and Prepare Environment
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: "npm"
- name: Cache node_modules
id: cache
uses: actions/cache@v4
with:
path: node_modules/
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Create .env
run: |
printf "JWT_SECRET=${{ secrets.JWT_SECRET }}\n\
NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }}\n\
CLOUDINARY_CLOUD_NAME=${{ secrets.CLOUDINARY_CLOUD_NAME }}\n\
CLOUDINARY_API_KEY=${{ secrets.CLOUDINARY_API_KEY }}\n\
CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }}\n\
RESEND_API_KEY=${{ secrets.RESEND_API_KEY }}\n\
INVITE_REQUEST_SENDER_EMAIL=${{ secrets.INVITE_REQUEST_SENDER_EMAIL }}\n\
RESET_PASSWORD_EMAIL=${{ secrets.RESET_PASSWORD_EMAIL }}\n\
CONTACT_SENDER_EMAIL=${{ secrets.CONTACT_SENDER_EMAIL }}\n\
INVITE_REQUEST_RECEIVER_EMAIL=${{ secrets.INVITE_REQUEST_RECEIVER_EMAIL }}\n" > .env
- name: Build project
run: npm run build
- name: Upload node_modules
uses: actions/upload-artifact@v7
with:
name: node-modules
path: node_modules/
retention-days: 1
lint:
name: Lint Codebase
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Restore node_modules
id: cache
uses: actions/cache@v4
with:
path: node_modules/
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Run Lint
run: npm run lint
test:
name: Run Tests (Jest)
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Restore node_modules
id: cache
uses: actions/cache@v4
with:
path: node_modules/
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Run Tests
run: npm run test
coverage:
name: Run Tests with Coverage
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Restore node_modules
id: cache
uses: actions/cache@v4
with:
path: node_modules/
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Run Tests with Coverage
run: |
npx jest --coverage \
--coverageThreshold='{"global":{"branches":60,"functions":60,"lines":60,"statements":60}}'
- name: Upload coverage report
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: coverage/
# SonarCloud runs in a separate "SonarCloud" workflow (workflow_run) so it
# has access to SONAR_TOKEN even for pull requests from forks. Persist the
# PR context here so that workflow can decorate the correct pull request.
- name: Save PR metadata
if: ${{ github.event_name == 'pull_request' }}
run: |
mkdir -p pr-meta
echo "${{ github.event.pull_request.number }}" > pr-meta/number
echo "${{ github.event.pull_request.head.ref }}" > pr-meta/head_ref
echo "${{ github.event.pull_request.base.ref }}" > pr-meta/base_ref
- name: Upload PR metadata
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v7
with:
name: pr-metadata
path: pr-meta/
audit:
name: Audit Dependencies
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Restore node_modules
id: cache
uses: actions/cache@v4
with:
path: node_modules/
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Audit dependencies
run: npm audit --audit-level=high