-
Notifications
You must be signed in to change notification settings - Fork 0
273 lines (235 loc) · 8.54 KB
/
Copy pathupdate.yml
File metadata and controls
273 lines (235 loc) · 8.54 KB
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
name: Update Test
on:
workflow_dispatch:
schedule:
- cron: '0 1 * * 1' # Monday at 01:00AM UTC
- cron: '0 1 * * 2-5' # Tuesday to Friday at 01:00AM
permissions:
# Only need read access to repository contents
contents: read
env:
SINCE_REF: ${{ github.event.schedule == '0 1 * * 1' && 'last friday' || 'yesterday' }}
UNTIL_REF: ${{ github.event.schedule == '0 1 * * 1' && 'last saturday' || 'today' }}
jobs:
# Firstly, check if there were changes the day before. If not, aborting
check_repo_changes:
name: Check changes in Android app
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.check.outputs.has_changes }}
steps:
- name: Checkout external repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
repository: owncloud/android
ref: master
fetch-depth: 0
path: android-repo
- name: Check commits from previous day
id: check
shell: bash
run: |
cd android-repo
export TZ="Europe/Madrid"
SINCE=$(date -d "$SINCE_REF" +"%Y-%m-%d 00:00:00")
UNTIL=$(date -d "$UNTIL_REF" +"%Y-%m-%d 00:00:00")
echo "Checking commits in external repo between:"
echo "SINCE=$SINCE"
echo "UNTIL=$UNTIL"
COMMITS=$(git rev-list --count --since="$SINCE" --until="$UNTIL" origin/master)
echo "Commits found: $COMMITS"
if [ "$COMMITS" -gt 0 ]; then
echo "has_changes=true" >> "$GITHUB_OUTPUT"
else
echo "has_changes=false" >> "$GITHUB_OUTPUT"
fi
# Creates oCIS server
create_ocis:
name: Provision of oCIS server
needs:
- check_repo_changes
if: github.event_name == 'workflow_dispatch' || needs.check_repo_changes.outputs.has_changes == 'true'
uses: ./.github/workflows/ocisbackend.yml
with:
ocis_version: ${{ vars.OCIS_VERSION }}
secrets:
ocis_url: ${{ secrets.OC_SERVER_URL }}
ssh_host: ${{ secrets.SSH_HOST }}
ssh_user: ${{ secrets.SSH_USER }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
ocis_pwd: ${{ secrets.OCIS_PWD }}
# Builds the apk to install from the "latest" tag (current stable)
build_apk_latest:
name: Build latest APK
needs:
- check_repo_changes
if: github.event_name == 'workflow_dispatch' || needs.check_repo_changes.outputs.has_changes == 'true'
uses: owncloud/android/.github/workflows/build-apk.yml@master
with:
build_variant: qaRelease
version: latest
# Builds the apk to install from the current master
build_apk_master:
name: Build master APK
needs:
- check_repo_changes
if: github.event_name == 'workflow_dispatch' || needs.check_repo_changes.outputs.has_changes == 'true'
uses: owncloud/android/.github/workflows/build-apk.yml@master
with:
build_variant: qaRelease
version: master
# Signs build from latest
sign_latest:
name: Sign latest APK
needs:
- build_apk_latest
uses: ./.github/workflows/sign-apk.yml
with:
version: latest
unsigned_artifact_name: ${{ needs.build_apk_latest.outputs.artifact_name }}
secrets: inherit
# Signs build from master
sign_master:
name: Sign master APK
needs:
- build_apk_master
uses: ./.github/workflows/sign-apk.yml
with:
version: master
unsigned_artifact_name: ${{ needs.build_apk_master.outputs.artifact_name }}
secrets: inherit
# Launches the test
update_test:
name: Update test
needs:
- build_apk_master
- sign_latest
- sign_master
- create_ocis
runs-on: ubuntu-latest
env:
BUILD_TOOLS_VERSION: "34.0.0"
steps:
# Checkout repo
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Show current branch and commit
run: |
echo "=== Current branch and commit info ==="
git rev-parse --abbrev-ref HEAD
git rev-parse HEAD
echo "======================================"
# Download the APK artifact published by sign_latest job
- name: Download signed APK from latest
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: owncloudSigned-latest
path: ./
# Download the APK artifact published by sign_master job
- name: Download signed APK from master
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: owncloudSigned-master
path: ./
# Move apk to resources folder
- name: Move and rename APKs to resources directory
run: |
ls -al .
mv ./owncloudSigned-latest.apk ./src/test/resources/owncloudSignedLatest.apk
mv ./owncloudSigned-master.apk ./src/test/resources/owncloudSignedMaster.apk
ls -al ./src/test/resources
# Start Appium server
- name: Start Appium
run: |
mkdir -p logs video
chmod +x ./runAppium.sh
./runAppium.sh
# Enable KVM for emulator acceleration
- 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
# Shorten the commit hash to use to compare in the UI
- name: Shorten the built commit hash
shell: bash
run: |
COMMIT_HASH="${{ needs.build_apk_master.outputs.commit_hash }}"
SHORT_HASH=${COMMIT_HASH:0:7}
echo Hash shortened: $SHORT_HASH
echo "SHORT_HASH=$SHORT_HASH" >> $GITHUB_ENV
# Run tests over emulator and catch crash logs
- name: Run Emulator & Execute tests
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d
id: execution
env:
URL: ${{ secrets.OC_SERVER_URL }}
USER: ${{ secrets.OC_SERVER_USERNAME_TEST }}
PASSWORD: ${{ secrets.OC_SERVER_PASSWORD_TEST }}
SHORT_HASH: ${{ env.SHORT_HASH }}
with:
api-level: 31
target: google_apis
arch: x86_64
profile: pixel_5
avd-name: test-avd
force-avd-creation: true
disable-animations: true
emulator-options: -no-snapshot -no-window -no-audio -no-boot-anim -accel on -memory 4096 -gpu swiftshader_indirect -feature -Vulkan -no-metrics
script: |
# To catch only crashes in background
adb logcat -b crash *:E > crash_log.txt 2>&1 &
LOGCAT_PID=$!
./gradlew --no-daemon clean test -Dserver="$URL" -Dusername="$USER" -Dpassword="$PASSWORD" -Dcommit="$SHORT_HASH"
# Kill logcat to serve crash_log.txt
kill $LOGCAT_PID || true
# If crash happened, upload crash log
- name: Upload crash log artifact
if: always() && hashFiles('crash_log.txt') != ''
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: crash-log
path: crash_log.txt
# Prepare crash log file to be uploaded
- name: Rename log file
if: always()
run: |
cp logs/*.log logs/log.log || true
# Upload log file
- name: Upload Execution Log
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: logs
path: ./logs/log.log
# Upload appium log
- name: Upload Appium Log
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: appium
path: ./appium.log
# Prepare video file to be uploaded by compressing it
- name: Zip video files
if: always()
run: zip -r -9 test-recording.zip video || true
# Upload video file
- name: Upload Video
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: video-recording
path: ./test-recording.zip
# Cleans up the server
cleanup:
name: Clean Up
needs:
- update_test
- create_ocis
- check_repo_changes
if: always() && (github.event_name == 'workflow_dispatch' || needs.check_repo_changes.outputs.has_changes == 'true')
uses: ./.github/workflows/cleanup.yml
secrets:
ssh_host: ${{ secrets.SSH_HOST }}
ssh_user: ${{ secrets.SSH_USER }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}