Skip to content

Commit a93c26e

Browse files
authored
Cache test VM (#387)
1 parent 4151664 commit a93c26e

2 files changed

Lines changed: 42 additions & 32 deletions

File tree

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
name: OpenDocument-Reader-Android
1+
name: build_test
22

33
on:
44
workflow_dispatch:
55
push:
6-
paths-ignore:
7-
- '**.md'
8-
- '.github/**'
9-
- '!.github/workflows/android_main.yml'
106

117
concurrency:
128
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -49,9 +45,19 @@ jobs:
4945
- name: conan profile
5046
run: conan profile detect
5147

48+
- name: Gradle cache
49+
uses: gradle/actions/setup-gradle@v3
50+
5251
- name: gradle
5352
run: ./gradlew assembleDebug lintProDebug lintLiteDebug --stacktrace
5453

54+
- name: conan cache size
55+
run: du -h -d1 ~/.conan2/p
56+
- name: conan login
57+
run: conan remote login odr admin --password '${{ secrets.ARTIFACTORY }}'
58+
- name: conan upload
59+
run: conan upload "*" --check --confirm --remote odr
60+
5561
- name: Artifact APKs
5662
uses: actions/upload-artifact@v4
5763
with:
@@ -117,42 +123,43 @@ jobs:
117123
- name: conan profile
118124
run: conan profile detect
119125

126+
- name: Gradle cache
127+
uses: gradle/actions/setup-gradle@v3
128+
129+
- name: AVD cache
130+
uses: actions/cache@v4
131+
id: avd-cache
132+
with:
133+
path: |
134+
~/.android/avd/*
135+
~/.android/adb*
136+
key: avd-${{ matrix.api-level }}-v2
137+
120138
- name: Enable KVM group perms
121139
run: |
122140
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
123141
sudo udevadm control --reload-rules
124142
sudo udevadm trigger --name-match=kvm
125143
126-
- name: Run tests
144+
- name: Create AVD and generate snapshot for caching
145+
if: steps.avd-cache.outputs.cache-hit != 'true'
127146
uses: reactivecircus/android-emulator-runner@v2
128147
with:
129-
force-avd-creation: false
130-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save
131148
api-level: ${{ matrix.api-level }}
132149
arch: ${{ matrix.arch }}
133150
target: google_apis
134-
script: |
135-
mkdir -p testResults/screenshots
136-
adb logcat > testResults/logcat.txt &
137-
138-
adb shell screencap /data/local/tmp/beforeTests.png
139-
adb pull /data/local/tmp/beforeTests.png testResults/screenshots/
140-
141-
bundle exec fastlane tests || touch sorry_but_tests_are_failing
142-
adb pull /sdcard/Pictures/screenshots testResults/ || true
143-
144-
adb shell screencap /data/local/tmp/afterTests.png
145-
adb pull /data/local/tmp/afterTests.png testResults/screenshots/
146-
147-
mv app/build/reports/androidTests/connected testResults/
148-
mv app/build/outputs/androidTest-results testResults/
149-
150-
test ! -f sorry_but_tests_are_failing
151+
force-avd-creation: false
152+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
153+
disable-animations: false
154+
script: echo "Generated AVD snapshot for caching."
151155

152-
- name: upload test results
153-
uses: actions/upload-artifact@v4
154-
if: always()
156+
- name: Run tests
157+
uses: reactivecircus/android-emulator-runner@v2
155158
with:
156-
name: testResults-${{ matrix.api-level }}-${{ matrix.arch }}
157-
path: testResults
158-
if-no-files-found: error
159+
api-level: ${{ matrix.api-level }}
160+
arch: ${{ matrix.arch }}
161+
target: google_apis
162+
force-avd-creation: false
163+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
164+
disable-animations: true
165+
script: ./gradlew connectedCheck

app/conanprofile.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ compiler=clang
77
compiler.version=17
88
compiler.cppstd=20
99
compiler.libcxx=c++_shared
10-
build_type=RelWithDebInfo
10+
&:build_type=RelWithDebInfo
11+
odrcore/*:build_type=RelWithDebInfo
12+
build_type=Release
1113

1214
[conf]
1315
tools.android:ndk_path=@NDK_PATH@
1416
tools.build:skip_test=True
17+
tools.graph:skip_binaries=False

0 commit comments

Comments
 (0)