-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (213 loc) · 8.11 KB
/
ci.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
name: Android CI
on:
schedule:
- cron: '0 0 */5 * *'
push:
branches-ignore:
- website
jobs:
build:
runs-on: macos-14
env:
ANDROID_KEYSTORE_FILE: '${{ github.workspace }}/release-key.jks'
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
CCACHE_NOHASHDIR: true
CCACHE_MAXSIZE: 1G
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
submodules: 'recursive'
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Prepare for building
id: prepare
run: |
chmod +x gradlew
base64 --decode <<< "${{ secrets.RELEASE_KEY }}" > "${{ env.ANDROID_KEYSTORE_FILE }}"
grep -q '[^[:space:]]' "${{ env.ANDROID_KEYSTORE_FILE }}" && echo release_key_exists=true >> $GITHUB_ENV || echo release_key_exists=false >> $GITHUB_ENV
- name: Cache dict.txt
uses: actions/cache@v4
with:
path: |
app/dict.txt
key: ${{ runner.os }}-dict.txt
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true
cache-overwrite-existing: true
cache-read-only: false
- name: Build APK
run: ./gradlew assembleRelease
env:
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
RELEASE_KEY_STORE_PASSWORD: ${{ secrets.RELEASE_KEY_STORE_PASSWORD }}
RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
release_key_exists: ${{ env.release_key_exists }}
- name: Upload built apk
env:
release_key_exists: ${{ env.release_key_exists }}
if: success() && env.release_key_exists == 'true'
uses: actions/upload-artifact@v4
with:
name: apk
path: |
app/build/outputs/apk/release/*.apk
- name: Upload signature
env:
release_key_exists: ${{ env.release_key_exists }}
if: success() && env.release_key_exists == 'true'
uses: actions/upload-artifact@v4
with:
name: signature_v4
path: |
app/build/outputs/apk/release/*.idsig
- name: Upload mappings
env:
release_key_exists: ${{ env.release_key_exists }}
if: success() && env.release_key_exists == 'true'
uses: actions/upload-artifact@v4
with:
name: mappings
path: app/build/outputs/mapping/release/
- name: Generate summary
env:
release_key_exists: ${{ env.release_key_exists }}
if: success() && env.release_key_exists == 'true'
run: |
brew install gnu-sed
echo "|Channel|Filename|SHA256|" >> $GITHUB_STEP_SUMMARY
echo "|:--------:|:--------:|:----------|" >> $GITHUB_STEP_SUMMARY
filename=$(ls app/build/outputs/apk/release/*.apk)
sha=$(shasum -a 256 $filename | gsed 's/ .*//')
channel=$(echo $filename | gsed 's/.*_//g' | gsed 's/.apk//')
filename=$(basename $filename)
echo "APK_FILENAME=$filename" >> $GITHUB_OUTPUT
echo "SHA256=$sha" >> $GITHUB_OUTPUT
echo "CHANNEL=$channel" >> $GITHUB_OUTPUT
echo "|$(echo $channel | gsed 's/./\u&/')|$filename|\`$sha\`|\n\n" >> $GITHUB_STEP_SUMMARY
echo "BUILD_SUCCESS=true" >> $GITHUB_OUTPUT
- name: Setup Debug Session
if: success() != true
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
instrumentation-tests:
name: Instrumentation tests
runs-on: ${{ matrix.os }}
timeout-minutes: 60
env:
JAVA_TOOL_OPTIONS: -Xmx4g -XX:+UseParallelGC
ANDROID_KEYSTORE_FILE: '${{ github.workspace }}/release-key.jks'
strategy:
fail-fast: false # Allow tests to continue on other devices if they fail on one device.
matrix:
include:
# - api-level: 26
# os: ubuntu-latest
# target: google_apis
# arch: x86_64
- api-level: 30
os: ubuntu-latest
target: default
arch: x86_64
- api-level: 34
os: ubuntu-latest
target: aosp_atd
arch: x86_64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
submodules: 'recursive'
- name: enable KVM for linux runners
if: runner.os == 'Linux'
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
- uses: gradle/actions/wrapper-validation@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true
cache-overwrite-existing: true
cache-read-only: false
add-job-summary: 'on-failure'
- name: Prepare for building
id: prepare
run: |
chmod +x gradlew
base64 --decode <<< "${{ secrets.RELEASE_KEY }}" > "${{ env.ANDROID_KEYSTORE_FILE }}"
grep -q '[^[:space:]]' "${{ env.ANDROID_KEYSTORE_FILE }}" && echo release_key_exists=true >> $GITHUB_ENV || echo release_key_exists=false >> $GITHUB_ENV
sed -i '/\/\/ CI TEST/{n;s/release/debug/g;}' app/build.gradle.kts
- name: Cache dict.txt
uses: actions/cache@v4
with:
path: |
app/dict.txt
key: ${{ runner.os }}-dict.txt
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}
- name: create AVD && Generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/[email protected]
with:
avd-name: test-${{ matrix.api-level }}-${{ matrix.target }}-${{ matrix.arch }}
api-level: ${{ matrix.api-level }}
force-avd-creation: false
disable-animations: true
disable-spellchecker: true
ram-size: 4096M
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
channel: stable
script: echo "Generated AVD snapshot for caching."
- name: run tests
uses: reactivecircus/[email protected]
env:
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
RELEASE_KEY_STORE_PASSWORD: ${{ secrets.RELEASE_KEY_STORE_PASSWORD }}
RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
with:
avd-name: test-${{ matrix.api-level }}-${{ matrix.target }}-${{ matrix.arch }}
api-level: ${{ matrix.api-level }}
force-avd-creation: false
disable-animations: true
disable-spellchecker: true
ram-size: 4096M
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
channel: stable
script: ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.notPackage=com.kevalpatel2106.benchmark.macro
- name: Upload test results Artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: android-test-report-avd-${{ matrix.api-level }}-${{ matrix.target }}-${{ matrix.arch }}
path: |
build/screenshots/**/*
build/androidTest-results/*
**/build/reports/androidTest/**/*
build/reports/*
if-no-files-found: warn