Repository navigation
283 lines (245 loc) · 11.5 KB
/
Copy pathandroid.yml
File metadata and controls
283 lines (245 loc) · 11.5 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
274
275
276
277
278
279
280
281
282
283
name: Android CI
on:
push:
branches: ['**']
# Pictures and prose do not need a half-hour build.
paths-ignore: ['docs/**', '**.md']
pull_request:
branches: [main]
paths-ignore: ['docs/**', '**.md']
workflow_dispatch:
# Least privilege. No repository write is needed to build an APK.
permissions:
contents: read
# A newer push replaces a run that is still waiting, but never kills one that has started: somebody may be
# about to download its APK.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: Lint, test, assemble
runs-on: ubuntu-latest
timeout-minutes: 30
# Job-level so every Gradle step sees them. The signing block in
# app/build.gradle.kts reads these env vars; blank values mean "unsigned".
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up JDK 17
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '17'
# v3 is unusable on current runners: it runs `sdkmanager tools`, and the
# legacy "tools" package was removed from Google's repository, so it exits
# 1 with "Failed to find package 'tools'". v4 drops that step.
- name: Set up Android SDK
uses: android-actions/setup-android@v4
# Must match compileSdk/targetSdk in app/build.gradle.kts.
# setup-android already accepts the SDK licenses and puts sdkmanager on PATH.
- name: Install SDK packages
run: sdkmanager --install "platform-tools" "platforms;android-35" "build-tools;35.0.0"
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
# Materialise the signing key from secrets. Nothing is committed to the
# repo, and the file is removed at the end of the job. The guard lives in
# the shell rather than in `if:` so the step is always defined and an
# absent key simply leaves the release APK unsigned.
- name: Decode signing keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: |
if [ -z "$KEYSTORE_BASE64" ]; then
echo "no keystore configured - release APK will be unsigned"
exit 0
fi
printf '%s' "$KEYSTORE_BASE64" | base64 --decode > "$RUNNER_TEMP/eyeblink-release.jks"
echo "KEYSTORE_FILE=$RUNNER_TEMP/eyeblink-release.jks" >> "$GITHUB_ENV"
# The platform-free brain: scheduling, the playback safety protocol, parsers, calibration math.
- name: Core tests
run: ./gradlew :core:test --stacktrace
- name: Lint
run: ./gradlew :app:lintDebug :lsposed:lintDebug --continue --stacktrace
# Lint prints only its first failure on the console; the full report is what is needed to fix them all.
- name: Show lint reports
if: failure()
run: |
shopt -s nullglob
for f in app/build/reports/lint-results-debug.txt lsposed/build/reports/lint-results-debug.txt \
app/build/intermediates/lint_intermediate_text_report/debug/lintReportDebug/lint-results-debug.txt; do
echo "=== $f ==="; sed -n 1,220p "$f"
done
- name: Assemble debug APKs
run: ./gradlew :app:assembleDebug :lsposed:assembleDebug --stacktrace
# Renders the real UI (the same Compose sources as the app) headlessly, so every change can be
# looked at. Non-blocking: a rendering hiccup must never hide a real build result.
- name: Render UI screenshots
continue-on-error: true
run: ./gradlew :tools:designlab:run --args="$GITHUB_WORKSPACE/build/shots" --stacktrace
# R8 + resource shrinking are enabled on release (see app/build.gradle.kts).
# Signed only when the secrets above were present; otherwise Gradle emits
# an unsigned release APK rather than failing.
- name: Assemble release APKs
run: ./gradlew :app:assembleRelease :lsposed:assembleRelease --stacktrace
# App Bundle: what Play actually consumes. Play serves per-device, so the
# bundle carries all ABIs while each install downloads only one slice.
- name: Assemble release App Bundle
run: ./gradlew :app:bundleRelease --stacktrace
# The privacy page promises that EyeBlink cannot reach the network. The manifest removes the permission even if a
# library asks for it; this proves it on every APK that was built - debug and release, the app and the module. It runs
# after the release build on purpose: before it, there were no release APKs to look at.
- name: Guard - no network permission
run: |
shopt -s nullglob
n=0
for APK in app/build/outputs/apk/debug/*.apk app/build/outputs/apk/release/*.apk \
lsposed/build/outputs/apk/debug/*.apk lsposed/build/outputs/apk/release/*.apk; do
n=$((n + 1))
if "$ANDROID_HOME"/build-tools/35.0.0/aapt2 dump permissions "$APK" | grep -qi "android.permission.INTERNET"; then
echo "::error::$APK declares INTERNET"; exit 1
fi
done
[ "$n" -gt 0 ] || { echo "::error::no APK found to check"; exit 1; }
echo "$n APKs checked, none declares INTERNET"
# apksigner is the source of truth. Do NOT look for META-INF/*.RSA:
# at minSdk 26 AGP emits v2/v3 signatures only, which write an APK
# Signing Block and no META-INF signature entries at all.
- name: Verify release APKs
run: |
shopt -s nullglob
APKS=(app/build/outputs/apk/release/*.apk)
if [ ${#APKS[@]} -eq 0 ]; then
echo "no release APK produced"; exit 1
fi
for APK in "${APKS[@]}"; do
echo "=== $(basename "$APK") ($(du -h "$APK" | cut -f1)) ==="
if "$ANDROID_HOME"/build-tools/35.0.0/apksigner verify --verbose --print-certs "$APK"; then
echo " result: SIGNED and verified"
else
echo " result: unsigned or unverifiable"
if [ -n "$KEYSTORE_PASSWORD" ]; then
echo " secrets were configured, so this is a real error"
exit 1
fi
fi
done
- name: Report artifact sizes
run: |
echo "release slices:"
du -h app/build/outputs/apk/release/*.apk 2>/dev/null || true
echo "app bundle:"
du -h app/build/outputs/bundle/release/*.aab 2>/dev/null || true
- name: Upload APKs
uses: actions/upload-artifact@v7
with:
name: eyeblink-apk
path: |
app/build/outputs/apk/debug/*.apk
app/build/outputs/apk/release/*.apk
app/build/outputs/apk/release/*.idsig
app/build/outputs/bundle/release/*.aab
lsposed/build/outputs/apk/debug/*.apk
lsposed/build/outputs/apk/release/*.apk
if-no-files-found: error
retention-days: 30
# Small downloads for a phone. Nearly every phone is arm64-v8a, and the zip above carries every variant.
- name: Upload the arm64 release APK
uses: actions/upload-artifact@v7
with:
name: eyeblink-release-arm64
path: app/build/outputs/apk/release/*arm64-v8a*.apk
if-no-files-found: error
retention-days: 30
# Not minified, so a crash log reads like the source. Installs next to the release build (com.eyeblink.app.debug).
- name: Upload the arm64 debug APK
uses: actions/upload-artifact@v7
with:
name: eyeblink-debug-arm64
path: app/build/outputs/apk/debug/*arm64-v8a*.apk
if-no-files-found: error
retention-days: 30
- name: Upload UI screenshots
uses: actions/upload-artifact@v7
with:
name: eyeblink-ui
path: build/shots/*.png
if-no-files-found: ignore
retention-days: 30
- name: Remove signing key
if: always()
run: rm -f "$RUNNER_TEMP/eyeblink-release.jks"
# CI used to compile the app and never start it, which is how a crash in Application.onCreate reached a phone.
# This job installs a build on an emulator, walks through the app (onboarding, a rest and skipping it, a blink, every tab
# and page, the Blink Studio, the app picker, the calibration camera allowed and refused, the language list, the theme),
# lets the engine run with the accessibility service on, and fails if the app dies or an engine task throws.
# It runs twice: the debug build, and the minified build, which is the release build as R8 leaves it - the one that
# breaks when something is shrunk or renamed that native code or reflection needs.
# Screenshots, UI dumps and logs are kept in the "eyeblink-smoke-<variant>" artifacts. It builds its own APK, so it never
# sees the signing secrets.
smoke:
name: Start it on an emulator (${{ matrix.variant }})
runs-on: ubuntu-latest
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
include:
- variant: debug
task: assembleDebug
- variant: minified
task: assembleMinified
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up JDK 17
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '17'
- name: Set up Android SDK
uses: android-actions/setup-android@v4
- name: Install SDK packages
run: sdkmanager --install "platform-tools" "platforms;android-35" "build-tools;35.0.0"
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
- name: Build the ${{ matrix.variant }} APK
run: ./gradlew :app:${{ matrix.task }} --stacktrace
# The emulator needs hardware acceleration, which the runner only allows once /dev/kvm is open to everyone.
- 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
# Lets the log say what colours a screenshot is made of, which is all a reader of a log can see of one.
- name: Install Pillow
run: sudo apt-get update -qq && sudo apt-get install -y -qq python3-pil
# Animations stay on: the app has to survive its own motion, and it switches to a still version when the phone
# turns animations off. The screen is a Pixel 6's, so layouts are the size a person sees.
- name: Walk through the app
uses: reactivecircus/android-emulator-runner@v2
env:
SMOKE_VARIANT: ${{ matrix.variant }}
with:
api-level: 35
target: google_apis
arch: x86_64
profile: pixel_6
ram-size: 3072M
disable-animations: false
# The runner's own options, plus a front camera: the calibration page opens it, and without one nothing but an
# error could ever be seen there. (There is no back camera to ask for, so none is started.)
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-front emulated -camera-back none
script: bash .github/smoke/smoke.sh
- name: Upload what it saw
if: always()
uses: actions/upload-artifact@v7
with:
name: eyeblink-smoke-${{ matrix.variant }}
path: build/smoke
if-no-files-found: ignore
retention-days: 14