Skip to content

Commit 748d046

Browse files
committed
ci: fix release asset flattening and add emulator startup smoke test
1 parent 43068a4 commit 748d046

File tree

5 files changed

+88
-7
lines changed

5 files changed

+88
-7
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,54 @@ jobs:
5151
chmod +x verify.sh
5252
./verify.sh
5353
54+
emulator-smoke:
55+
name: Emulator Startup Smoke
56+
runs-on: ubuntu-latest
57+
needs: core-build
58+
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Set up JDK 17
63+
uses: actions/setup-java@v4
64+
with:
65+
java-version: '17'
66+
distribution: 'temurin'
67+
68+
- name: Setup Android SDK
69+
uses: android-actions/setup-android@v3
70+
71+
- name: Install Rust Toolchain
72+
uses: dtolnay/rust-toolchain@stable
73+
with:
74+
targets: aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android
75+
76+
- name: Cache Rust artifacts
77+
uses: Swatinem/rust-cache@v2
78+
with:
79+
workspaces: loader/app/src/main/rust
80+
81+
- name: Install cargo-ndk
82+
run: cargo install cargo-ndk --locked
83+
84+
- name: Run connected startup smoke test
85+
uses: reactivecircus/android-emulator-runner@v2
86+
with:
87+
api-level: 30
88+
target: google_apis
89+
arch: x86_64
90+
profile: Nexus 6
91+
disable-animations: true
92+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
93+
script: |
94+
if [ -z "${ANDROID_NDK_HOME:-}" ] && [ -d "${ANDROID_SDK_ROOT}/ndk" ]; then
95+
export ANDROID_NDK_HOME="$(ls -d "${ANDROID_SDK_ROOT}/ndk/"* | sort -V | tail -n 1)"
96+
fi
97+
echo "Using ANDROID_NDK_HOME=${ANDROID_NDK_HOME:-unset}"
98+
cd loader
99+
./gradlew -q dependencies || true
100+
./gradlew :app:connectedDebugAndroidTest --stacktrace
101+
54102
gui-package:
55103
name: GUI Package (${{ matrix.platform.name }})
56104
runs-on: ${{ matrix.platform.os }}

.github/workflows/release.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,18 @@ jobs:
148148
set -euo pipefail
149149
TAG="${{ steps.vars.outputs.tag }}"
150150
mkdir -p release-assets
151-
shopt -s nullglob
152151
153-
for file in release-artifacts/*; do
154-
base="$(basename "$file")"
155-
cp "$file" "release-assets/CrabShell-${TAG}-${base}"
156-
done
152+
# download-artifact can contain nested directories; publish files only.
153+
while IFS= read -r -d '' file; do
154+
rel="${file#release-artifacts/}"
155+
safe_rel="${rel//\//-}"
156+
cp "$file" "release-assets/CrabShell-${TAG}-${safe_rel}"
157+
done < <(find release-artifacts -type f -print0 | sort -z)
158+
159+
if ! find release-assets -maxdepth 1 -type f | grep -q .; then
160+
echo "No release files found under release-artifacts/"
161+
exit 1
162+
fi
157163
158164
ls -lah release-assets
159165

loader/app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ tasks.register('cargoBuild', Exec) {
7878
}
7979

8080
environment 'ANDROID_NDK_HOME', ndkHome
81-
commandLine 'cargo', 'ndk', '-t', 'arm64-v8a', '-t', 'armeabi-v7a', '-o', '../jniLibs', 'build', '--release'
81+
// Keep x86_64 for emulator/CI startup smoke tests.
82+
commandLine 'cargo', 'ndk', '-t', 'arm64-v8a', '-t', 'armeabi-v7a', '-t', 'x86_64', '-o', '../jniLibs', 'build', '--release'
8283
workingDir 'src/main/rust'
8384

8485
// Keep Android build honest: Rust/NDK failure should fail the build.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.kapp.shell;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import android.content.Context;
6+
7+
import androidx.test.core.app.ApplicationProvider;
8+
import androidx.test.ext.junit.runners.AndroidJUnit4;
9+
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
12+
13+
@RunWith(AndroidJUnit4.class)
14+
public class ShellStartupSmokeTest {
15+
@Test
16+
public void appContextIsAccessible() {
17+
Context appContext = ApplicationProvider.getApplicationContext();
18+
assertEquals("com.kapp.shell", appContext.getPackageName());
19+
}
20+
21+
@Test
22+
public void ensureDexLoadedDoesNotThrow() {
23+
Context appContext = ApplicationProvider.getApplicationContext();
24+
ShellApplication.ensureDexLoaded(appContext);
25+
}
26+
}

verify.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ if [ -z "$ANDROID_NDK_HOME" ]; then
153153
exit 1
154154
fi
155155

156-
cargo ndk -t arm64-v8a -t armeabi-v7a -o ../jniLibs build --release
156+
cargo ndk -t arm64-v8a -t armeabi-v7a -t x86_64 -o ../jniLibs build --release
157157
if [ $? -ne 0 ]; then
158158
echo -e "${RED}[FAIL] Cargo NDK build failed.${NC}"
159159
exit 1

0 commit comments

Comments
 (0)