-
Notifications
You must be signed in to change notification settings - Fork 26
318 lines (302 loc) · 13.6 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
name: CI jobs
on:
push:
jobs:
aaa:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install software
run: |
mkdir -p ${HOME}/bin && curl https://raw.githubusercontent.com/vishnubob/wait-for-it/8ed92e8cab83cfed76ff012ed4a36cef74b28096/wait-for-it.sh > ${HOME}/bin/wait-for-it.sh && chmod +x ${HOME}/bin/wait-for-it.sh
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: liberica
java-version: 17.0.4
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.m2/wrapper
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/.mvn/wrapper/maven-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Start & wait docker-compose environment
run: |
docker-compose up -d postgresql redis rabbitmq jaeger
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:35432 -- echo 'postgres is up'
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:36379 -- echo 'redis is up'
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:36672 -- echo 'rabbitmq is up'
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:6831 -- echo 'jaeger is up'
docker-compose -f docker-compose.keycloak.yml up -d keycloak
sleep 15 && ${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:8484 -- echo 'keycloak is up'
- name: Build and test with Maven
run: |
(cd aaa; make check-env clean download package test)
- name: Build docker image and deploy
if: github.ref == 'refs/heads/master'
run: |
mkdir -p ~/.ssh && openssl aes-256-cbc -K ${{ secrets.EncryptedKey }} -iv ${{ secrets.EncryptedIv }} -in ./.secret_keys/id_rsa.enc -out ~/.ssh/id_rsa -d
chmod 600 ~/.ssh/id_rsa
echo "Will login to docker" &&
docker login -u="nkonev" -p="${{ secrets.DockerPassword }}"
(cd aaa; make push-docker && echo "Will deploy aaa" && ssh -o "BatchMode yes" -o StrictHostKeyChecking=no -q ${{ secrets.ConnectLine }} ${{ secrets.AaaUpdateCommand }} )
frontend:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18.16.0
- name: Cache Node.js dependencies
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-frontend-cache-v2-${{ hashFiles('**/package-lock.json') }}
- name: Build with npm run
run: |
(cd frontend; make check-env clean download package)
- name: Build docker image and deploy
if: github.ref == 'refs/heads/master'
run: |
mkdir -p ~/.ssh && openssl aes-256-cbc -K ${{ secrets.EncryptedKey }} -iv ${{ secrets.EncryptedIv }} -in ./.secret_keys/id_rsa.enc -out ~/.ssh/id_rsa -d
chmod 600 ~/.ssh/id_rsa
echo "Will login to docker" &&
docker login -u="nkonev" -p="${{ secrets.DockerPassword }}"
(cd frontend; make push-docker && echo "Will deploy frontend" && ssh -o "BatchMode yes" -o StrictHostKeyChecking=no -q ${{ secrets.ConnectLine }} ${{ secrets.FrontendUpdateCommand }} )
chat:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-chat-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install software
run: |
mkdir -p ${HOME}/bin && curl https://raw.githubusercontent.com/vishnubob/wait-for-it/8ed92e8cab83cfed76ff012ed4a36cef74b28096/wait-for-it.sh > ${HOME}/bin/wait-for-it.sh && chmod +x ${HOME}/bin/wait-for-it.sh
- name: Start & wait docker-compose environment
run: |
docker-compose up -d postgresql redis rabbitmq
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:35432 -- echo 'postgres is up'
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:36379 -- echo 'redis is up'
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:36672 -- echo 'rabbitmq is up'
- name: Build and test with make
run: (cd chat; sleep 5 && make check-env clean download generate test package)
- name: Build docker image and deploy
if: github.ref == 'refs/heads/master'
run: |
mkdir -p ~/.ssh && openssl aes-256-cbc -K ${{ secrets.EncryptedKey }} -iv ${{ secrets.EncryptedIv }} -in ./.secret_keys/id_rsa.enc -out ~/.ssh/id_rsa -d
chmod 600 ~/.ssh/id_rsa
echo "Will login to docker" &&
docker login -u="nkonev" -p="${{ secrets.DockerPassword }}"
(cd chat; make push-docker && echo "Will deploy chat" && ssh -o "BatchMode yes" -o StrictHostKeyChecking=no -q ${{ secrets.ConnectLine }} ${{ secrets.ChatUpdateCommand }} )
event:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-event-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build and test with make
run: (cd event; make check-env clean download generate test package)
- name: Build docker image and deploy
if: github.ref == 'refs/heads/master'
run: |
mkdir -p ~/.ssh && openssl aes-256-cbc -K ${{ secrets.EncryptedKey }} -iv ${{ secrets.EncryptedIv }} -in ./.secret_keys/id_rsa.enc -out ~/.ssh/id_rsa -d
chmod 600 ~/.ssh/id_rsa
echo "Will login to docker" &&
docker login -u="nkonev" -p="${{ secrets.DockerPassword }}"
(cd event; make push-docker && echo "Will deploy event" && ssh -o "BatchMode yes" -o StrictHostKeyChecking=no -q ${{ secrets.ConnectLine }} ${{ secrets.EventUpdateCommand }} )
notification:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-notification-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build and test with make
run: (cd notification; make check-env clean download generate test package)
- name: Build docker image and deploy
if: github.ref == 'refs/heads/master'
run: |
mkdir -p ~/.ssh && openssl aes-256-cbc -K ${{ secrets.EncryptedKey }} -iv ${{ secrets.EncryptedIv }} -in ./.secret_keys/id_rsa.enc -out ~/.ssh/id_rsa -d
chmod 600 ~/.ssh/id_rsa
echo "Will login to docker" &&
docker login -u="nkonev" -p="${{ secrets.DockerPassword }}"
(cd notification; make push-docker && echo "Will deploy notification" && ssh -o "BatchMode yes" -o StrictHostKeyChecking=no -q ${{ secrets.ConnectLine }} ${{ secrets.NotificationUpdateCommand }} )
storage:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-storage-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build and test with make
run: (cd storage; make check-env clean download generate test package)
- name: Build docker image and deploy
if: github.ref == 'refs/heads/master'
run: |
mkdir -p ~/.ssh && openssl aes-256-cbc -K ${{ secrets.EncryptedKey }} -iv ${{ secrets.EncryptedIv }} -in ./.secret_keys/id_rsa.enc -out ~/.ssh/id_rsa -d
chmod 600 ~/.ssh/id_rsa
echo "Will login to docker" &&
docker login -u="nkonev" -p="${{ secrets.DockerPassword }}"
(cd storage; make push-docker && echo "Will deploy storage" && ssh -o "BatchMode yes" -o StrictHostKeyChecking=no -q ${{ secrets.ConnectLine }} ${{ secrets.StorageUpdateCommand }} )
video:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-video-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build and test with make
run: (cd video; make check-env clean download generate test package)
- name: Build docker image and deploy
if: github.ref == 'refs/heads/master'
run: |
mkdir -p ~/.ssh && openssl aes-256-cbc -K ${{ secrets.EncryptedKey }} -iv ${{ secrets.EncryptedIv }} -in ./.secret_keys/id_rsa.enc -out ~/.ssh/id_rsa -d
chmod 600 ~/.ssh/id_rsa
echo "Will login to docker" &&
docker login -u="nkonev" -p="${{ secrets.DockerPassword }}"
(cd video; make push-docker && echo "Will deploy video" && ssh -o "BatchMode yes" -o StrictHostKeyChecking=no -q ${{ secrets.ConnectLine }} ${{ secrets.VideoUpdateCommand }} )
e2e-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install software
run: |
mkdir -p ${HOME}/bin && curl https://raw.githubusercontent.com/vishnubob/wait-for-it/8ed92e8cab83cfed76ff012ed4a36cef74b28096/wait-for-it.sh > ${HOME}/bin/wait-for-it.sh && chmod +x ${HOME}/bin/wait-for-it.sh
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: liberica
java-version: 17.0.4
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.m2/wrapper
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/.mvn/wrapper/maven-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/setup-node@v3
with:
node-version: 16.13.0
- name: Cache Playwright browsers and Node.js dependencies
uses: actions/cache@v3
with:
path: |
**/node_modules
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-browsers-v0-${{ hashFiles('**/package-lock.json') }}
- name: Install Playwright Node.js dependencies
run: (cd e2e-test; npm ci)
- name: Install Playwright browsers
run: (cd e2e-test; npx playwright install)
- name: Cache frontend Node.js dependencies
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-frontend-cache-v2-${{ hashFiles('**/package-lock.json') }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Cache go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-e2e-test-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Start and wait docker-compose
run: |
docker-compose up -d postgresql redis rabbitmq jaeger minio traefik
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:35432 -- echo 'postgres is up'
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:36379 -- echo 'redis is up'
sleep 5 && ${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:36672 -- echo 'rabbitmq is up'
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:16686 -- echo 'jaeger web ui is up'
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:9000 -- echo 'minio is up'
${HOME}/bin/wait-for-it.sh -t 30 127.0.0.1:8081 -- echo 'traefik is up'
- name: Build microservices
run: |
(cd aaa; make check-env clean download package-java)
(cd frontend; make check-env clean download package)
(cd chat; make check-env clean download generate package-go)
(cd event; make check-env clean download generate package-go)
- name: Run microservices
run: |
(cd aaa; ./run-with-oauth2.sh &)
(cd chat; ./chat &)
(cd event; ./event &)
# Using port 3000 we mimic to Vite's npm run dev
(docker run --rm -p 3000:8082 nkonev/chat-frontend:latest &)
- name: Wait for microservices
run: |
${HOME}/bin/wait-for-it.sh -t 40 127.0.0.1:8060 -- echo 'aaa is up' # because aaa creates schema
${HOME}/bin/wait-for-it.sh -t 40 127.0.0.1:1235 -- echo 'chat is up'
${HOME}/bin/wait-for-it.sh -t 40 127.0.0.1:1238 -- echo 'event is up'
${HOME}/bin/wait-for-it.sh -t 40 127.0.0.1:3000 -- echo 'front is up'
# Once we started aaa (compiling) we start the emulator
(cd aaa; ./run-oauth2-emu.sh &)
${HOME}/bin/wait-for-it.sh -t 40 127.0.0.1:9080 -- echo 'oauth2 emulator controller is up'
- name: Run your Playwright tests
run: (cd e2e-test; npx playwright test)
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: playwright-results
path: e2e-test/test-results