-
Notifications
You must be signed in to change notification settings - Fork 638
276 lines (224 loc) · 10.5 KB
/
test.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
name: Ant Media Server Community Edition Test
on:
push:
branches:
- '**'
tags:
- 'ams-v*'
pull_request:
branches:
- '**'
env:
RUNNER: ubuntu-22.04
jobs:
run-unit-tests:
runs-on: ubuntu-22.04
env:
GPG_TTY: ${{ secrets.GPG_TTY }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt' #openjdk
java-version: '17'
cache: 'maven'
- name: Add MongoDB 6.0 GPG key and repository
run: |
if [ ! -f /usr/share/keyrings/mongodb-server-6.0.gpg ]; then
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor
fi
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
- name: Add Redis repository
run: |
sudo rm -rf /usr/share/keyrings/redis-archive-keyring.gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y redis redis-tools mongodb-org ffmpeg wondershaper
- name: Start Redis
run: sudo systemctl start redis-server
- name: Start MongoDB
run: sudo systemctl start mongod
- name: Install Onvif Simulator
run: sudo git clone --depth=1 https://github.com/ant-media/utilities.git /usr/local/onvif
- name: Build projects
uses: ./.github/actions/build-projects
with:
branch_name: ${{ github.ref_name }}
- name: Run tests and SonarCloud analysis
run: |
export RELEASE_VERSION="$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)"
echo $RELEASE_VERSION
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package -Dtest=!*/integration/* -Dorg.bytedeco.javacpp.logger.debug=false org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dmaven.javadoc.skip=true --quiet
- name: Show MongoDB Log, Crash Log and Servis Status on failure
if: failure()
run: |
if [[ -f /var/log/mongodb/mongod.log ]]; then
sudo cat /var/log/mongodb/mongod.log
fi
if [[ -f hs_err_pid*.log ]]; then
cat hs_err_pid*.log
else
echo "No hs_err_pid*.log file found"
fi
sudo service mongod status
sudo service redis-server status
check-vulnerabilities:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt' #openjdk
java-version: '17'
cache: 'maven'
- name: Build projects
uses: ./.github/actions/build-projects
with:
branch_name: ${{ github.ref_name }}
- name: Check vulnerabilities
run: mvn org.owasp:dependency-check-maven:check -DfailOnError=false
- name: Show MongoDB Log, Crash Log and Servis Status on failure
if: failure()
run: |
if [[ -f /var/log/mongodb/mongod.log ]]; then
sudo cat /var/log/mongodb/mongod.log
fi
if [[ -f hs_err_pid*.log ]]; then
cat hs_err_pid*.log
else
echo "No hs_err_pid*.log file found"
fi
sudo service mongod status
sudo service redis-server status
run-integration-tests:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt' #openjdk
java-version: '17'
cache: 'maven'
- name: Add MongoDB 6.0 GPG key and repository
run: |
if [ ! -f /usr/share/keyrings/mongodb-server-6.0.gpg ]; then
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor
fi
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
- name: Add Redis repository
run: |
sudo rm -rf /usr/share/keyrings/redis-archive-keyring.gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
- name: Add ffmpeg7 repo
run: sudo add-apt-repository ppa:ubuntuhandbook1/ffmpeg7 -y
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y redis redis-tools mongodb-org ffmpeg wondershaper
- name: Start Redis
run: sudo systemctl start redis-server
- name: Start MongoDB
run: sudo systemctl start mongod
- name: Install Chrome
run: |
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt-get install -y ./google-chrome-stable_current_amd64.deb
- name: Install Onvif Simulator
run: sudo git clone --depth=1 https://github.com/ant-media/utilities.git /usr/local/onvif
- name: Build projects
uses: ./.github/actions/build-projects
with:
branch_name: ${{ github.ref_name }}
- name: Package Ant Media Server
run: mvn clean package -U -P assemble -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -DskipTests=true --quiet
- name: Install Ant Media Server
run: |
wget https://raw.githubusercontent.com/ant-media/Scripts/${{ github.ref_name }}/install_ant-media-server.sh -O target/install_ant-media-server.sh || wget https://raw.githubusercontent.com/ant-media/Scripts/master/install_ant-media-server.sh -O target/install_ant-media-server.sh
chmod 755 target/install_ant-media-server.sh
cd target
sudo ./install_ant-media-server.sh -i ant-media-server-community*.zip
cd ..
sleep 20
sudo cp src/test/resources/preset-red5-web.properties /usr/local/antmedia/webapps/LiveApp/WEB-INF/red5-web.properties
sudo cp src/test/resources/preset-red5-web.db /usr/local/antmedia/liveapp.db
sudo sed -i 's^server.cpu_limit=.*^server.cpu_limit=100^' /usr/local/antmedia/conf/red5.properties
sudo sed -i 's^server.memory_limit_percentage=.*^server.memory_limit_percentage=100^' /usr/local/antmedia/conf/red5.properties
sudo chown -R antmedia:antmedia /usr/local/antmedia/
sudo service antmedia stop
sudo service antmedia start
sleep 10
- name: Run integration tests
run: |
export RELEASE_VERSION="$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)"
echo $RELEASE_VERSION
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package -Dtest=*/integration/* -Dmaven.javadoc.skip=true --quiet
- name: Show Ant Media Server Error Log on failure
if: failure()
run: cat /usr/local/antmedia/log/antmedia-error.log
- name: Show Ant Media Server Log on failure
if: failure()
run: cat /usr/local/antmedia/log/ant-media-server.log
- name: Show MongoDB Log, Crash Log and Servis Status on failure
if: failure()
run: |
if [[ -f /var/log/mongodb/mongod.log ]]; then
sudo cat /var/log/mongodb/mongod.log
fi
if [[ -f /usr/local/antmedia/hs_err_pid*.log ]]; then
cat /usr/local/antmedia/hs_err_pid*.log
fi
if [[ -f hs_err_pid*.log ]]; then
cat hs_err_pid*.log
else
echo "No hs_err_pid*.log file found"
fi
sudo service mongod status
sudo service redis-server status
deploy:
runs-on: ubuntu-22.04
needs: [run-unit-tests, check-vulnerabilities, run-integration-tests]
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt' #openjdk
java-version: '17'
cache: 'maven'
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Build projects # there is low probability that if somethings has pushed to the related branch while running test and before this job, it may build something not exactly same
uses: ./.github/actions/build-projects
with:
branch_name: ${{ github.ref_name }}
- name: Deploy snapshots
#if it is a master branch
if: github.ref == 'refs/heads/master' #if it is a master branch
run: |
echo "Deploy to snapshots"
mvn deploy -P assemble -DskipTests --settings mvn-settings.xml
echo "Deploy to snapshots exited with $?"
- name: Deploy release
#if it is a tagged
if: startsWith(github.ref, 'refs/tags/ams-v')
run: |
echo "Deploy to release"
mvn deploy -P assemble -DskipTests --settings mvn-settings.xml --quiet
echo "Deploy to release exited with $?"