forked from zingolabs/zingo-mobile
-
Notifications
You must be signed in to change notification settings - Fork 1
273 lines (237 loc) · 8.62 KB
/
android-ubuntu-integration-test-ci.yaml
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: Android Ubuntu Integration tests
on:
workflow_call:
inputs:
timestamp:
required: true
type: string
cache-key:
required: true
type: string
abi:
required: true
type: string
api-level:
required: true
type: string
target:
required: true
type: string
env:
REPO-OWNER: ${{ github.repository_owner }}
ABI: ${{ inputs.abi }}
API-LEVEL: ${{ inputs.api-level }}
TARGET: ${{ inputs.target }}
TIMESTAMP: ${{ inputs.timestamp }}
jobs:
android-ubuntu-integration-test-ci-avd-cache:
name: Avd Cache Integration
runs-on: ubuntu-22.04
env:
CACHE-KEY: ${{ inputs.cache-key }}
steps:
- name: Set envs for zingolib CI
if: ${{ contains(github.repository, 'zingolib') }}
run: echo "REPO-OWNER=zingolabs" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ env.REPO-OWNER }}/zingo-mobile
- name: Set envs for x86_64
if: ${{ env.ABI == 'x86_64' }}
run: |
echo "AVD-ARCH=x86_64" >> $GITHUB_ENV
- name: Set envs for x86
if: ${{ env.ABI == 'x86' }}
run: |
echo "AVD-ARCH=x86" >> $GITHUB_ENV
- name: Set envs for arm64-v8a
if: ${{ env.ABI == 'arm64-v8a' }}
run: |
echo "AVD-ARCH=arm64-v8a" >> $GITHUB_ENV
- name: Set envs for armeabi-v7a
if: ${{ env.ABI == 'armeabi-v7a' }}
run: |
echo "AVD-ARCH=arm64-v8a" >> $GITHUB_ENV
- 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: Check AVD cache
uses: actions/cache/restore@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.ABI }}-api-${{ env.API-LEVEL }}-integ
lookup-only: true
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.API-LEVEL }}
arch: ${{ env.AVD-ARCH }}
target: ${{ env.TARGET }}
force-avd-creation: true
emulator-options: -no-snapshot-load -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Save AVD cache
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
id: avd-cache-saving
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.ABI }}-api-${{ env.API-LEVEL }}-integ
android-ubuntu-integration-test-ci:
name: Android Ubuntu Integration test
needs: android-ubuntu-integration-test-ci-avd-cache
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
test: [
"offline_testsuite",
"execute_sync_from_seed",
"execute_send_from_orchard",
"execute_currentprice_and_value_transfers_from_seed",
"execute_sapling_balance_from_seed",
"execute_parse_addresses"
]
env:
CACHE-KEY: ${{ inputs.cache-key }}
steps:
- name: Set envs for zingolib CI
if: ${{ contains(github.repository, 'zingolib') }}
run: echo "REPO-OWNER=zingolabs" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ env.REPO-OWNER }}/zingo-mobile
- name: Set envs for x86_64
if: ${{ env.ABI == 'x86_64' }}
run: |
echo "AVD-ARCH=x86_64" >> $GITHUB_ENV
echo "NEXTEST-ABI=x86_64" >> $GITHUB_ENV
- name: Set envs for x86
if: ${{ env.ABI == 'x86' }}
run: |
echo "AVD-ARCH=x86" >> $GITHUB_ENV
echo "NEXTEST-ABI=x86_32" >> $GITHUB_ENV
- name: Set envs for arm64-v8a
if: ${{ env.ABI == 'arm64-v8a' }}
run: |
echo "AVD-ARCH=arm64-v8a" >> $GITHUB_ENV
echo "NEXTEST-ABI=arm64" >> $GITHUB_ENV
- name: Set envs for armeabi-v7a
if: ${{ env.ABI == 'armeabi-v7a' }}
run: |
echo "AVD-ARCH=arm64-v8a" >> $GITHUB_ENV
echo "NEXTEST-ABI=arm32" >> $GITHUB_ENV
- name: Remove unnecessary directories to free up space
run: |
echo "Disk space before post-build cleanup:"
df -h
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/local/lib/android/sdk/ndk
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo apt-get clean
echo "Disk space after post-build cleanup:"
df -h
- name: Grant permissions
run: |
sudo chmod 777 /var/run/docker.sock
sudo chmod 777 ./scripts/ci/integration_tests_ci.sh
- 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: Install protoc
run: sudo apt install protobuf-compiler
- name: Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Install nextest
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: rust
- name: Pull regchest docker image
run: docker pull zingodevops/regchest:009
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Gradle cache
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.2
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev'}}
- name: Native rust cache
uses: actions/cache/restore@v4
with:
path: android/app/src/main/jniLibs/${{ env.ABI }}
key: native-android-uniffi-${{ env.ABI }}-${{ env.CACHE-KEY }}
fail-on-cache-miss: true
- name: Kotlin uniffi cache
uses: actions/cache/restore@v4
with:
path: android/app/build/generated/source/uniffi/debug/java/uniffi/zingo
key: kotlin-android-uniffi-${{ env.ABI }}-${{ env.CACHE-KEY }}
fail-on-cache-miss: true
- name: Restore AVD cache
uses: actions/cache/restore@v4
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.ABI }}-api-${{ env.API-LEVEL }}-integ
fail-on-cache-miss: true
- name: Yarn install
run: yarn
- name: Run Build
working-directory: android
run: ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug -PsplitApk=true
- name: Remove unnecessary directories to free up space after build
run: |
echo "Disk space before post-build cleanup:"
df -h
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/local/lib/android/sdk/ndk
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo apt-get clean
echo "Disk space after post-build cleanup:"
df -h
- name: Run Integration Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.API-LEVEL }}
arch: ${{ env.AVD-ARCH }}
target: ${{ env.TARGET }}
force-avd-creation: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: cargo nextest run integration::${{ env.NEXTEST-ABI }}::${{ matrix.test }} --features "ci regchest" --verbose --release
working-directory: ./rust
- name: Upload test reports
if: ${{ ! cancelled() }}
uses: actions/upload-artifact@v4
with:
name: test-integration-reports-${{ env.ABI }}-${{ matrix.test }}-${{ env.TIMESTAMP }}
path: android/app/build/outputs/integration_test_reports