Repository navigation
173 lines (153 loc) · 5.78 KB
/
Copy pathandroid-tests.yml
File metadata and controls
173 lines (153 loc) · 5.78 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
name: Android Tests
on:
workflow_dispatch:
push:
branches: [main]
paths:
- .github/workflows/android-tests.yml
- .gitmodules
- .npmrc
- app/**
- build.gradle.kts
- ci/script/download_android_dependencies.sh
- ci/script/prepare_android_dependencies.py
- cmake/**
- avator/**
- examples/**
- gradle/**
- gradle.properties
- gradlew
- gradlew.bat
- llm/**
- package.json
- package-lock.json
- npm-shrinkwrap.json
- pnpm-workspace.yaml
- quickjs/**
- settings.gradle.kts
- showerclient/**
- terminal/**
- terminal
- tools/native_ripgrep/**
- tools/packages_whitelist.txt
- tools/example_packages/sync_example_packages.py
- web-chat/**
concurrency:
group: android-tests-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
PYTHONDONTWRITEBYTECODE: '1'
JAVA_VERSION: '21'
ANDROID_BUILD_TOOLS_VERSION: '35.0.0'
ANDROID_NDK_VERSION: '25.1.8937393'
ANDROID_API_LEVEL: '26'
RUST_VERSION: '1.88.0'
MANUAL_DEPS_DIR: manual-deps
jobs:
tests:
name: Android JVM tests
runs-on: ubuntu-24.04
timeout-minutes: 240
steps:
- name: Checkout source
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
ref: ${{ github.sha }}
fetch-depth: 1
persist-credentials: false
submodules: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.12'
- name: Initialize terminal submodule
shell: bash
run: |
set -euo pipefail
git submodule sync -- terminal
git submodule update --init --recursive --depth 1 terminal
git submodule status -- terminal
- name: Set up JDK
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
cache: gradle
- name: Set up Android SDK
uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4
with:
packages: ''
- name: Install required Android toolchain
shell: bash
run: |
set -euo pipefail
sdkmanager --install \
"platform-tools" \
"platforms;android-34" \
"platforms;android-36" \
"build-tools;$ANDROID_BUILD_TOOLS_VERSION" \
"ndk;$ANDROID_NDK_VERSION"
- name: Restore Android dependency cache
id: cache-manual-deps
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: ${{ env.MANUAL_DEPS_DIR }}
key: android-full-deps-${{ runner.os }}-${{ hashFiles('ci/script/download_android_dependencies.sh', 'ci/script/prepare_android_dependencies.py') }}
- name: Restore generated STT asset cache
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: app/build/generated/stt-model-assets
key: stt-model-assets-${{ runner.os }}-${{ hashFiles('app/config/stt-model-assets.properties') }}
- name: Download Android dependencies
if: steps.cache-manual-deps.outputs.cache-hit != 'true'
run: bash ci/script/download_android_dependencies.sh full "$MANUAL_DEPS_DIR"
- name: Prepare Android dependencies
run: |
python3 ci/script/prepare_android_dependencies.py \
--profile full \
--archives "$MANUAL_DEPS_DIR" \
--repository "$GITHUB_WORKSPACE"
- name: Restore native ripgrep cache
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: |
~/.cargo/registry
~/.cargo/git
tools/native_ripgrep/target
key: native-ripgrep-arm64-${{ runner.os }}-${{ runner.arch }}-ndk-${{ env.ANDROID_NDK_VERSION }}-api-${{ env.ANDROID_API_LEVEL }}-rust-${{ env.RUST_VERSION }}-${{ hashFiles('tools/native_ripgrep/Cargo.toml', 'tools/native_ripgrep/Cargo.lock', 'tools/native_ripgrep/**/*.rs', 'tools/native_ripgrep/build_native_ripgrep.ps1') }}
- name: Build native ripgrep
shell: bash
run: |
set -euo pipefail
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/$ANDROID_NDK_VERSION"
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android${ANDROID_API_LEVEL}-clang"
rustup toolchain install "$RUST_VERSION" --profile minimal
rustup target add --toolchain "$RUST_VERSION" aarch64-linux-android
cargo "+$RUST_VERSION" build \
--manifest-path tools/native_ripgrep/Cargo.toml \
--release \
--target aarch64-linux-android \
--locked
install -Dm755 \
tools/native_ripgrep/target/aarch64-linux-android/release/liboperit_ripgrep.so \
app/src/main/jniLibs/arm64-v8a/liboperit_ripgrep.so
test -s app/src/main/jniLibs/arm64-v8a/liboperit_ripgrep.so
- name: Configure Android SDK
shell: bash
run: |
set -euo pipefail
echo "sdk.dir=$ANDROID_HOME" > local.properties
- name: Run JVM unit tests
run: ./gradlew :app:testDebugUnitTest --stacktrace --no-daemon
- name: Upload Android test reports
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: operit-android-test-reports-${{ github.run_number }}
path: |
app/build/reports/**
build/reports/**
if-no-files-found: warn
retention-days: 14