-
Notifications
You must be signed in to change notification settings - Fork 17
264 lines (235 loc) · 10.3 KB
/
gradle.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
name: Android SDK CI
on: [pull_request]
# Important Information:
# -It's running in ci.antmedia.cloud and Linux hardware acceleration is enabled.
# Check this out -> https://developer.android.com/studio/run/emulator-acceleration#vm-linux
#
# - If runner is not working, start the service.
# Go to /home/ubuntu/actions-runner and execute the following command
# sudo ./svc.sh start
# stop and status commands are also available
# sudo ./svc.sh status
# sudo ./svc.sh stop
# for more information -> https://docs.github.com/en/actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service#customizing-the-self-hosted-runner-service
#
# - For reactivecircus/[email protected] , ANDROID_SDK_ROOT env should be set
# in later versions, ANDROID_HOME should be set
#
# - Important: In the actions-runner directory, add the following lines to the .env directory and .bashrc
# ANDROID_HOME=/home/ubuntu/android
# ANDROID_SDK_ROOT=/home/ubuntu/android
# JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
#
env:
GITHUB_TOKEN: ${{ secrets.G_TOKEN }}
REPO: ${{ github.repository }}
OWNER: ${{ github.repository_owner }}
OS_USERNAME: ${{ secrets.OS_USERNAME }}
OS_PASSWORD: ${{ secrets.OS_PASSWORD }}
OS_PROJECT_NAME: ${{ secrets.OS_PROJECT_NAME }}
OS_AUTH_URL: ${{ secrets.OS_AUTH_URL }}
OS_REGION_NAME: ${{ secrets.OS_REGION_NAME }}
OS_TENANT_ID: ${{ secrets.OS_TENANT_ID }}
OS_TENANT_NAME: ${{ secrets.OS_TENANT_NAME }}
OS_API_VERSION: ${{ secrets.OS_API_VERSION }}
OS_USER_DOMAIN_NAME: ${{ secrets.OS_USER_DOMAIN_NAME }}
INSTANCE_TYPE: "c3-16"
IMAGE_ID: "Ubuntu 24.04"
jobs:
setup-runner:
runs-on: ubuntu-latest
outputs:
server_id: ${{ steps.set-server-id.outputs.server_id }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-pip python3-dev libffi-dev libssl-dev
sudo pip3 install python-openstackclient
- name: server-id
id: set-server-id
run: |
REPO=$(echo "$REPO" | cut -d'/' -f2)
BRANCH_NAME="${{ github.head_ref }}"
SERVER_ID="ci-$REPO-$BRANCH_NAME"
echo $SERVER_ID
echo "server_id=$SERVER_ID" >> $GITHUB_OUTPUT
- name: Configure OpenStack CLI and Create Instance
run: |
echo "Setting up OpenStack CLI environment variables..."
echo "GITHUB_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
sed -i "s/^GITHUB_TOKEN=.*$/GITHUB_TOKEN=${GITHUB_TOKEN}/" user_data.sh
sed -i "s|RUNNER_ORG=\"[^\"]*\"|RUNNER_ORG=\"$REPO\"|g" user_data.sh
SERVER_ID="${{ steps.set-server-id.outputs.server_id }}"
echo $SERVER_ID
openstack server create --flavor "$INSTANCE_TYPE" --image "$IMAGE_ID" --key-name ovh --security-group default --user-data user_data.sh --network Ext-Net $SERVER_ID
echo "Server creation initiated."
STATUS=$(openstack server show $SERVER_ID -f value -c status)
echo "Current server status: $STATUS"
while [[ "$STATUS" != "ACTIVE" && "$STATUS" != "ERROR" ]]; do
echo "Waiting for server to be ACTIVE. Current status: $STATUS"
sleep 10
STATUS=$(openstack server show $SERVER_ID -f value -c status)
done
if [[ "$STATUS" == "ERROR" ]]; then
echo "Server creation failed."
exit 1
fi
- name: Check runner status and wait if offline
id: check_status
run: |
MAX_WAIT=300
WAIT_INTERVAL=10
ELAPSED_TIME=0
RUNNER_STATUS=$(curl -s -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO/actions/runners | jq -r '.runners[0].status')
echo "Initial Runner status is: $RUNNER_STATUS"
while [[ "$RUNNER_STATUS" != "online" && "$ELAPSED_TIME" -lt "$MAX_WAIT" ]]; do
echo "Runner is $RUNNER_STATUS. Waiting for $WAIT_INTERVAL seconds..."
sleep $WAIT_INTERVAL
ELAPSED_TIME=$((ELAPSED_TIME + WAIT_INTERVAL))
RUNNER_STATUS=$(curl -s -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO/actions/runners | jq -r '.runners[0].status')
echo "Runner status is: $RUNNER_STATUS"
done
echo "::set-output name=runner_status::$RUNNER_STATUS"
- name: Cancel workflow if runner is still offline
if: steps.check_status.outputs.runner_status == 'offline'
run: |
exit 1
unit-tests:
needs: setup-runner
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'adopt'
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Gradle Cache
uses: gradle/gradle-build-action@v2
- name: Run ffmpeg
#send test stream to the server to play test
run: ffmpeg -re -stream_loop 20 -i ./webrtc-android-sample-app/src/androidTest/resources/test.flv -codec copy -f flv rtmp://test.antmedia.io/LiveApp/stream556677i4d 2>&1 < /dev/null &
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: 127
install-chromedriver: true
- name: Get Chrome and ChromeDriver Paths
id: paths
run: |
echo "CHROME_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV
echo "CHROMEDRIVER_PATH=${{ steps.setup-chrome.outputs.chromedriver-path }}" >> $GITHUB_ENV
- name: Setting up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install python packages
run: |
#wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.105/linux64/chromedriver-linux64.zip
#unzip chromedriver-linux64.zip
#cp chromedriver-linux64/chromedriver /home/ubuntu
pip3 install requests selenium==4.14 flask
- name: Run Multitrack Conference Test Server
run: python3 multitrack-conference-server.py &
- name: Run Tests and Generate Report
uses: reactivecircus/[email protected]
with:
api-level: 33
arch: x86_64
target: playstore
emulator-build: 9322596 #31.3.14.0 It can be get by running -> ./emulator -version
force-avd-creation: false
disable-animations: true
cores: 3
emulator-options: -no-snapshot-save -gpu swiftshader_indirect -no-window -noaudio -no-boot-anim
script: |
touch emulator.log
chmod 777 emulator.log
adb logcat io.antmedia:I >> emulator.log &
./gradlew jacocoTestReport; EXIT_CODE=$?; exit $EXIT_CODE
- name: Archive Test Report
if: always()
uses: actions/upload-artifact@v3
with:
name: Test report
path: |
webrtc-android-sample-app/build/reports/tests/testDebugUnitTest/
webrtc-android-sample-app/build/reports/jacoco/jacocoTestReport/
webrtc-android-sample-app/build/reports/androidTests/
webrtc-android-sample-app/build/outputs/connected_android_test_additional_output/
webrtc-android-framework/build/reports/tests/testDebugUnitTest/
webrtc-android-framework/build/reports/jacoco/jacocoTestReport/
webrtc-android-framework/build/reports/androidTests/
webrtc-android-sample-app/build/logcat.txt
webrtc-android-sample-app/build/screen.png
emulator.log
- name: Upload Test Report to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: webrtc-android-framework/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml,webrtc-android-sample-app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml
fail_ci_if_error: true
- name: Deploy to Sonatype
#deploy only in master branches
if: github.ref == 'refs/heads/master'
run: ./gradlew publish
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
clean:
needs: [setup-runner, unit-tests]
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Delete runner
if: ${{ always() }}
run: |
echo "GITHUB_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
RUNNER_ID=$(curl -s -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO/actions/runners | jq -r '.runners[0].id')
echo "Deleting runner with ID: $RUNNER_ID"
curl -X DELETE -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO/actions/runners/$RUNNER_ID
echo "Runner deleted successfully."
- name: Install Dependencies
if: ${{ always() }}
run: |
sudo apt-get update
sudo apt-get install -y python3-pip python3-dev libffi-dev libssl-dev
sudo pip3 install python-openstackclient
- name: Delete CI Instance
if: ${{ always() }}
run: |
SERVER_ID="${{ needs.setup-runner.outputs.server_id }}"
echo "server id" $SERVER_ID
if [ -n "$SERVER_ID" ]; then
openstack server delete $SERVER_ID
echo $SERVER_ID
else
echo "SERVER_ID is empty, skipping server delete."
fi