-
Notifications
You must be signed in to change notification settings - Fork 14
445 lines (386 loc) · 16 KB
/
build-and-deploy.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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
name: Build Maven Project
on:
push:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: 'latest'
- name: Create kubeconfig file
run: |
mkdir $HOME/.kube
echo "${{ secrets.KUBE_CONFIG_DATA }}" > $HOME/.kube/config
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_PASSWORD # env variable for token in deploy
gpg-private-key: ${{ secrets.MVN_GPG_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Cache Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2-
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: react/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('react/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-modules-
- name: Clone ant-media-server-parent
run: |
git clone --depth=1 https://github.com/ant-media/ant-media-server-parent.git
cd ant-media-server-parent
mvn clean install -DskipTests -Dmaven.javadoc.skip=true -Dgpg.skip=true --quiet
cd ..
- name: Clone Ant-Media-Server
run: |
CI_COMMIT_REF_NAME=$(echo $GITHUB_REF | cut -d'/' -f 3)
(if [ $(git ls-remote https://github.com/ant-media/Ant-Media-Server.git $CI_COMMIT_REF_NAME | wc -l) == "1" ];
then
echo "$CI_COMMIT_REF_NAME branch found in Ant-Media-Server";
git clone --depth=1 -b $CI_COMMIT_REF_NAME https://github.com/ant-media/Ant-Media-Server.git;
else
echo "$CI_COMMIT_REF_NAME branch not. Checking out master";
git clone --depth=1 https://github.com/ant-media/Ant-Media-Server.git;
fi)
cd Ant-Media-Server
mvn clean install -DskipTests -Dmaven.javadoc.skip=true -Dgpg.skip=true --quiet
cd ..
- name: Build React application for webinar
env:
CI: false
NODE_OPTIONS: '--max-old-space-size=4096'
run: |
cd react
mv .env.production .env.production.conferencing
mv .env.production.webinar .env.production
sed -i "s#^REACT_APP_TURN_SERVER_URL=.*#REACT_APP_TURN_SERVER_URL=\"turn:${{ secrets.STAGING_TURN_URL }}\"#" .env.production
sed -i "s#^REACT_APP_TURN_SERVER_USERNAME=.*#REACT_APP_TURN_SERVER_USERNAME=\"${{ secrets.STAGING_TURN_USERNAME }}\"#" .env.production
sed -i "s#^REACT_APP_TURN_SERVER_CREDENTIAL=.*#REACT_APP_TURN_SERVER_CREDENTIAL=\"${{ secrets.STAGING_TURN_PASSWORD }}\"#" .env.production
npm install
npm run build
cd ..
rm -r webapp/src/main/webapp/static/*
cp -a react/build/. webapp/src/main/webapp
- name: Build Maven project for webinar
run: |
cd webapp
mvn clean install -DskipTests -Dgpg.skip=true --quiet
ls -alh
ls -alh target/
cp target/*.war /tmp/circle-webinar.war
cd ..
- name: Build React application for conferencing
env:
CI: false
NODE_OPTIONS: '--max-old-space-size=4096'
run: |
cd react
mv .env.production.conferencing .env.production
sed -i "s#^REACT_APP_TURN_SERVER_URL=.*#REACT_APP_TURN_SERVER_URL=\"turn:${{ secrets.STAGING_TURN_URL }}\"#" .env.production
sed -i "s#^REACT_APP_TURN_SERVER_USERNAME=.*#REACT_APP_TURN_SERVER_USERNAME=\"${{ secrets.STAGING_TURN_USERNAME }}\"#" .env.production
sed -i "s#^REACT_APP_TURN_SERVER_CREDENTIAL=.*#REACT_APP_TURN_SERVER_CREDENTIAL=\"${{ secrets.STAGING_TURN_PASSWORD }}\"#" .env.production
npm install
npm run build
cd ..
rm -r webapp/src/main/webapp/static/*
cp -a react/build/. webapp/src/main/webapp
- name: Build Maven project for conferencing
run: |
cd webapp
mvn clean install -DskipTests -Dgpg.skip=true --quiet
ls -alh
ls -alh target/
cp target/*.war /tmp/circle-conferencing.war
cd ..
- name: Create Test Tool
run: |
sudo apt-get update
sudo apt-get install -y unzip iproute2 libva-drm2 libva-x11-2 libvdpau-dev ffmpeg
git clone https://gitlab.com/Ant-Media/webrtc-test.git
cd webrtc-test
./redeploy.sh
cd ..
- name: Cache Test Tool
uses: actions/cache@v3
with:
path: webrtc-test/
key: test-tool-${{ hashFiles('**/tool-source/**') }}
restore-keys: test-tool-
- name: Upload conferencing war file as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: circle-conferencing.war
path: /tmp/circle-conferencing.war
- name: Upload webinar war file as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: circle-webinar.war
path: /tmp/circle-webinar.war
- name: Debug WAR file paths
run: ls -alh /tmp
unit-tests:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run Unit Test
run: |
echo "pwd:"
pwd
echo "ls:"
ls -al
cd react
npm install --include=dev
npm test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
conference-integration-tests:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Restore Cached Test Tool
uses: actions/cache@v3
with:
path: webrtc-test/
key: test-tool-${{ hashFiles('**/tool-source/**') }}
restore-keys: test-tool-
- name: Locate Test Tool
run: |
pwd
ls
cp webrtc-test/target/webrtc-load-test-tool-*.zip ../
cd ..
unzip webrtc-load-test-tool-*.zip
mkdir ~/test
mv webrtc-load-test ~/test
ls -al ~/test
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_PASSWORD # env variable for token in deploy
gpg-private-key: ${{ secrets.MVN_GPG_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Download circle-conferencing.war Artifact
uses: actions/download-artifact@v4
with:
name: circle-conferencing.war
path: /tmp
- name: Debug WAR file paths
run: ls -alh /tmp
- name: Install Selenium
run: |
wget https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.58/linux64/chromedriver-linux64.zip
unzip chromedriver-linux64.zip
sudo cp chromedriver-linux64/chromedriver /tmp
ls -al /tmp
pip3 install selenium==4.14
pip3 install requests
pip3 show selenium
pip3 install psutil
- name: Run Integration Test
run: |
cd test
python3 test_main.py ${{ secrets.STAGING_SERVER_URL }} ${{ secrets.USER_NAME }} ${{ secrets.PASSWORD }} /tmp/circle-conferencing.war false
- name: Upload PNG files as artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: ${{ github.workspace }}/test/**/*.png
webinar-integration-tests:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Restore Cached Test Tool
uses: actions/cache@v3
with:
path: webrtc-test/
key: test-tool-${{ hashFiles('**/tool-source/**') }}
restore-keys: test-tool-
- name: Locate Test Tool
run: |
pwd
ls
cp webrtc-test/target/webrtc-load-test-tool-*.zip ../
cd ..
unzip webrtc-load-test-tool-*.zip
mkdir ~/test
mv webrtc-load-test ~/test
- name: Download circle-webinar.war Artifact
uses: actions/download-artifact@v4
with:
name: circle-webinar.war
path: /tmp
- name: Debug WAR file paths
run: ls -alh /tmp
- name: Install Selenium
run: |
wget https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.58/linux64/chromedriver-linux64.zip
unzip chromedriver-linux64.zip
sudo cp chromedriver-linux64/chromedriver /tmp
ls -al /tmp
pip3 install selenium==4.14
pip3 install requests
pip3 show selenium
pip3 install psutil
- name: Run Integration Test for webinar
run: |
sleep 10
cd test
python3 test_main.py ${{ secrets.STAGING_SERVER_URL }} ${{ secrets.USER_NAME }} ${{ secrets.PASSWORD }} /tmp/circle-webinar.war true
collect-and-upload-logs:
needs: [unit-tests, webinar-integration-tests , conference-integration-tests]
if: always()
runs-on: ubuntu-latest
steps:
- name: Upload PNG files as artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: ${{ github.workspace }}/test/**/*.png
- name: Copy Logs From Pods
if: always()
run: |
for pod in $(kubectl -n circle get pods | grep "ant-media-server" | awk '{print $1}'); do
node_ip=$(kubectl -n circle get pods -o wide | grep "$pod" | awk '{print $6}')
kubectl -n circle cp $pod:/usr/local/antmedia/log/ant-media-server.log /tmp/ant-media-server-$node_ip.log
kubectl -n circle cp $pod:/usr/local/antmedia/log/antmedia-error.log /tmp/antmedia-error-$node_ip.log
done
- name: Upload log files as artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: logs
path: /tmp/*.log
deploy:
runs-on: ubuntu-latest
needs: collect-and-upload-logs
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_PASSWORD # env variable for token in deploy
gpg-private-key: ${{ secrets.MVN_GPG_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Build React application for conferencing
env:
CI: false
NODE_OPTIONS: '--max-old-space-size=4096'
run: |
cd react
sed -i "s#^REACT_APP_TURN_SERVER_URL=.*#REACT_APP_TURN_SERVER_URL=\"turn:${{ secrets.STAGING_TURN_URL }}\"#" .env.production
sed -i "s#^REACT_APP_TURN_SERVER_USERNAME=.*#REACT_APP_TURN_SERVER_USERNAME=\"${{ secrets.STAGING_TURN_USERNAME }}\"#" .env.production
sed -i "s#^REACT_APP_TURN_SERVER_CREDENTIAL=.*#REACT_APP_TURN_SERVER_CREDENTIAL=\"${{ secrets.STAGING_TURN_PASSWORD }}\"#" .env.production
npm install
npm run build
cd ..
rm -r webapp/src/main/webapp/static/*
cp -a react/build/. webapp/src/main/webapp
- name: Publish to Maven Central
run: |
cd webapp
ls -alh
mvn -e deploy -DskipTests --quiet --settings ../mvn-settings.xml
sleep 60
env:
MAVEN_USERNAME: ${{ secrets.MVN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MVN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MVN_GPG_PASSPHRASE }}
- name: Get versions data from repo
run: wget -O maven-metadata.xml https://oss.sonatype.org/service/local/repositories/snapshots/content/io/antmedia/webrtc/ConferenceCall/maven-metadata.xml
- name: Install jq
run: sudo apt-get install jq -y
- name: Download war File
run: |
export LATEST_SNAPSHOT=$(cat maven-metadata.xml | grep "<version>" | tail -n 1 | xargs | grep -oP "(?<=<version>).*?(?=</version>)")
echo $LATEST_SNAPSHOT
wget -O ConferenceCall.war "https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=io.antmedia.webrtc&a=ConferenceCall&v=${LATEST_SNAPSHOT}&e=war"
ls -al
if [ ! -f ConferenceCall.war ]; then
echo "War file not found."
exit 1
fi
- name: Login to server
run: |
response=$(curl -X POST -H "Accept: Application/json" -H "Content-Type: application/json" ${{ secrets.STAGING_SERVER_URL }}/rest/v2/users/authenticate -d '{"email":"${{ secrets.USER_NAME }}","password":"${{ secrets.PASSWORD }}"}' -c cookie.txt)
success=$(echo $response | jq -r '.success')
if [ "$success" != "true" ]; then
echo "Login failed"
exit 1
fi
- name: Check if Conference App Exists
run: |
response=$(curl -s -H "Accept: Application/json" -H "Content-Type: application/json" "${{ secrets.STAGING_SERVER_URL }}/rest/v2/applications" -b cookie.txt)
echo $response | jq .
app_exists=$(echo $response | jq -r '.applications | index("Conference")')
if [ "$app_exists" != "null" ]; then
echo "App exists, proceeding to delete it."
response=$(curl -s -X DELETE -H "Accept: Application/json" -H "Content-Type: application/json" "${{ secrets.STAGING_SERVER_URL }}/rest/v2/applications/Conference" -b cookie.txt)
success=$(echo $response | jq -r '.success')
if [ "$success" != "true" ]; then
echo "Conference app deletion failed"
exit 1
fi
sleep 10
else
echo "App does not exist, proceeding to create a new one."
fi
- name: Create New App
run: |
export WAR_FILE_NAME="ConferenceCall.war"
response=$(curl -X PUT -H "Accept: Application/json" -H "Content-Type: multipart/form-data" -F "file=@./$WAR_FILE_NAME" "${{ secrets.STAGING_SERVER_URL }}/rest/v2/applications/Conference" -b cookie.txt)
sleep 5
success=$(echo $response | jq -r '.success')
if [ "$success" != "true" ]; then
echo "Conference app creation is failed"
exit 1
fi
sleep 10
- name: Update Turn Settings
run: |
curl "${{ secrets.STAGING_SERVER_URL }}/rest/v2/applications/settings/Conference" -b cookie.txt -o settings.json
jq '.stunServerURI = "turn:${{ secrets.STAGING_TURN_URL }}" | .turnServerUsername = "${{ secrets.STAGING_TURN_USERNAME }}" | .turnServerCredential = "${{ secrets.STAGING_TURN_PASSWORD }}"' settings.json > updated_settings.json
response=$(curl -X POST -H "Accept: Application/json" -H "Content-Type: application/json" -d @updated_settings.json -b cookie.txt "${{ secrets.STAGING_SERVER_URL }}/rest/v2/applications/settings/Conference")
success=$(echo $response | jq -r '.success')
if [ "$success" != "true" ]; then
echo "Importing setting is failed."
exit 1
fi