-
Notifications
You must be signed in to change notification settings - Fork 0
232 lines (196 loc) · 6.25 KB
/
ci-cd.dev.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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: CI/CD Dev Pipeline
on:
push:
branches:
- develop
pull_request:
branches:
- develop
env:
ENVIRONMENT: dev
DATABASE_URL: ${{ secrets.DATABASE_URL }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
NEXT_PUBLIC_SITE_URL: ${{ secrets.NEXT_PUBLIC_SITE_URL }}
NEXT_PUBLIC_SOCKET_URL: ${{ secrets.NEXT_PUBLIC_SOCKET_URL }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
jobs:
deps-vulnerability:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Create lock file
run: |
cd ./satsquare
npm install --package-lock-only
- name: Install dependencies
run: |
cd ./satsquare
npm ci
npm update
- name: Install jest-environment-jsdom
run: |
cd ./satsquare
npm install jest-environment-jsdom --save-dev
- name: Audit npm dependencies
run: |
cd ./satsquare
npm audit --audit-level=moderate
lint:
needs: deps-vulnerability
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm ci
- name: Run Linting
run: |
cd ./satsquare
npm run lint
unit-tests:
# needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm ci
npm i jest-environment-jsdom jest
- name: Run Jest Unit Tests
run: |
cd ./satsquare
npm run test
codecov:
# needs: unit-tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm ci
npm i jest-environment-jsdom jest
- name: Run tests and generate coverage report
run: |
cd ./satsquare
npm run test -- --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
# security:
# # needs: codecov
# runs-on: ubuntu-latest
# permissions:
# pull-requests: write
# security-events: write
# statuses: write
# contents: write
# issues: write
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - uses: mobb-dev/[email protected]
# with:
# mobb-api-token: ${{ secrets.MOBB_API_TOKEN }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
lighthouse:
# needs: security
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm install
- name: Run Lighthouse CI
run: |
cd ./satsquare
npx lhci autorun
# docker-build:
# # needs: lighthouse
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Login to GitHub Container Registry
# run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# - name: Build Docker image
# run: |
# cd ./satsquare
# docker run -e DATABASE_URL="${{ secrets.DATABASE_URL }}" \
# -e NEXTAUTH_SECRET="${{ secrets.NEXTAUTH_SECRET }}" \
# -e NEXT_PUBLIC_SITE_URL="${{ secrets.NEXT_PUBLIC_SITE_URL }}" \
# -e NEXT_PUBLIC_SOCKET_URL="${{ secrets.NEXT_PUBLIC_SOCKET_URL }}" \
# -p 3000:3000 -p 5157:5157
# docker build -t ghcr.io/ismail-mouyahada/sat-square:dev-${{ github.sha }} -f Dockerfile.dev .
# - name: Scan Docker image for vulnerabilities
# uses: aquasecurity/[email protected]
# with:
# image-ref: ghcr.io/ismail-mouyahada/sat-square:dev-${{ github.sha }}
# - name: Push Docker image to GitHub Container Registry
# run: docker push ghcr.io/ismail-mouyahada/sat-square:dev-${{ github.sha }}
e2e-tests:
# needs: docker-build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm install
- name: Run end-to-end tests
run: |
cd ./satsquare
npm run test:e2e
stress-test:
needs: e2e-tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm install
- name: Run stress tests
run: |
cd ./satsquare
npm run test:stress
notify:
runs-on: ubuntu-latest
# needs: [stress-test]
steps:
- name: Notify Discord
uses: discord-actions/message@v2
with:
webhookUrl: "https://discord.com/api/webhooks/1278096229351293008/UdVm3whQn9wb_neR4tuS5TGFfFzaiAo4Jijwa0yuEks1GwoVdrV-lcsdvw5qlA0Kq9CN"
message: "On est la les BG"
username: "Github"
avatar: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
- name: Notify Discord
if: success()
uses: discord-actions/message@v2
with:
webhookUrl: "https://discord.com/api/webhooks/1278096229351293008/UdVm3whQn9wb_neR4tuS5TGFfFzaiAo4Jijwa0yuEks1GwoVdrV-lcsdvw5qlA0Kq9CN"
message: "Bah Oui ça marche mon gasr 🗺 "
- name: Notify Discord
if: failure()
uses: discord-actions/message@v2
with:
webhookUrl: "https://discord.com/api/webhooks/1278096229351293008/UdVm3whQn9wb_neR4tuS5TGFfFzaiAo4Jijwa0yuEks1GwoVdrV-lcsdvw5qlA0Kq9CN"
message: "Ops tu as glissé mon pote ☣ "
- name: Notify Discord
if: ${{ always() && contains(needs.*.result, 'failure') }}
uses: discord-actions/message@v2
with:
webhookUrl: "https://discord.com/api/webhooks/1278096229351293008/UdVm3whQn9wb_neR4tuS5TGFfFzaiAo4Jijwa0yuEks1GwoVdrV-lcsdvw5qlA0Kq9CN"
message: "C'était presque bon mon kiki ! 😇 "