Repository navigation
183 lines (161 loc) · 5.88 KB
/
Copy pathandroid.yml
File metadata and controls
183 lines (161 loc) · 5.88 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
name: Android CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: android-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
verify:
name: Build and verify
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout source and LFS files
uses: actions/checkout@v7
with:
lfs: true
# Fails in seconds, before the toolchain is set up: VERSION is valid and
# CHANGELOG.md has the matching dated section (docs/RELEASE.md).
- name: Check version and changelog
shell: bash
run: |
python3 -m unittest discover -s scripts -p 'test_*.py'
python3 scripts/release_check.py check
- name: Set up JDK 17
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '17'
cache: gradle
- name: Set up Android SDK
uses: android-actions/setup-android@v4
with:
# The retired legacy 'tools' package is still the action's default and
# now fails with "Failed to find package 'tools'", which killed every
# job before it reached the build. platform-tools is what the build
# actually needs from here.
packages: 'platform-tools'
- name: Install Android build components
shell: bash
run: |
sdkmanager "platforms;android-36" \
"build-tools;35.0.0" \
"ndk;27.0.12077973" \
"cmake;3.22.1"
- name: Verify LFS objects
shell: bash
run: |
git lfs checkout
if grep -RIl --exclude-dir=.git "version https://git-lfs.github.com/spec/v1" app/libs app/src/main/assets/models; then
echo "A Git LFS pointer was left unresolved" >&2
exit 1
fi
- name: Fetch pinned librime dependencies
shell: bash
run: bash scripts/fetch_rime_deps.sh
- name: Ensure Gradle wrapper is executable
shell: bash
run: chmod +x gradlew
- name: Run unit tests, lint, and assemble
shell: bash
run: |
set +e
./gradlew :app:testDebugUnitTest :app:lintDebug :app:assembleDebug :app:assembleDebugAndroidTest --build-cache --parallel --no-daemon --console=plain
status=$?
if [[ $status -ne 0 && -f app/build/reports/lint-results-debug.txt ]]; then
echo "::group::Full Android Lint report"
cat app/build/reports/lint-results-debug.txt
echo "::endgroup::"
fi
exit $status
- name: Verify APK version identity
shell: bash
run: |
python3 scripts/release_check.py apk app/build/outputs/apk/debug/app-debug.apk \
--aapt2 "$ANDROID_HOME/build-tools/35.0.0/aapt2"
- name: Upload test APKs
uses: actions/upload-artifact@v7
with:
name: openIME-test-apks
path: |
app/build/outputs/apk/debug/app-debug.apk
app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
if-no-files-found: error
compression-level: 0
retention-days: 1
compatibility:
needs: verify
name: Compatibility API ${{ matrix.api-level }}
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
api-level: [26, 29, 31, 34]
steps:
- name: Enable KVM group perms
shell: bash
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: Set up Android SDK
uses: android-actions/setup-android@v4
with:
packages: 'platform-tools'
- name: Download prebuilt test APKs
uses: actions/download-artifact@v8
with:
name: openIME-test-apks
path: ci-apks
- name: Prepare instrumentation runner
shell: bash
run: |
cat > ci-run-instrumentation.sh <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
api_level="$1"
mkdir -p ci-reports
app_apk="$(find ci-apks -type f -name 'app-debug.apk' -print -quit)"
test_apk="$(find ci-apks -type f -name 'app-debug-androidTest.apk' -print -quit)"
test -n "$app_apk"
test -n "$test_apk"
adb install -r "$app_apk"
adb install -r "$test_apk"
report="ci-reports/instrumentation-api-${api_level}.txt"
adb shell am instrument -w -r \
llc.slacker.openime.test/androidx.test.runner.AndroidJUnitRunner \
| tee "$report"
# 'am instrument' exits 0 even when tests fail; a clean run ends with "OK (N tests)".
if ! grep -aq '^OK (' "$report"; then
echo "::error::Instrumentation tests failed on API ${api_level}"
grep -a -B1 -A12 'INSTRUMENTATION_STATUS_CODE: -[12]' "$report" | head -120 || true
exit 1
fi
EOF
chmod +x ci-run-instrumentation.sh
- name: Run compatibility instrumentation
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
target: default
profile: pixel_2
disable-animations: true
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: bash ci-run-instrumentation.sh ${{ matrix.api-level }}
- name: Upload compatibility test report
if: always()
uses: actions/upload-artifact@v7
with:
name: compatibility-api-${{ matrix.api-level }}
path: ci-reports
if-no-files-found: warn
compression-level: 0
retention-days: 7