Skip to content

Commit cf3b526

Browse files
madeyeclaude
authored andcommitted
Add E2E test GitHub Actions workflow
Parameterize test-e2e.sh with env-var defaults so it works both locally (macOS/ARM64) and on CI (Linux/x86_64). Add TARGET_ABI Gradle property to build a single-architecture APK, and create an e2e-test workflow that runs the VPN connectivity tests on an x86_64 emulator with KVM. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 962a289 commit cf3b526

File tree

3 files changed

+476
-2
lines changed

3 files changed

+476
-2
lines changed

.github/workflows/e2e-test.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: E2E Test
2+
on:
3+
push:
4+
branches: [master]
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
e2e-test:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 45
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
submodules: recursive
16+
17+
- uses: actions/setup-java@v4
18+
with:
19+
distribution: jetbrains
20+
java-version: 21
21+
22+
- uses: dtolnay/rust-toolchain@stable
23+
with:
24+
targets: x86_64-linux-android
25+
26+
- name: Enable KVM
27+
run: |
28+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
29+
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
30+
sudo udevadm control --reload-rules
31+
sudo udevadm trigger --name-match=kvm
32+
33+
- name: Gradle cache
34+
uses: actions/cache@v4
35+
with:
36+
path: |
37+
~/.gradle/caches
38+
~/.gradle/wrapper
39+
key: gradle-${{ hashFiles('**/*.gradle*', 'gradle/wrapper/gradle-wrapper.properties') }}
40+
41+
- name: Cargo cache
42+
uses: actions/cache@v4
43+
with:
44+
path: |
45+
~/.cargo/registry
46+
~/.cargo/git
47+
core/src/main/rust/shadowsocks-rust/target
48+
key: cargo-${{ hashFiles('core/src/main/rust/shadowsocks-rust/Cargo.lock') }}
49+
50+
- name: Build debug APK (x86_64)
51+
run: ./gradlew assembleDebug -PCARGO_PROFILE=debug -PTARGET_ABI=x86_64
52+
53+
- name: Build ssserver
54+
run: |
55+
cd core/src/main/rust/shadowsocks-rust
56+
cargo build --release --bin ssserver --features "server,aead-cipher,logging"
57+
58+
- name: E2E Test
59+
uses: ReactiveCircus/android-emulator-runner@v2
60+
with:
61+
api-level: 34
62+
target: google_apis
63+
arch: x86_64
64+
force-avd-creation: true
65+
emulator-options: >-
66+
-no-snapshot-save -no-window -gpu swiftshader_indirect
67+
-noaudio -no-boot-anim
68+
disable-animations: true
69+
script: bash test-e2e.sh
70+
env:
71+
SKIP_EMULATOR_BOOT: "true"
72+
ADB: adb
73+
APK: ${{ github.workspace }}/mobile/build/outputs/apk/debug/mobile-x86_64-debug.apk
74+
SSSERVER: ${{ github.workspace }}/core/src/main/rust/shadowsocks-rust/target/release/ssserver
75+
76+
- name: Upload screenshots
77+
uses: actions/upload-artifact@v4
78+
if: always()
79+
with:
80+
name: e2e-screenshots
81+
path: screen_*.png

core/build.gradle.kts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ plugins {
1010

1111
setupCore()
1212

13+
val allAbis = mapOf("arm" to "armeabi-v7a", "arm64" to "arm64-v8a", "x86" to "x86", "x86_64" to "x86_64")
14+
val targetAbi = findProperty("TARGET_ABI")?.toString()
15+
1316
android {
1417
namespace = "com.github.shadowsocks.core"
1518

1619
defaultConfig {
1720
consumerProguardFiles("proguard-rules.pro")
1821

1922
externalNativeBuild.ndkBuild {
20-
abiFilters("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
23+
val abis = if (targetAbi != null) listOf(allAbis.getValue(targetAbi)) else allAbis.values.toList()
24+
abiFilters(*abis.toTypedArray())
2125
arguments("-j${Runtime.getRuntime().availableProcessors()}")
2226
}
2327

@@ -39,7 +43,7 @@ android {
3943
cargo {
4044
module = "src/main/rust/shadowsocks-rust"
4145
libname = "sslocal"
42-
targets = listOf("arm", "arm64", "x86", "x86_64")
46+
targets = if (targetAbi != null) listOf(targetAbi) else listOf("arm", "arm64", "x86", "x86_64")
4347
profile = findProperty("CARGO_PROFILE")?.toString() ?: currentFlavor
4448
extraCargoBuildArguments = listOf("--bin", libname!!)
4549
featureSpec.noDefaultBut(arrayOf(

0 commit comments

Comments
 (0)